From patchwork Thu Jul 24 18:13:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 4619451 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A3064C0515 for ; Thu, 24 Jul 2014 18:17:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D37AF201EC for ; Thu, 24 Jul 2014 18:17:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB10E201DD for ; Thu, 24 Jul 2014 18:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934099AbaGXSOl (ORCPT ); Thu, 24 Jul 2014 14:14:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59743 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933705AbaGXSOj (ORCPT ); Thu, 24 Jul 2014 14:14:39 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6OIE93o027387 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Jul 2014 14:14:09 -0400 Received: from t540p.bos.redhat.com ([10.18.25.41]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6OIE6R2008153; Thu, 24 Jul 2014 14:14:08 -0400 From: Benjamin Tissoires To: Dmitry Torokhov , Jiri Kosina , Ping Cheng , Jason Gerecke , Przemo Firszt Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v2 02/10] Input - wacom: put a flag when the led are initialized Date: Thu, 24 Jul 2014 14:13:57 -0400 Message-Id: <1406225645-32141-3-git-send-email-benjamin.tissoires@redhat.com> In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com> References: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This solves a bug with the wireless receiver: - at plug, the wireless receiver does not know which Wacom device it is connected to, so it does not actually creates all the LEDs - when the tablet connects, wacom->wacom_wac.features.type is set to the proper device so that wacom_wac can understand the packets - when the receiver is unplugged, it detects that a LED should have been created (based on wacom->wacom_wac.features.type) and tries to remove it: crash when removing the sysfs group. Side effect, we can now safely call several times wacom_destroy_leds(). Signed-off-by: Benjamin Tissoires Acked-by: Ping Cheng --- no changes in v2 drivers/hid/wacom.h | 1 + drivers/hid/wacom_sys.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h index dd67b7d..a678f82 100644 --- a/drivers/hid/wacom.h +++ b/drivers/hid/wacom.h @@ -118,6 +118,7 @@ struct wacom { u8 hlv; /* status led brightness button pressed (1..127) */ u8 img_lum; /* OLED matrix display brightness */ } led; + bool led_initialized; struct power_supply battery; }; diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 9dbb6dd..c857b3d 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -729,12 +729,18 @@ static int wacom_initialize_leds(struct wacom *wacom) return error; } wacom_led_control(wacom); + wacom->led_initialized = true; return 0; } static void wacom_destroy_leds(struct wacom *wacom) { + if (!wacom->led_initialized) + return; + + wacom->led_initialized = false; + switch (wacom->wacom_wac.features.type) { case INTUOS4S: case INTUOS4: