* [PATCH] drivers/hid: Convert timers to use timer_setup()
@ 2017-10-24 17:30 Allen Pais
[not found] ` <1508866222-15063-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Allen Pais @ 2017-10-24 17:30 UTC (permalink / raw)
To: benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA
Cc: dh.herrmann-gM/Ye1E23mwN+BqQ9rBEUg,
linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Allen Pais, Kees Cook
Switch to using the new timer_setup() and from_timer()
for drivers/hid/*
Cc: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Signed-off-by: Allen Pais <allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
Note: This patch is only compile tested.
drivers/hid/hid-appleir.c | 8 ++++----
drivers/hid/hid-multitouch.c | 6 +++---
drivers/hid/hid-prodikeys.c | 7 +++----
drivers/hid/hid-wiimote-core.c | 6 +++---
drivers/hid/usbhid/hid-core.c | 8 ++++----
5 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/drivers/hid/hid-appleir.c b/drivers/hid/hid-appleir.c
index 07cbc70..f5f4a93 100644
--- a/drivers/hid/hid-appleir.c
+++ b/drivers/hid/hid-appleir.c
@@ -173,9 +173,9 @@ static void battery_flat(struct appleir *appleir)
dev_err(&appleir->input_dev->dev, "possible flat battery?\n");
}
-static void key_up_tick(unsigned long data)
+static void key_up_tick(struct timer_list *t)
{
- struct appleir *appleir = (struct appleir *)data;
+ struct appleir *appleir = from_timer(applier, t, key_up_timer);
struct hid_device *hid = appleir->hid;
unsigned long flags;
@@ -303,8 +303,8 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id)
hid->quirks |= HID_QUIRK_HIDINPUT_FORCE;
spin_lock_init(&appleir->lock);
- setup_timer(&appleir->key_up_timer,
- key_up_tick, (unsigned long) appleir);
+ timer_setup(&appleir->key_up_timer,
+ key_up_tick, 0);
hid_set_drvdata(hid, appleir);
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 9e8c4d2..b5117a8 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1246,9 +1246,9 @@ static void mt_release_contacts(struct hid_device *hid)
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 hid_device *hdev = from_timer(hdev, t, release_timer);
struct mt_device *td = hid_get_drvdata(hdev);
/*
@@ -1331,7 +1331,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
*/
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);
if (ret != 0)
diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c
index 49c4bd3..87eda34 100644
--- a/drivers/hid/hid-prodikeys.c
+++ b/drivers/hid/hid-prodikeys.c
@@ -239,9 +239,9 @@ static void pcmidi_send_note(struct pcmidi_snd *pm,
return;
}
-static void pcmidi_sustained_note_release(unsigned long data)
+static void pcmidi_sustained_note_release(struct timer_list *t)
{
- struct pcmidi_sustain *pms = (struct pcmidi_sustain *)data;
+ struct pcmidi_sustain *pms = from_timer(pms, t, timer);
pcmidi_send_note(pms->pm, pms->status, pms->note, pms->velocity);
pms->in_use = 0;
@@ -256,8 +256,7 @@ static void init_sustain_timers(struct pcmidi_snd *pm)
pms = &pm->sustained_notes[i];
pms->in_use = 0;
pms->pm = pm;
- setup_timer(&pms->timer, pcmidi_sustained_note_release,
- (unsigned long)pms);
+ timer_setup(&pms->timer, pcmidi_sustained_note_release, 0);
}
}
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index d003914..579884e 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -1226,9 +1226,9 @@ static void wiimote_schedule(struct wiimote_data *wdata)
spin_unlock_irqrestore(&wdata->state.lock, flags);
}
-static void wiimote_init_timeout(unsigned long arg)
+static void wiimote_init_timeout(struct timer_list *t)
{
- struct wiimote_data *wdata = (void*)arg;
+ struct wiimote_data *wdata = from_timer(wdata, t, timer);
wiimote_schedule(wdata);
}
@@ -1740,7 +1740,7 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
wdata->state.cmd_battery = 0xff;
INIT_WORK(&wdata->init_worker, wiimote_init_worker);
- setup_timer(&wdata->timer, wiimote_init_timeout, (long)wdata);
+ timer_setup(&wdata->timer, wiimote_init_timeout, 0);
return wdata;
}
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 045b5da..640dfb93 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)
}
/* 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 = hid->driver_data;
+ struct usbhid_device *usbhid = from_timer(usbhid, t, io_retry);
+ struct hid_device *hid = usbhid->hid;
dev_dbg(&usbhid->intf->dev, "retrying intr urb\n");
if (hid_start_in(hid))
@@ -1373,7 +1373,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
init_waitqueue_head(&usbhid->wait);
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);
ret = hid_add_device(hid);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 7+ messages in thread[parent not found: <1508866222-15063-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] drivers/hid: Convert timers to use timer_setup() [not found] ` <1508866222-15063-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> @ 2017-10-24 17:34 ` Allen 2017-10-25 15:33 ` kbuild test robot 2017-10-25 15:38 ` kbuild test robot 2 siblings, 0 replies; 7+ messages in thread From: Allen @ 2017-10-24 17:34 UTC (permalink / raw) To: benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA Cc: dh.herrmann-gM/Ye1E23mwN+BqQ9rBEUg, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, Kees Cook > Switch to using the new timer_setup() and from_timer() > for drivers/hid/* > > Cc: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > Signed-off-by: Allen Pais <allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> Ignore the patch. I send out a wrong one by mistake. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/hid: Convert timers to use timer_setup() [not found] ` <1508866222-15063-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 2017-10-24 17:34 ` Allen @ 2017-10-25 15:33 ` kbuild test robot 2017-10-25 15:38 ` kbuild test robot 2 siblings, 0 replies; 7+ messages in thread From: kbuild test robot @ 2017-10-25 15:33 UTC (permalink / raw) Cc: kbuild-all-JC7UmRfGjtg, benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA, dh.herrmann-gM/Ye1E23mwN+BqQ9rBEUg, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, Allen Pais, Kees Cook [-- Attachment #1: Type: text/plain, Size: 8371 bytes --] Hi Allen, [auto build test ERROR on v4.14-rc6] [cannot apply to hid/for-next next-20171018] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Allen-Pais/drivers-hid-Convert-timers-to-use-timer_setup/20171025-230118 config: i386-randconfig-x008-201743 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=i386 All error/warnings (new ones prefixed by >>): In file included from include/linux/ioport.h:12:0, from include/linux/device.h:16, from drivers//hid/hid-multitouch.c:41: drivers//hid/hid-multitouch.c: In function 'mt_expired_timeout': >> include/linux/kernel.h:928:51: error: 'struct hid_device' has no member named 'release_timer' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^ include/linux/compiler.h:553:19: note: in definition of macro '__compiletime_assert' bool __cond = !(condition); \ ^~~~~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/kernel.h:928:2: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~~~~~~ include/linux/kernel.h:928:20: note: in expansion of macro '__same_type' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~ include/linux/timer.h:183:2: note: in expansion of macro 'container_of' container_of(callback_timer, typeof(*var), timer_fieldname) ^~~~~~~~~~~~ >> drivers//hid/hid-multitouch.c:1251:28: note: in expansion of macro 'from_timer' struct hid_device *hdev = from_timer(hdev, t, release_timer); ^~~~~~~~~~ In file included from include/linux/compiler.h:58:0, from include/linux/ioport.h:12, from include/linux/device.h:16, from drivers//hid/hid-multitouch.c:41: >> include/linux/compiler-gcc.h:165:2: error: 'struct hid_device' has no member named 'release_timer' __builtin_offsetof(a, b) ^ include/linux/stddef.h:16:32: note: in expansion of macro '__compiler_offsetof' #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER) ^~~~~~~~~~~~~~~~~~~ include/linux/kernel.h:931:21: note: in expansion of macro 'offsetof' ((type *)(__mptr - offsetof(type, member))); }) ^~~~~~~~ include/linux/timer.h:183:2: note: in expansion of macro 'container_of' container_of(callback_timer, typeof(*var), timer_fieldname) ^~~~~~~~~~~~ >> drivers//hid/hid-multitouch.c:1251:28: note: in expansion of macro 'from_timer' struct hid_device *hdev = from_timer(hdev, t, release_timer); ^~~~~~~~~~ -- In file included from include/linux/ioport.h:12:0, from include/linux/device.h:16, from drivers/hid/hid-multitouch.c:41: drivers/hid/hid-multitouch.c: In function 'mt_expired_timeout': >> include/linux/kernel.h:928:51: error: 'struct hid_device' has no member named 'release_timer' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^ include/linux/compiler.h:553:19: note: in definition of macro '__compiletime_assert' bool __cond = !(condition); \ ^~~~~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/kernel.h:928:2: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~~~~~~ include/linux/kernel.h:928:20: note: in expansion of macro '__same_type' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~ include/linux/timer.h:183:2: note: in expansion of macro 'container_of' container_of(callback_timer, typeof(*var), timer_fieldname) ^~~~~~~~~~~~ drivers/hid/hid-multitouch.c:1251:28: note: in expansion of macro 'from_timer' struct hid_device *hdev = from_timer(hdev, t, release_timer); ^~~~~~~~~~ In file included from include/linux/compiler.h:58:0, from include/linux/ioport.h:12, from include/linux/device.h:16, from drivers/hid/hid-multitouch.c:41: >> include/linux/compiler-gcc.h:165:2: error: 'struct hid_device' has no member named 'release_timer' __builtin_offsetof(a, b) ^ include/linux/stddef.h:16:32: note: in expansion of macro '__compiler_offsetof' #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER) ^~~~~~~~~~~~~~~~~~~ include/linux/kernel.h:931:21: note: in expansion of macro 'offsetof' ((type *)(__mptr - offsetof(type, member))); }) ^~~~~~~~ include/linux/timer.h:183:2: note: in expansion of macro 'container_of' container_of(callback_timer, typeof(*var), timer_fieldname) ^~~~~~~~~~~~ drivers/hid/hid-multitouch.c:1251:28: note: in expansion of macro 'from_timer' struct hid_device *hdev = from_timer(hdev, t, release_timer); ^~~~~~~~~~ vim +928 include/linux/kernel.h ^1da177e4 Linus Torvalds 2005-04-16 909 91f68b735 Wu Fengguang 2009-01-07 910 e8c97af0c Randy Dunlap 2017-10-13 911 /** e8c97af0c Randy Dunlap 2017-10-13 912 * swap - swap values of @a and @b e8c97af0c Randy Dunlap 2017-10-13 913 * @a: first value e8c97af0c Randy Dunlap 2017-10-13 914 * @b: second value 91f68b735 Wu Fengguang 2009-01-07 915 */ ac7b90049 Peter Zijlstra 2009-02-04 916 #define swap(a, b) \ ac7b90049 Peter Zijlstra 2009-02-04 917 do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) 91f68b735 Wu Fengguang 2009-01-07 918 ^1da177e4 Linus Torvalds 2005-04-16 919 /** ^1da177e4 Linus Torvalds 2005-04-16 920 * container_of - cast a member of a structure out to the containing structure ^1da177e4 Linus Torvalds 2005-04-16 921 * @ptr: the pointer to the member. ^1da177e4 Linus Torvalds 2005-04-16 922 * @type: the type of the container struct this is embedded in. ^1da177e4 Linus Torvalds 2005-04-16 923 * @member: the name of the member within the struct. ^1da177e4 Linus Torvalds 2005-04-16 924 * ^1da177e4 Linus Torvalds 2005-04-16 925 */ ^1da177e4 Linus Torvalds 2005-04-16 926 #define container_of(ptr, type, member) ({ \ c7acec713 Ian Abbott 2017-07-12 927 void *__mptr = (void *)(ptr); \ c7acec713 Ian Abbott 2017-07-12 @928 BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ c7acec713 Ian Abbott 2017-07-12 929 !__same_type(*(ptr), void), \ c7acec713 Ian Abbott 2017-07-12 930 "pointer type mismatch in container_of()"); \ c7acec713 Ian Abbott 2017-07-12 931 ((type *)(__mptr - offsetof(type, member))); }) ^1da177e4 Linus Torvalds 2005-04-16 932 :::::: The code at line 928 was first introduced by commit :::::: c7acec713d14c6ce8a20154f9dfda258d6bcad3b kernel.h: handle pointers to arrays better in container_of() :::::: TO: Ian Abbott <abbotti-GUHe90Wt2aFaa/9Udqfwiw@public.gmane.org> :::::: CC: Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 31471 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/hid: Convert timers to use timer_setup() [not found] ` <1508866222-15063-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 2017-10-24 17:34 ` Allen 2017-10-25 15:33 ` kbuild test robot @ 2017-10-25 15:38 ` kbuild test robot 2 siblings, 0 replies; 7+ messages in thread From: kbuild test robot @ 2017-10-25 15:38 UTC (permalink / raw) Cc: kbuild-all-JC7UmRfGjtg, benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA, dh.herrmann-gM/Ye1E23mwN+BqQ9rBEUg, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, Allen Pais, Kees Cook [-- Attachment #1: Type: text/plain, Size: 9359 bytes --] Hi Allen, [auto build test ERROR on v4.14-rc6] [cannot apply to hid/for-next next-20171018] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Allen-Pais/drivers-hid-Convert-timers-to-use-timer_setup/20171025-230118 config: x86_64-randconfig-x011-201743 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All error/warnings (new ones prefixed by >>): In file included from include/linux/ioport.h:12:0, from include/linux/device.h:16, from drivers/hid/hid-appleir.c:26: drivers/hid/hid-appleir.c: In function 'key_up_tick': >> drivers/hid/hid-appleir.c:178:39: error: 'applier' undeclared (first use in this function) struct appleir *appleir = from_timer(applier, t, key_up_timer); ^ include/linux/compiler.h:553:19: note: in definition of macro '__compiletime_assert' bool __cond = !(condition); \ ^~~~~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/kernel.h:928:2: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~~~~~~ include/linux/kernel.h:928:20: note: in expansion of macro '__same_type' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~ include/linux/timer.h:183:2: note: in expansion of macro 'container_of' container_of(callback_timer, typeof(*var), timer_fieldname) ^~~~~~~~~~~~ >> drivers/hid/hid-appleir.c:178:28: note: in expansion of macro 'from_timer' struct appleir *appleir = from_timer(applier, t, key_up_timer); ^~~~~~~~~~ drivers/hid/hid-appleir.c:178:39: note: each undeclared identifier is reported only once for each function it appears in struct appleir *appleir = from_timer(applier, t, key_up_timer); ^ include/linux/compiler.h:553:19: note: in definition of macro '__compiletime_assert' bool __cond = !(condition); \ ^~~~~~~~~ include/linux/compiler.h:576:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:46:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/kernel.h:928:2: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~~~~~~ include/linux/kernel.h:928:20: note: in expansion of macro '__same_type' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^~~~~~~~~~~ include/linux/timer.h:183:2: note: in expansion of macro 'container_of' container_of(callback_timer, typeof(*var), timer_fieldname) ^~~~~~~~~~~~ >> drivers/hid/hid-appleir.c:178:28: note: in expansion of macro 'from_timer' struct appleir *appleir = from_timer(applier, t, key_up_timer); ^~~~~~~~~~ vim +/applier +178 drivers/hid/hid-appleir.c > 26 #include <linux/device.h> 27 #include <linux/hid.h> 28 #include <linux/module.h> 29 #include "hid-ids.h" 30 31 MODULE_AUTHOR("James McKenzie"); 32 MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>"); 33 MODULE_DESCRIPTION("HID Apple IR remote controls"); 34 MODULE_LICENSE("GPL"); 35 36 #define KEY_MASK 0x0F 37 #define TWO_PACKETS_MASK 0x40 38 39 /* 40 * James McKenzie has two devices both of which report the following 41 * 25 87 ee 83 0a + 42 * 25 87 ee 83 0c - 43 * 25 87 ee 83 09 << 44 * 25 87 ee 83 06 >> 45 * 25 87 ee 83 05 >" 46 * 25 87 ee 83 03 menu 47 * 26 00 00 00 00 for key repeat 48 */ 49 50 /* 51 * Thomas Glanzmann reports the following responses 52 * 25 87 ee ca 0b + 53 * 25 87 ee ca 0d - 54 * 25 87 ee ca 08 << 55 * 25 87 ee ca 07 >> 56 * 25 87 ee ca 04 >" 57 * 25 87 ee ca 02 menu 58 * 26 00 00 00 00 for key repeat 59 * 60 * He also observes the following event sometimes 61 * sent after a key is release, which I interpret 62 * as a flat battery message 63 * 25 87 e0 ca 06 flat battery 64 */ 65 66 /* 67 * Alexandre Karpenko reports the following responses for Device ID 0x8242 68 * 25 87 ee 47 0b + 69 * 25 87 ee 47 0d - 70 * 25 87 ee 47 08 << 71 * 25 87 ee 47 07 >> 72 * 25 87 ee 47 04 >" 73 * 25 87 ee 47 02 menu 74 * 26 87 ee 47 ** for key repeat (** is the code of the key being held) 75 */ 76 77 /* 78 * Bastien Nocera's remote 79 * 25 87 ee 91 5f followed by 80 * 25 87 ee 91 05 gives you >" 81 * 82 * 25 87 ee 91 5c followed by 83 * 25 87 ee 91 05 gives you the middle button 84 */ 85 86 /* 87 * Fabien Andre's remote 88 * 25 87 ee a3 5e followed by 89 * 25 87 ee a3 04 gives you >" 90 * 91 * 25 87 ee a3 5d followed by 92 * 25 87 ee a3 04 gives you the middle button 93 */ 94 95 static const unsigned short appleir_key_table[] = { 96 KEY_RESERVED, 97 KEY_MENU, 98 KEY_PLAYPAUSE, 99 KEY_FORWARD, 100 KEY_BACK, 101 KEY_VOLUMEUP, 102 KEY_VOLUMEDOWN, 103 KEY_RESERVED, 104 KEY_RESERVED, 105 KEY_RESERVED, 106 KEY_RESERVED, 107 KEY_RESERVED, 108 KEY_RESERVED, 109 KEY_RESERVED, 110 KEY_ENTER, 111 KEY_PLAYPAUSE, 112 KEY_RESERVED, 113 }; 114 115 struct appleir { 116 struct input_dev *input_dev; 117 struct hid_device *hid; 118 unsigned short keymap[ARRAY_SIZE(appleir_key_table)]; 119 struct timer_list key_up_timer; /* timer for key up */ 120 spinlock_t lock; /* protects .current_key */ 121 int current_key; /* the currently pressed key */ 122 int prev_key_idx; /* key index in a 2 packets message */ 123 }; 124 125 static int get_key(int data) 126 { 127 /* 128 * The key is coded accross bits 2..9: 129 * 130 * 0x00 or 0x01 ( ) key: 0 -> KEY_RESERVED 131 * 0x02 or 0x03 ( menu ) key: 1 -> KEY_MENU 132 * 0x04 or 0x05 ( >" ) key: 2 -> KEY_PLAYPAUSE 133 * 0x06 or 0x07 ( >> ) key: 3 -> KEY_FORWARD 134 * 0x08 or 0x09 ( << ) key: 4 -> KEY_BACK 135 * 0x0a or 0x0b ( + ) key: 5 -> KEY_VOLUMEUP 136 * 0x0c or 0x0d ( - ) key: 6 -> KEY_VOLUMEDOWN 137 * 0x0e or 0x0f ( ) key: 7 -> KEY_RESERVED 138 * 0x50 or 0x51 ( ) key: 8 -> KEY_RESERVED 139 * 0x52 or 0x53 ( ) key: 9 -> KEY_RESERVED 140 * 0x54 or 0x55 ( ) key: 10 -> KEY_RESERVED 141 * 0x56 or 0x57 ( ) key: 11 -> KEY_RESERVED 142 * 0x58 or 0x59 ( ) key: 12 -> KEY_RESERVED 143 * 0x5a or 0x5b ( ) key: 13 -> KEY_RESERVED 144 * 0x5c or 0x5d ( middle ) key: 14 -> KEY_ENTER 145 * 0x5e or 0x5f ( >" ) key: 15 -> KEY_PLAYPAUSE 146 * 147 * Packets starting with 0x5 are part of a two-packets message, 148 * we notify the caller by sending a negative value. 149 */ 150 int key = (data >> 1) & KEY_MASK; 151 152 if ((data & TWO_PACKETS_MASK)) 153 /* Part of a 2 packets-command */ 154 key = -key; 155 156 return key; 157 } 158 159 static void key_up(struct hid_device *hid, struct appleir *appleir, int key) 160 { 161 input_report_key(appleir->input_dev, key, 0); 162 input_sync(appleir->input_dev); 163 } 164 165 static void key_down(struct hid_device *hid, struct appleir *appleir, int key) 166 { 167 input_report_key(appleir->input_dev, key, 1); 168 input_sync(appleir->input_dev); 169 } 170 171 static void battery_flat(struct appleir *appleir) 172 { 173 dev_err(&appleir->input_dev->dev, "possible flat battery?\n"); 174 } 175 176 static void key_up_tick(struct timer_list *t) 177 { > 178 struct appleir *appleir = from_timer(applier, t, key_up_timer); 179 struct hid_device *hid = appleir->hid; 180 unsigned long flags; 181 182 spin_lock_irqsave(&appleir->lock, flags); 183 if (appleir->current_key) { 184 key_up(hid, appleir, appleir->current_key); 185 appleir->current_key = 0; 186 } 187 spin_unlock_irqrestore(&appleir->lock, flags); 188 } 189 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 30524 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] drivers/hid: Convert timers to use timer_setup()
@ 2017-10-24 17:55 Allen Pais
[not found] ` <1508867719-16157-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-10-25 7:33 ` Benjamin Tissoires
0 siblings, 2 replies; 7+ messages in thread
From: Allen Pais @ 2017-10-24 17:55 UTC (permalink / raw)
To: benjamin.tissoires
Cc: dh.herrmann, linux-input, linux-usb, Allen Pais, Kees Cook
Switch to using the new timer_setup() and from_timer()
for drivers/hid/*
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
---
Note:This patch is only compile tested.
drivers/hid/hid-appleir.c | 8 ++++----
drivers/hid/hid-prodikeys.c | 7 +++----
drivers/hid/hid-wiimote-core.c | 6 +++---
drivers/hid/usbhid/hid-core.c | 8 ++++----
4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/hid/hid-appleir.c b/drivers/hid/hid-appleir.c
index 07cbc70..1c913a7 100644
--- a/drivers/hid/hid-appleir.c
+++ b/drivers/hid/hid-appleir.c
@@ -173,9 +173,9 @@ static void battery_flat(struct appleir *appleir)
dev_err(&appleir->input_dev->dev, "possible flat battery?\n");
}
-static void key_up_tick(unsigned long data)
+static void key_up_tick(struct timer_list *t)
{
- struct appleir *appleir = (struct appleir *)data;
+ struct appleir *appleir = from_timer(appleir, t, key_up_timer);
struct hid_device *hid = appleir->hid;
unsigned long flags;
@@ -303,8 +303,8 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id)
hid->quirks |= HID_QUIRK_HIDINPUT_FORCE;
spin_lock_init(&appleir->lock);
- setup_timer(&appleir->key_up_timer,
- key_up_tick, (unsigned long) appleir);
+ timer_setup(&appleir->key_up_timer,
+ key_up_tick, 0);
hid_set_drvdata(hid, appleir);
diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c
index 49c4bd3..87eda34 100644
--- a/drivers/hid/hid-prodikeys.c
+++ b/drivers/hid/hid-prodikeys.c
@@ -239,9 +239,9 @@ static void pcmidi_send_note(struct pcmidi_snd *pm,
return;
}
-static void pcmidi_sustained_note_release(unsigned long data)
+static void pcmidi_sustained_note_release(struct timer_list *t)
{
- struct pcmidi_sustain *pms = (struct pcmidi_sustain *)data;
+ struct pcmidi_sustain *pms = from_timer(pms, t, timer);
pcmidi_send_note(pms->pm, pms->status, pms->note, pms->velocity);
pms->in_use = 0;
@@ -256,8 +256,7 @@ static void init_sustain_timers(struct pcmidi_snd *pm)
pms = &pm->sustained_notes[i];
pms->in_use = 0;
pms->pm = pm;
- setup_timer(&pms->timer, pcmidi_sustained_note_release,
- (unsigned long)pms);
+ timer_setup(&pms->timer, pcmidi_sustained_note_release, 0);
}
}
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index d003914..579884e 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -1226,9 +1226,9 @@ static void wiimote_schedule(struct wiimote_data *wdata)
spin_unlock_irqrestore(&wdata->state.lock, flags);
}
-static void wiimote_init_timeout(unsigned long arg)
+static void wiimote_init_timeout(struct timer_list *t)
{
- struct wiimote_data *wdata = (void*)arg;
+ struct wiimote_data *wdata = from_timer(wdata, t, timer);
wiimote_schedule(wdata);
}
@@ -1740,7 +1740,7 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
wdata->state.cmd_battery = 0xff;
INIT_WORK(&wdata->init_worker, wiimote_init_worker);
- setup_timer(&wdata->timer, wiimote_init_timeout, (long)wdata);
+ timer_setup(&wdata->timer, wiimote_init_timeout, 0);
return wdata;
}
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 045b5da..640dfb93 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)
}
/* 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 = hid->driver_data;
+ struct usbhid_device *usbhid = from_timer(usbhid, t, io_retry);
+ struct hid_device *hid = usbhid->hid;
dev_dbg(&usbhid->intf->dev, "retrying intr urb\n");
if (hid_start_in(hid))
@@ -1373,7 +1373,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
init_waitqueue_head(&usbhid->wait);
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);
ret = hid_add_device(hid);
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread[parent not found: <1508867719-16157-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] drivers/hid: Convert timers to use timer_setup() [not found] ` <1508867719-16157-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> @ 2017-10-24 18:06 ` Kees Cook 0 siblings, 0 replies; 7+ messages in thread From: Kees Cook @ 2017-10-24 18:06 UTC (permalink / raw) To: Allen Pais Cc: Benjamin Tissoires, dh.herrmann-gM/Ye1E23mwN+BqQ9rBEUg, linux-input, linux-usb-u79uwXL29TY76Z2rM5mHXA On Tue, Oct 24, 2017 at 10:55 AM, Allen Pais <allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> wrote: > Switch to using the new timer_setup() and from_timer() > for drivers/hid/* > > Cc: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > Signed-off-by: Allen Pais <allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> Yup, this matches what I'd expect for timer_setup() conversion in these files, thanks! -Kees -- Kees Cook Pixel Security -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/hid: Convert timers to use timer_setup() 2017-10-24 17:55 Allen Pais [not found] ` <1508867719-16157-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> @ 2017-10-25 7:33 ` Benjamin Tissoires 1 sibling, 0 replies; 7+ messages in thread From: Benjamin Tissoires @ 2017-10-25 7:33 UTC (permalink / raw) To: Allen Pais; +Cc: dh.herrmann, linux-input, linux-usb, Kees Cook On Oct 24 2017 or thereabouts, Allen Pais wrote: > Switch to using the new timer_setup() and from_timer() > for drivers/hid/* > > Cc: Kees Cook <keescook@chromium.org> > Signed-off-by: Allen Pais <allen.pais@oracle.com> > --- > > Note:This patch is only compile tested. Looks good enough for me: Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Cheers, Benjamin > > drivers/hid/hid-appleir.c | 8 ++++---- > drivers/hid/hid-prodikeys.c | 7 +++---- > drivers/hid/hid-wiimote-core.c | 6 +++--- > drivers/hid/usbhid/hid-core.c | 8 ++++---- > 4 files changed, 14 insertions(+), 15 deletions(-) > > diff --git a/drivers/hid/hid-appleir.c b/drivers/hid/hid-appleir.c > index 07cbc70..1c913a7 100644 > --- a/drivers/hid/hid-appleir.c > +++ b/drivers/hid/hid-appleir.c > @@ -173,9 +173,9 @@ static void battery_flat(struct appleir *appleir) > dev_err(&appleir->input_dev->dev, "possible flat battery?\n"); > } > > -static void key_up_tick(unsigned long data) > +static void key_up_tick(struct timer_list *t) > { > - struct appleir *appleir = (struct appleir *)data; > + struct appleir *appleir = from_timer(appleir, t, key_up_timer); > struct hid_device *hid = appleir->hid; > unsigned long flags; > > @@ -303,8 +303,8 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id) > hid->quirks |= HID_QUIRK_HIDINPUT_FORCE; > > spin_lock_init(&appleir->lock); > - setup_timer(&appleir->key_up_timer, > - key_up_tick, (unsigned long) appleir); > + timer_setup(&appleir->key_up_timer, > + key_up_tick, 0); > > hid_set_drvdata(hid, appleir); > > diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c > index 49c4bd3..87eda34 100644 > --- a/drivers/hid/hid-prodikeys.c > +++ b/drivers/hid/hid-prodikeys.c > @@ -239,9 +239,9 @@ static void pcmidi_send_note(struct pcmidi_snd *pm, > return; > } > > -static void pcmidi_sustained_note_release(unsigned long data) > +static void pcmidi_sustained_note_release(struct timer_list *t) > { > - struct pcmidi_sustain *pms = (struct pcmidi_sustain *)data; > + struct pcmidi_sustain *pms = from_timer(pms, t, timer); > > pcmidi_send_note(pms->pm, pms->status, pms->note, pms->velocity); > pms->in_use = 0; > @@ -256,8 +256,7 @@ static void init_sustain_timers(struct pcmidi_snd *pm) > pms = &pm->sustained_notes[i]; > pms->in_use = 0; > pms->pm = pm; > - setup_timer(&pms->timer, pcmidi_sustained_note_release, > - (unsigned long)pms); > + timer_setup(&pms->timer, pcmidi_sustained_note_release, 0); > } > } > > diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c > index d003914..579884e 100644 > --- a/drivers/hid/hid-wiimote-core.c > +++ b/drivers/hid/hid-wiimote-core.c > @@ -1226,9 +1226,9 @@ static void wiimote_schedule(struct wiimote_data *wdata) > spin_unlock_irqrestore(&wdata->state.lock, flags); > } > > -static void wiimote_init_timeout(unsigned long arg) > +static void wiimote_init_timeout(struct timer_list *t) > { > - struct wiimote_data *wdata = (void*)arg; > + struct wiimote_data *wdata = from_timer(wdata, t, timer); > > wiimote_schedule(wdata); > } > @@ -1740,7 +1740,7 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev) > wdata->state.cmd_battery = 0xff; > > INIT_WORK(&wdata->init_worker, wiimote_init_worker); > - setup_timer(&wdata->timer, wiimote_init_timeout, (long)wdata); > + timer_setup(&wdata->timer, wiimote_init_timeout, 0); > > return wdata; > } > diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c > index 045b5da..640dfb93 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) > } > > /* 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 = hid->driver_data; > + struct usbhid_device *usbhid = from_timer(usbhid, t, io_retry); > + struct hid_device *hid = usbhid->hid; > > dev_dbg(&usbhid->intf->dev, "retrying intr urb\n"); > if (hid_start_in(hid)) > @@ -1373,7 +1373,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * > > init_waitqueue_head(&usbhid->wait); > 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); > > ret = hid_add_device(hid); > -- > 1.9.1 > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-10-25 15:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-24 17:30 [PATCH] drivers/hid: Convert timers to use timer_setup() Allen Pais
[not found] ` <1508866222-15063-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-10-24 17:34 ` Allen
2017-10-25 15:33 ` kbuild test robot
2017-10-25 15:38 ` kbuild test robot
-- strict thread matches above, loose matches on Subject: below --
2017-10-24 17:55 Allen Pais
[not found] ` <1508867719-16157-1-git-send-email-allen.pais-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-10-24 18:06 ` Kees Cook
2017-10-25 7:33 ` Benjamin Tissoires
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.