summaryrefslogtreecommitdiff
path: root/drivers/hid/wacom_sys.c
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2015-03-06 11:47:40 -0800
committerJiri Kosina <jkosina@suse.cz>2015-03-11 11:46:12 -0400
commitfce9957d8f618346b76c63066e146fc76ed975ce (patch)
tree95dfe85fa6a0ab13fef04a01c4b020f6d000cf23 /drivers/hid/wacom_sys.c
parent953f2c5f716305a5c2ebea935f410ee7aa439159 (diff)
HID: wacom: Allow dynamic battery creation/destruction
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 <killertofu@gmail.com> Acked-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/wacom_sys.c')
-rw-r--r--drivers/hid/wacom_sys.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 957699fb70b5..dfa4be7eac8c 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