summaryrefslogtreecommitdiff
path: root/drivers/hid/wacom_sys.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2016-07-13 19:06:07 +0300
committerJiri Kosina <jkosina@suse.cz>2016-08-05 14:39:18 +0300
commit7c35dc3cd4d114019ed4b26cab313e253396d7c9 (patch)
tree17d24cce6ecbdc28d39510b5643a565875ec6846 /drivers/hid/wacom_sys.c
parente7749f6e5f9d33da189f7bc7d757349ad4716f00 (diff)
downloadlinux-7c35dc3cd4d114019ed4b26cab313e253396d7c9.tar.xz
HID: wacom: EKR: allocate one input node per remote
Thanks to devres, we can now afford to create more than one input node without having to overload the remove/failure paths. Having one input node per remote is something which should have been implemented from start but the probability of having users with several remotes is quite low. Anyway, still, better looking at the future and implement things properly. Remote input nodes will be freed/unregistered magically as they are created in the devres group &remote->remotes[index]. We need to open the hid node now that the remotes are dynamically allocated. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.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.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index c3b269237af5..f2f5b4b248cb 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1905,6 +1905,11 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
struct wacom_remote *remote = wacom->remote;
u32 serial = remote->remotes[index].serial;
int i;
+ unsigned long flags;
+
+ spin_lock_irqsave(&remote->remote_lock, flags);
+ remote->remotes[index].registered = false;
+ spin_unlock_irqrestore(&remote->remote_lock, flags);
if (remote->remotes[index].group.name)
devres_release_group(&wacom->hdev->dev,
@@ -1914,6 +1919,7 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
if (remote->remotes[i].serial == serial) {
remote->remotes[i].serial = 0;
remote->remotes[i].group.name = NULL;
+ remote->remotes[i].registered = false;
wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
}
}
@@ -1946,8 +1952,32 @@ static int wacom_remote_create_one(struct wacom *wacom, u32 serial,
if (error)
goto fail;
+ remote->remotes[index].input = wacom_allocate_input(wacom);
+ if (!remote->remotes[index].input) {
+ error = -ENOMEM;
+ goto fail;
+ }
+ remote->remotes[index].input->uniq = remote->remotes[index].group.name;
+ remote->remotes[index].input->name = wacom->wacom_wac.pad_name;
+
+ if (!remote->remotes[index].input->name) {
+ error = -EINVAL;
+ goto fail;
+ }
+
+ error = wacom_setup_pad_input_capabilities(remote->remotes[index].input,
+ &wacom->wacom_wac);
+ if (error)
+ goto fail;
+
remote->remotes[index].serial = serial;
+ error = input_register_device(remote->remotes[index].input);
+ if (error)
+ goto fail;
+
+ remote->remotes[index].registered = true;
+
devres_close_group(dev, &remote->remotes[index]);
return 0;