Or Gnome complains about an empty battery.
Signed-off-by: Benjamin Tissoires <[email protected]>
Acked-by: Ping Cheng <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
[[email protected]: Imported into input-wacom repository (9f1015d)]
Signed-off-by: Aaron Armstrong Skomra <[email protected]>
[[email protected]: Backported from input-wacom repository (4cbb4d9)]
Signed-off-by: Aaron Armstrong Skomra <[email protected]>
---
2.6.38/wacom_sys.c | 28 ++++++++++++++++++++++------
3.17/wacom_sys.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------
3.7/wacom_sys.c | 28 ++++++++++++++++++++++------
3 files changed, 88 insertions(+), 18 deletions(-)
diff --git a/2.6.38/wacom_sys.c b/2.6.38/wacom_sys.c
index 5683cd8..481942a 100644
--- a/2.6.38/wacom_sys.c
+++ b/2.6.38/wacom_sys.c
@@ -1372,6 +1372,7 @@ static void wacom_remote_destroy_one(struct wacom *wacom,
unsigned int index)
remote->remotes[i].group.name = NULL;
remote->remotes[i].registered = false;
+ remote->remotes[i].battery.battery.dev = NULL;
wacom->led.select[i] = WACOM_STATUS_UNKNOWN;
}
}
@@ -1631,11 +1632,6 @@ static int wacom_remote_create_one(struct wacom *wacom,
u32 serial,
remote->remotes[index].registered = true;
- error = __wacom_initialize_battery(wacom,
- &remote->remotes[index].battery);
- if (error)
- goto fail;
-
devres_close_group(dev, &remote->remotes[index]);
return 0;
@@ -1649,6 +1645,24 @@ fail:
return error;
}
+static int wacom_remote_attach_battery(struct wacom *wacom, int index)
+{
+ struct wacom_remote *remote = wacom->remote;
+ int error;
+ if (!remote->remotes[index].registered)
+ return 0;
+
+ if (remote->remotes[index].battery.battery.dev)
+ return 0;
+
+ error = __wacom_initialize_battery(wacom,
+
&wacom->remote->remotes[index].battery);
+ if (error)
+ return error;
+
+ return 0;
+}
+
/*
* Not all devices report physical dimensions from HID.
* Compute the default from hardcoded logical dimension
@@ -1830,8 +1844,10 @@ static void wacom_remote_work(struct work_struct *work)
serial = data.remote[i].serial;
if (data.remote[i].connected) {
- if (remote->remotes[i].serial == serial)
+ if (remote->remotes[i].serial == serial) {
+ wacom_remote_attach_battery(wacom, i);
continue;
+ }
if (remote->remotes[i].serial)
wacom_remote_destroy_one(wacom, i);
diff --git a/3.17/wacom_sys.c b/3.17/wacom_sys.c
index 793cb72..29a5396 100644
--- a/3.17/wacom_sys.c
+++ b/3.17/wacom_sys.c
@@ -2020,6 +2020,16 @@ fail:
return;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
+static void wacom_destroy_remote_battery(struct wacom_battery *battery)
+{
+ if (battery->battery.dev) {
+ power_supply_unregister(&battery->battery);
+ battery->battery.dev = NULL;
+ }
+}
+#endif
+
static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
{
struct wacom_remote *remote = wacom->remote;
@@ -2031,6 +2041,15 @@ static void wacom_remote_destroy_one(struct wacom
*wacom, unsigned int index)
remote->remotes[index].registered = false;
spin_unlock_irqrestore(&remote->remote_lock, flags);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ if (WACOM_POWERSUPPLY_DEVICE(remote->remotes[index].battery.battery))
+ devres_release_group(&wacom->hdev->dev,
+ &remote->remotes[index].battery.bat_desc);
+#else
+ if (remote->remotes[index].battery.battery.dev)
+ wacom_destroy_remote_battery(&remote->remotes[index].battery);
+#endif
+
if (remote->remotes[index].group.name)
devres_release_group(&wacom->hdev->dev,
&remote->remotes[index]);
@@ -2040,6 +2059,7 @@ static void wacom_remote_destroy_one(struct wacom *wacom,
unsigned int index)
remote->remotes[i].serial = 0;
remote->remotes[i].group.name = NULL;
remote->remotes[i].registered = false;
+
WACOM_POWERSUPPLY_DEVICE(remote->remotes[i].battery.battery) = NULL;
wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
}
}
@@ -2096,11 +2116,6 @@ static int wacom_remote_create_one(struct wacom *wacom,
u32 serial,
if (error)
goto fail;
- error = __wacom_initialize_battery(wacom,
- &remote->remotes[index].battery);
- if (error)
- goto fail;
-
remote->remotes[index].registered = true;
devres_close_group(dev, &remote->remotes[index]);
@@ -2112,6 +2127,27 @@ fail:
return error;
}
+static int wacom_remote_attach_battery(struct wacom *wacom, int index)
+{
+ struct wacom_remote *remote = wacom->remote;
+ int error;
+ if (!remote->remotes[index].registered)
+ return 0;
+
+ if (WACOM_POWERSUPPLY_DEVICE(remote->remotes[index].battery.battery))
+ return 0;
+
+ if (wacom->led.groups[index].select == WACOM_STATUS_UNKNOWN)
+ return 0;
+
+ error = __wacom_initialize_battery(wacom,
+
&wacom->remote->remotes[index].battery);
+ if (error)
+ return error;
+
+ return 0;
+}
+
static void wacom_remote_work(struct work_struct *work)
{
struct wacom *wacom = container_of(work, struct wacom, remote_work);
@@ -2142,8 +2178,10 @@ static void wacom_remote_work(struct work_struct *work)
serial = data.remote[i].serial;
if (data.remote[i].connected) {
- if (remote->remotes[i].serial == serial)
+ if (remote->remotes[i].serial == serial) {
+ wacom_remote_attach_battery(wacom, i);
continue;
+ }
if (remote->remotes[i].serial)
wacom_remote_destroy_one(wacom, i);
diff --git a/3.7/wacom_sys.c b/3.7/wacom_sys.c
index 0094ff5..37e1700 100644
--- a/3.7/wacom_sys.c
+++ b/3.7/wacom_sys.c
@@ -1365,6 +1365,7 @@ static void wacom_remote_destroy_one(struct wacom *wacom,
unsigned int index)
kfree((char *)remote->remotes[i].group.name);
remote->remotes[i].group.name = NULL;
remote->remotes[i].registered = false;
+ remote->remotes[i].battery.battery.dev = NULL;
wacom->led.select[i] = WACOM_STATUS_UNKNOWN;
}
}
@@ -1622,11 +1623,6 @@ static int wacom_remote_create_one(struct wacom *wacom,
u32 serial,
remote->remotes[index].registered = true;
- error = __wacom_initialize_battery(wacom,
- &remote->remotes[index].battery);
- if (error)
- goto fail;
-
devres_close_group(dev, &remote->remotes[index]);
return 0;
@@ -1640,6 +1636,24 @@ fail:
return error;
}
+static int wacom_remote_attach_battery(struct wacom *wacom, int index)
+{
+ struct wacom_remote *remote = wacom->remote;
+ int error;
+ if (!remote->remotes[index].registered)
+ return 0;
+
+ if (remote->remotes[index].battery.battery.dev)
+ return 0;
+
+ error = __wacom_initialize_battery(wacom,
+
&wacom->remote->remotes[index].battery);
+ if (error)
+ return error;
+
+ return 0;
+}
+
/*
* Not all devices report physical dimensions from HID.
* Compute the default from hardcoded logical dimension
@@ -1825,8 +1839,10 @@ static void wacom_remote_work(struct work_struct *work)
serial = data.remote[i].serial;
if (data.remote[i].connected) {
- if (remote->remotes[i].serial == serial)
+ if (remote->remotes[i].serial == serial) {
+ wacom_remote_attach_battery(wacom, i);
continue;
+ }
if (remote->remotes[i].serial)
wacom_remote_destroy_one(wacom, i);
--
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel