diff options
author | Kees Cook <keescook@chromium.org> | 2017-10-04 20:53:24 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2017-10-11 09:22:15 -0400 |
commit | 0ee32774aed648854a06bc3fae636f20f5f75a68 (patch) | |
tree | 50559a1b33950a9f183209d0f51534b70629a7ee | |
parent | 77ede3a014a32746002f7889211f0cecf4803163 (diff) |
HID: usbhid: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
(introduced by 686fef928bba ("timer: Prepare to change timer callback
argument type")) to pass the timer pointer explicitly. Adds pointer back to
hid_device for multitouch.
[jkosina@suse.cz: extend changelog a little bit as asked for by Benjamin]
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/hid-multitouch.c | 10 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 8 |
2 files changed, 10 insertions, 8 deletions
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 9e8c4d2ba11d..8ba95c3af056 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
@@ -112,6 +112,7 @@ struct mt_device { | |||
112 | struct mt_slot curdata; /* placeholder of incoming data */ | 112 | struct mt_slot curdata; /* placeholder of incoming data */ |
113 | struct mt_class mtclass; /* our mt device class */ | 113 | struct mt_class mtclass; /* our mt device class */ |
114 | struct timer_list release_timer; /* to release sticky fingers */ | 114 | struct timer_list release_timer; /* to release sticky fingers */ |
115 | struct hid_device *hdev; /* hid_device we're attached to */ | ||
115 | struct mt_fields *fields; /* temporary placeholder for storing the | 116 | struct mt_fields *fields; /* temporary placeholder for storing the |
116 | multitouch fields */ | 117 | multitouch fields */ |
117 | unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ | 118 | unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ |
@@ -1246,10 +1247,10 @@ static void mt_release_contacts(struct hid_device *hid) | |||
1246 | td->num_received = 0; | 1247 | td->num_received = 0; |
1247 | } | 1248 | } |
1248 | 1249 | ||
1249 | static void mt_expired_timeout(unsigned long arg) | 1250 | static void mt_expired_timeout(struct timer_list *t) |
1250 | { | 1251 | { |
1251 | struct hid_device *hdev = (void *)arg; | 1252 | struct mt_device *td = from_timer(td, t, release_timer); |
1252 | struct mt_device *td = hid_get_drvdata(hdev); | 1253 | struct hid_device *hdev = td->hdev; |
1253 | 1254 | ||
1254 | /* | 1255 | /* |
1255 | * An input report came in just before we release the sticky fingers, | 1256 | * An input report came in just before we release the sticky fingers, |
@@ -1280,6 +1281,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
1280 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); | 1281 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); |
1281 | return -ENOMEM; | 1282 | return -ENOMEM; |
1282 | } | 1283 | } |
1284 | td->hdev = hdev; | ||
1283 | td->mtclass = *mtclass; | 1285 | td->mtclass = *mtclass; |
1284 | td->inputmode = -1; | 1286 | td->inputmode = -1; |
1285 | td->maxcontact_report_id = -1; | 1287 | td->maxcontact_report_id = -1; |
@@ -1331,7 +1333,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
1331 | */ | 1333 | */ |
1332 | hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; | 1334 | hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; |
1333 | 1335 | ||
1334 | setup_timer(&td->release_timer, mt_expired_timeout, (long)hdev); | 1336 | timer_setup(&td->release_timer, mt_expired_timeout, 0); |
1335 | 1337 | ||
1336 | ret = hid_parse(hdev); | 1338 | ret = hid_parse(hdev); |
1337 | if (ret != 0) | 1339 | if (ret != 0) |
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 089bad8a9a21..9f9fe0e58f5b 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -101,10 +101,10 @@ static int hid_start_in(struct hid_device *hid) | |||
101 | } | 101 | } |
102 | 102 | ||
103 | /* I/O retry timer routine */ | 103 | /* I/O retry timer routine */ |
104 | static void hid_retry_timeout(unsigned long _hid) | 104 | static void hid_retry_timeout(struct timer_list *t) |
105 | { | 105 | { |
106 | struct hid_device *hid = (struct hid_device *) _hid; | 106 | struct usbhid_device *usbhid = from_timer(usbhid, t, io_retry); |
107 | struct usbhid_device *usbhid = hid->driver_data; | 107 | struct hid_device *hid = usbhid->hid; |
108 | 108 | ||
109 | dev_dbg(&usbhid->intf->dev, "retrying intr urb\n"); | 109 | dev_dbg(&usbhid->intf->dev, "retrying intr urb\n"); |
110 | if (hid_start_in(hid)) | 110 | if (hid_start_in(hid)) |
@@ -1363,7 +1363,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1363 | 1363 | ||
1364 | init_waitqueue_head(&usbhid->wait); | 1364 | init_waitqueue_head(&usbhid->wait); |
1365 | INIT_WORK(&usbhid->reset_work, hid_reset); | 1365 | INIT_WORK(&usbhid->reset_work, hid_reset); |
1366 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | 1366 | timer_setup(&usbhid->io_retry, hid_retry_timeout, 0); |
1367 | spin_lock_init(&usbhid->lock); | 1367 | spin_lock_init(&usbhid->lock); |
1368 | 1368 | ||
1369 | ret = hid_add_device(hid); | 1369 | ret = hid_add_device(hid); |