From patchwork Fri Mar 6 19:47:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 5957651 X-Patchwork-Delegate: jikos@jikos.cz 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 99823BF440 for ; Fri, 6 Mar 2015 19:48:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C791B20263 for ; Fri, 6 Mar 2015 19:48:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDAB92038D for ; Fri, 6 Mar 2015 19:48:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755846AbbCFTsK (ORCPT ); Fri, 6 Mar 2015 14:48:10 -0500 Received: from mail-pd0-f180.google.com ([209.85.192.180]:34229 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755840AbbCFTsJ (ORCPT ); Fri, 6 Mar 2015 14:48:09 -0500 Received: by pdno5 with SMTP id o5so3377476pdn.1 for ; Fri, 06 Mar 2015 11:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PannqnbdF3Jd6hl3gSBICQ9OpMz57iC73KIKByl+2Sw=; b=li6x0EW9y57HXPA4FW1K8P8LprQFTWzhSK/xPZ42boaM53MyxH+dxzP4/Chnx0TOzS sqLzKBUlOm6RE6Op5KZFAm9Susf1YD8wQUq0m3EGBB7s6Qv5zHcnXNBwcpFwIf7QLVVb cIXzvkTko46gzZfOgDInno/RiYSy0NYhvyFumQ3C1I8F0kZb4hMHm4cicgy0DEiHjUxN 1klcnvTZMF8M7wgBEaSIvdVEj5NilV0hZQLsuIKzBIqdS0LxEmo+14WaZ1mITa6Qb89b sb+biRFZb7pbT8LfH1Oz8zMC6G5QMeXrTJ9v6kZcTC/KN4RnJP14qnFhSs6E9aiXXJjg zOSQ== X-Received: by 10.66.97.7 with SMTP id dw7mr28500621pab.56.1425671289180; Fri, 06 Mar 2015 11:48:09 -0800 (PST) Received: from wacom-arch2.localdomain ([67.51.163.2]) by mx.google.com with ESMTPSA id gf2sm2367452pbc.60.2015.03.06.11.48.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Mar 2015 11:48:07 -0800 (PST) From: Jason Gerecke To: jkosina@suse.cz, linux-input@vger.kernel.org Cc: pinglinux@gmail.com, benjamin.tissoires@redhat.com, Jason Gerecke Subject: [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction Date: Fri, 6 Mar 2015 11:47:40 -0800 Message-Id: <1425671264-4944-10-git-send-email-killertofu@gmail.com> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1425671264-4944-1-git-send-email-killertofu@gmail.com> References: <1425671264-4944-1-git-send-email-killertofu@gmail.com> 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Tablets like the Intuos, Intuos Pro, and Bamboo have a connector for an optional wireless module that can be connected on the fly. The presence (or absence) of this module is indicated in a status report recieved from the tablet. This patch adds a workqueue function that will create or destroy a power_supply object at runtime to match the current state of the WACOM_QUIRK_BATTERY flag. Signed-off-by: Jason Gerecke --- drivers/hid/wacom.h | 1 + drivers/hid/wacom_sys.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h index b8344b1..ad7318d 100644 --- a/drivers/hid/wacom.h +++ b/drivers/hid/wacom.h @@ -142,4 +142,5 @@ void wacom_wac_usage_mapping(struct hid_device *hdev, int wacom_wac_event(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value); void wacom_wac_report(struct hid_device *hdev, struct hid_report *report); +void wacom_battery_work(struct work_struct *work); #endif diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 957699f..dfa4be7 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1057,8 +1057,7 @@ static int wacom_initialize_battery(struct wacom *wacom) static void wacom_destroy_battery(struct wacom *wacom) { - if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && - wacom->battery.dev) { + if (wacom->battery.dev) { power_supply_unregister(&wacom->battery); wacom->battery.dev = NULL; power_supply_unregister(&wacom->ac); @@ -1329,6 +1328,20 @@ fail: return; } +void wacom_battery_work(struct work_struct *work) +{ + struct wacom *wacom = container_of(work, struct wacom, work); + + if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && + !wacom->battery.dev) { + wacom_initialize_battery(wacom); + } + else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && + wacom->battery.dev) { + wacom_destroy_battery(wacom); + } +} + /* * Not all devices report physical dimensions from HID. * Compute the default from hardcoded logical dimension