diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2016-07-13 12:06:09 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2016-08-05 07:39:19 -0400 |
commit | 9f1015d45f62d3b1c6719a1ccffaded89b157e10 (patch) | |
tree | 498743a6eef32935465f33c0e495bf1a08640b38 | |
parent | 59d69bc8215478af6b89d4ae9ab0baf6d91eb870 (diff) |
HID: wacom: EKR: attach the power_supply on first connection
Or Gnome complains about an empty battery.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/wacom_sys.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 04f5c753c868..1d79215a7968 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c | |||
@@ -1917,6 +1917,10 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index) | |||
1917 | remote->remotes[index].registered = false; | 1917 | remote->remotes[index].registered = false; |
1918 | spin_unlock_irqrestore(&remote->remote_lock, flags); | 1918 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
1919 | 1919 | ||
1920 | if (remote->remotes[index].battery.battery) | ||
1921 | devres_release_group(&wacom->hdev->dev, | ||
1922 | &remote->remotes[index].battery.bat_desc); | ||
1923 | |||
1920 | if (remote->remotes[index].group.name) | 1924 | if (remote->remotes[index].group.name) |
1921 | devres_release_group(&wacom->hdev->dev, | 1925 | devres_release_group(&wacom->hdev->dev, |
1922 | &remote->remotes[index]); | 1926 | &remote->remotes[index]); |
@@ -1926,6 +1930,7 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index) | |||
1926 | remote->remotes[i].serial = 0; | 1930 | remote->remotes[i].serial = 0; |
1927 | remote->remotes[i].group.name = NULL; | 1931 | remote->remotes[i].group.name = NULL; |
1928 | remote->remotes[i].registered = false; | 1932 | remote->remotes[i].registered = false; |
1933 | remote->remotes[i].battery.battery = NULL; | ||
1929 | wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; | 1934 | wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; |
1930 | } | 1935 | } |
1931 | } | 1936 | } |
@@ -1982,11 +1987,6 @@ static int wacom_remote_create_one(struct wacom *wacom, u32 serial, | |||
1982 | if (error) | 1987 | if (error) |
1983 | goto fail; | 1988 | goto fail; |
1984 | 1989 | ||
1985 | error = __wacom_initialize_battery(wacom, | ||
1986 | &remote->remotes[index].battery); | ||
1987 | if (error) | ||
1988 | goto fail; | ||
1989 | |||
1990 | remote->remotes[index].registered = true; | 1990 | remote->remotes[index].registered = true; |
1991 | 1991 | ||
1992 | devres_close_group(dev, &remote->remotes[index]); | 1992 | devres_close_group(dev, &remote->remotes[index]); |
@@ -1998,6 +1998,28 @@ fail: | |||
1998 | return error; | 1998 | return error; |
1999 | } | 1999 | } |
2000 | 2000 | ||
2001 | static int wacom_remote_attach_battery(struct wacom *wacom, int index) | ||
2002 | { | ||
2003 | struct wacom_remote *remote = wacom->remote; | ||
2004 | int error; | ||
2005 | |||
2006 | if (!remote->remotes[index].registered) | ||
2007 | return 0; | ||
2008 | |||
2009 | if (remote->remotes[index].battery.battery) | ||
2010 | return 0; | ||
2011 | |||
2012 | if (wacom->led.groups[index].select == WACOM_STATUS_UNKNOWN) | ||
2013 | return 0; | ||
2014 | |||
2015 | error = __wacom_initialize_battery(wacom, | ||
2016 | &wacom->remote->remotes[index].battery); | ||
2017 | if (error) | ||
2018 | return error; | ||
2019 | |||
2020 | return 0; | ||
2021 | } | ||
2022 | |||
2001 | static void wacom_remote_work(struct work_struct *work) | 2023 | static void wacom_remote_work(struct work_struct *work) |
2002 | { | 2024 | { |
2003 | struct wacom *wacom = container_of(work, struct wacom, remote_work); | 2025 | struct wacom *wacom = container_of(work, struct wacom, remote_work); |
@@ -2028,8 +2050,10 @@ static void wacom_remote_work(struct work_struct *work) | |||
2028 | serial = data.remote[i].serial; | 2050 | serial = data.remote[i].serial; |
2029 | if (data.remote[i].connected) { | 2051 | if (data.remote[i].connected) { |
2030 | 2052 | ||
2031 | if (remote->remotes[i].serial == serial) | 2053 | if (remote->remotes[i].serial == serial) { |
2054 | wacom_remote_attach_battery(wacom, i); | ||
2032 | continue; | 2055 | continue; |
2056 | } | ||
2033 | 2057 | ||
2034 | if (remote->remotes[i].serial) | 2058 | if (remote->remotes[i].serial) |
2035 | wacom_remote_destroy_one(wacom, i); | 2059 | wacom_remote_destroy_one(wacom, i); |