Commit fce9957d authored by Jason Gerecke's avatar Jason Gerecke Committed by Jiri Kosina

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: default avatarJason Gerecke <killertofu@gmail.com>
Acked-by: default avatarPing Cheng <pingc@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 953f2c5f
...@@ -142,4 +142,5 @@ void wacom_wac_usage_mapping(struct hid_device *hdev, ...@@ -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, int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
struct hid_usage *usage, __s32 value); struct hid_usage *usage, __s32 value);
void wacom_wac_report(struct hid_device *hdev, struct hid_report *report); void wacom_wac_report(struct hid_device *hdev, struct hid_report *report);
void wacom_battery_work(struct work_struct *work);
#endif #endif
...@@ -1057,8 +1057,7 @@ static int wacom_initialize_battery(struct wacom *wacom) ...@@ -1057,8 +1057,7 @@ static int wacom_initialize_battery(struct wacom *wacom)
static void wacom_destroy_battery(struct wacom *wacom) static void wacom_destroy_battery(struct wacom *wacom)
{ {
if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && if (wacom->battery.dev) {
wacom->battery.dev) {
power_supply_unregister(&wacom->battery); power_supply_unregister(&wacom->battery);
wacom->battery.dev = NULL; wacom->battery.dev = NULL;
power_supply_unregister(&wacom->ac); power_supply_unregister(&wacom->ac);
...@@ -1329,6 +1328,20 @@ static void wacom_wireless_work(struct work_struct *work) ...@@ -1329,6 +1328,20 @@ static void wacom_wireless_work(struct work_struct *work)
return; 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. * Not all devices report physical dimensions from HID.
* Compute the default from hardcoded logical dimension * Compute the default from hardcoded logical dimension
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment