Commit 0ee32774 authored by Kees Cook's avatar Kees Cook Committed by Jiri Kosina

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 686fef92 ("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: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 77ede3a0
...@@ -112,6 +112,7 @@ struct mt_device { ...@@ -112,6 +112,7 @@ struct mt_device {
struct mt_slot curdata; /* placeholder of incoming data */ struct mt_slot curdata; /* placeholder of incoming data */
struct mt_class mtclass; /* our mt device class */ struct mt_class mtclass; /* our mt device class */
struct timer_list release_timer; /* to release sticky fingers */ struct timer_list release_timer; /* to release sticky fingers */
struct hid_device *hdev; /* hid_device we're attached to */
struct mt_fields *fields; /* temporary placeholder for storing the struct mt_fields *fields; /* temporary placeholder for storing the
multitouch fields */ multitouch fields */
unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */
...@@ -1246,10 +1247,10 @@ static void mt_release_contacts(struct hid_device *hid) ...@@ -1246,10 +1247,10 @@ static void mt_release_contacts(struct hid_device *hid)
td->num_received = 0; td->num_received = 0;
} }
static void mt_expired_timeout(unsigned long arg) static void mt_expired_timeout(struct timer_list *t)
{ {
struct hid_device *hdev = (void *)arg; struct mt_device *td = from_timer(td, t, release_timer);
struct mt_device *td = hid_get_drvdata(hdev); struct hid_device *hdev = td->hdev;
/* /*
* An input report came in just before we release the sticky fingers, * 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,6 +1281,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
dev_err(&hdev->dev, "cannot allocate multitouch data\n"); dev_err(&hdev->dev, "cannot allocate multitouch data\n");
return -ENOMEM; return -ENOMEM;
} }
td->hdev = hdev;
td->mtclass = *mtclass; td->mtclass = *mtclass;
td->inputmode = -1; td->inputmode = -1;
td->maxcontact_report_id = -1; td->maxcontact_report_id = -1;
...@@ -1331,7 +1333,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -1331,7 +1333,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
*/ */
hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS;
setup_timer(&td->release_timer, mt_expired_timeout, (long)hdev); timer_setup(&td->release_timer, mt_expired_timeout, 0);
ret = hid_parse(hdev); ret = hid_parse(hdev);
if (ret != 0) if (ret != 0)
......
...@@ -101,10 +101,10 @@ static int hid_start_in(struct hid_device *hid) ...@@ -101,10 +101,10 @@ static int hid_start_in(struct hid_device *hid)
} }
/* I/O retry timer routine */ /* I/O retry timer routine */
static void hid_retry_timeout(unsigned long _hid) static void hid_retry_timeout(struct timer_list *t)
{ {
struct hid_device *hid = (struct hid_device *) _hid; struct usbhid_device *usbhid = from_timer(usbhid, t, io_retry);
struct usbhid_device *usbhid = hid->driver_data; struct hid_device *hid = usbhid->hid;
dev_dbg(&usbhid->intf->dev, "retrying intr urb\n"); dev_dbg(&usbhid->intf->dev, "retrying intr urb\n");
if (hid_start_in(hid)) if (hid_start_in(hid))
...@@ -1363,7 +1363,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * ...@@ -1363,7 +1363,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
init_waitqueue_head(&usbhid->wait); init_waitqueue_head(&usbhid->wait);
INIT_WORK(&usbhid->reset_work, hid_reset); INIT_WORK(&usbhid->reset_work, hid_reset);
setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); timer_setup(&usbhid->io_retry, hid_retry_timeout, 0);
spin_lock_init(&usbhid->lock); spin_lock_init(&usbhid->lock);
ret = hid_add_device(hid); ret = hid_add_device(hid);
......
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