diff options
| author | Jason Gerecke <killertofu@gmail.com> | 2015-03-06 14:47:40 -0500 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2015-03-11 11:46:12 -0400 |
| commit | fce9957d8f618346b76c63066e146fc76ed975ce (patch) | |
| tree | 95dfe85fa6a0ab13fef04a01c4b020f6d000cf23 | |
| parent | 953f2c5f716305a5c2ebea935f410ee7aa439159 (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>
| -rw-r--r-- | drivers/hid/wacom.h | 1 | ||||
| -rw-r--r-- | 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 b8344b140760..ad7318db1dfe 100644 --- a/drivers/hid/wacom.h +++ b/drivers/hid/wacom.h | |||
| @@ -142,4 +142,5 @@ void wacom_wac_usage_mapping(struct hid_device *hdev, | |||
| 142 | int wacom_wac_event(struct hid_device *hdev, struct hid_field *field, | 142 | int wacom_wac_event(struct hid_device *hdev, struct hid_field *field, |
| 143 | struct hid_usage *usage, __s32 value); | 143 | struct hid_usage *usage, __s32 value); |
| 144 | void wacom_wac_report(struct hid_device *hdev, struct hid_report *report); | 144 | void wacom_wac_report(struct hid_device *hdev, struct hid_report *report); |
| 145 | void wacom_battery_work(struct work_struct *work); | ||
| 145 | #endif | 146 | #endif |
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) | |||
| 1057 | 1057 | ||
| 1058 | static void wacom_destroy_battery(struct wacom *wacom) | 1058 | static void wacom_destroy_battery(struct wacom *wacom) |
| 1059 | { | 1059 | { |
| 1060 | if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && | 1060 | if (wacom->battery.dev) { |
| 1061 | wacom->battery.dev) { | ||
| 1062 | power_supply_unregister(&wacom->battery); | 1061 | power_supply_unregister(&wacom->battery); |
| 1063 | wacom->battery.dev = NULL; | 1062 | wacom->battery.dev = NULL; |
| 1064 | power_supply_unregister(&wacom->ac); | 1063 | power_supply_unregister(&wacom->ac); |
| @@ -1329,6 +1328,20 @@ fail: | |||
| 1329 | return; | 1328 | return; |
| 1330 | } | 1329 | } |
| 1331 | 1330 | ||
| 1331 | void wacom_battery_work(struct work_struct *work) | ||
| 1332 | { | ||
| 1333 | struct wacom *wacom = container_of(work, struct wacom, work); | ||
| 1334 | |||
| 1335 | if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && | ||
| 1336 | !wacom->battery.dev) { | ||
| 1337 | wacom_initialize_battery(wacom); | ||
| 1338 | } | ||
| 1339 | else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && | ||
| 1340 | wacom->battery.dev) { | ||
| 1341 | wacom_destroy_battery(wacom); | ||
| 1342 | } | ||
| 1343 | } | ||
| 1344 | |||
| 1332 | /* | 1345 | /* |
| 1333 | * Not all devices report physical dimensions from HID. | 1346 | * Not all devices report physical dimensions from HID. |
| 1334 | * Compute the default from hardcoded logical dimension | 1347 | * Compute the default from hardcoded logical dimension |
