Commit 16a334c0de5a94b1d10a1ac9a33f4dedac89a075

Authored by Dmitry Torokhov
1 parent c27a748225

Input: introduce usb_to_input_id() to uniformly produce

struct input_id for USB input devices.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Showing 15 changed files with 54 additions and 58 deletions Side-by-side Diff

drivers/usb/input/acecad.c
... ... @@ -31,6 +31,7 @@
31 31 #include <linux/module.h>
32 32 #include <linux/init.h>
33 33 #include <linux/usb.h>
  34 +#include <linux/usb_input.h>
34 35  
35 36 /*
36 37 * Version Information
... ... @@ -212,10 +213,7 @@
212 213  
213 214 acecad->dev.name = acecad->name;
214 215 acecad->dev.phys = acecad->phys;
215   - acecad->dev.id.bustype = BUS_USB;
216   - acecad->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
217   - acecad->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
218   - acecad->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
  216 + usb_to_input_id(dev, &acecad->dev.id);
219 217 acecad->dev.dev = &intf->dev;
220 218  
221 219 usb_fill_int_urb(acecad->irq, dev, pipe,
drivers/usb/input/aiptek.c
... ... @@ -77,6 +77,7 @@
77 77 #include <linux/module.h>
78 78 #include <linux/init.h>
79 79 #include <linux/usb.h>
  80 +#include <linux/usb_input.h>
80 81 #include <linux/sched.h>
81 82 #include <asm/uaccess.h>
82 83 #include <asm/unaligned.h>
... ... @@ -2125,10 +2126,7 @@
2125 2126 aiptek->inputdev.absflat[ABS_WHEEL] = 0;
2126 2127 aiptek->inputdev.name = "Aiptek";
2127 2128 aiptek->inputdev.phys = aiptek->features.usbPath;
2128   - aiptek->inputdev.id.bustype = BUS_USB;
2129   - aiptek->inputdev.id.vendor = le16_to_cpu(usbdev->descriptor.idVendor);
2130   - aiptek->inputdev.id.product = le16_to_cpu(usbdev->descriptor.idProduct);
2131   - aiptek->inputdev.id.version = le16_to_cpu(usbdev->descriptor.bcdDevice);
  2129 + usb_to_input_id(usbdev, &aiptek->inputdev.id);
2132 2130 aiptek->inputdev.dev = &intf->dev;
2133 2131  
2134 2132 aiptek->usbdev = usbdev;
drivers/usb/input/ati_remote.c
... ... @@ -94,6 +94,7 @@
94 94 #include <linux/moduleparam.h>
95 95 #include <linux/input.h>
96 96 #include <linux/usb.h>
  97 +#include <linux/usb_input.h>
97 98 #include <linux/wait.h>
98 99  
99 100 /*
... ... @@ -635,11 +636,8 @@
635 636 idev->name = ati_remote->name;
636 637 idev->phys = ati_remote->phys;
637 638  
638   - idev->id.bustype = BUS_USB;
639   - idev->id.vendor = le16_to_cpu(ati_remote->udev->descriptor.idVendor);
640   - idev->id.product = le16_to_cpu(ati_remote->udev->descriptor.idProduct);
641   - idev->id.version = le16_to_cpu(ati_remote->udev->descriptor.bcdDevice);
642   - idev->dev = &(ati_remote->udev->dev);
  639 + usb_to_input_id(ati_remote->udev, &idev->id);
  640 + idev->dev = &ati_remote->udev->dev;
643 641 }
644 642  
645 643 static int ati_remote_initialize(struct ati_remote *ati_remote)
drivers/usb/input/hid-input.c
... ... @@ -31,6 +31,7 @@
31 31 #include <linux/kernel.h>
32 32 #include <linux/input.h>
33 33 #include <linux/usb.h>
  34 +#include <linux/usb_input.h>
34 35  
35 36 #undef DEBUG
36 37  
... ... @@ -581,10 +582,7 @@
581 582 hidinput->input.name = hid->name;
582 583 hidinput->input.phys = hid->phys;
583 584 hidinput->input.uniq = hid->uniq;
584   - hidinput->input.id.bustype = BUS_USB;
585   - hidinput->input.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
586   - hidinput->input.id.product = le16_to_cpu(dev->descriptor.idProduct);
587   - hidinput->input.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
  585 + usb_to_input_id(dev, &hidinput->input.id);
588 586 hidinput->input.dev = &hid->intf->dev;
589 587 }
590 588  
drivers/usb/input/itmtouch.c
... ... @@ -53,6 +53,7 @@
53 53 #include <linux/module.h>
54 54 #include <linux/init.h>
55 55 #include <linux/usb.h>
  56 +#include <linux/usb_input.h>
56 57  
57 58 /* only an 8 byte buffer necessary for a single packet */
58 59 #define ITM_BUFSIZE 8
... ... @@ -184,10 +185,7 @@
184 185  
185 186 itmtouch->inputdev.name = itmtouch->name;
186 187 itmtouch->inputdev.phys = itmtouch->phys;
187   - itmtouch->inputdev.id.bustype = BUS_USB;
188   - itmtouch->inputdev.id.vendor = udev->descriptor.idVendor;
189   - itmtouch->inputdev.id.product = udev->descriptor.idProduct;
190   - itmtouch->inputdev.id.version = udev->descriptor.bcdDevice;
  188 + usb_to_input_id(udev, &itmtouch->inputdev.id);
191 189 itmtouch->inputdev.dev = &intf->dev;
192 190  
193 191 if (!strlen(itmtouch->name))
drivers/usb/input/kbtab.c
... ... @@ -4,6 +4,7 @@
4 4 #include <linux/module.h>
5 5 #include <linux/init.h>
6 6 #include <linux/usb.h>
  7 +#include <linux/usb_input.h>
7 8 #include <asm/unaligned.h>
8 9 #include <asm/byteorder.h>
9 10  
... ... @@ -167,10 +168,7 @@
167 168  
168 169 kbtab->dev.name = "KB Gear Tablet";
169 170 kbtab->dev.phys = kbtab->phys;
170   - kbtab->dev.id.bustype = BUS_USB;
171   - kbtab->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
172   - kbtab->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
173   - kbtab->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
  171 + usb_to_input_id(dev, &kbtab->dev.id);
174 172 kbtab->dev.dev = &intf->dev;
175 173 kbtab->usbdev = dev;
176 174  
drivers/usb/input/mtouchusb.c
... ... @@ -53,6 +53,7 @@
53 53 #include <linux/module.h>
54 54 #include <linux/init.h>
55 55 #include <linux/usb.h>
  56 +#include <linux/usb_input.h>
56 57  
57 58 #define MTOUCHUSB_MIN_XC 0x0
58 59 #define MTOUCHUSB_MAX_RAW_XC 0x4000
... ... @@ -232,10 +233,7 @@
232 233  
233 234 mtouch->input.name = mtouch->name;
234 235 mtouch->input.phys = mtouch->phys;
235   - mtouch->input.id.bustype = BUS_USB;
236   - mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
237   - mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
238   - mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
  236 + usb_to_input_id(udev, &mtouch->input.id);
239 237 mtouch->input.dev = &intf->dev;
240 238  
241 239 mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
drivers/usb/input/powermate.c
... ... @@ -35,6 +35,7 @@
35 35 #include <linux/init.h>
36 36 #include <linux/spinlock.h>
37 37 #include <linux/usb.h>
  38 +#include <linux/usb_input.h>
38 39  
39 40 #define POWERMATE_VENDOR 0x077d /* Griffin Technology, Inc. */
40 41 #define POWERMATE_PRODUCT_NEW 0x0410 /* Griffin PowerMate */
... ... @@ -389,10 +390,7 @@
389 390 pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
390 391 pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL);
391 392 pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED);
392   - pm->input.id.bustype = BUS_USB;
393   - pm->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
394   - pm->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
395   - pm->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
  393 + usb_to_input_id(udev, &pm->input.id);
396 394 pm->input.event = powermate_input_event;
397 395 pm->input.dev = &intf->dev;
398 396 pm->input.phys = pm->phys;
drivers/usb/input/touchkitusb.c
... ... @@ -35,8 +35,8 @@
35 35 #define DEBUG
36 36 #endif
37 37 #include <linux/usb.h>
  38 +#include <linux/usb_input.h>
38 39  
39   -
40 40 #define TOUCHKIT_MIN_XC 0x0
41 41 #define TOUCHKIT_MAX_XC 0x07ff
42 42 #define TOUCHKIT_XC_FUZZ 0x0
... ... @@ -202,10 +202,7 @@
202 202  
203 203 touchkit->input.name = touchkit->name;
204 204 touchkit->input.phys = touchkit->phys;
205   - touchkit->input.id.bustype = BUS_USB;
206   - touchkit->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
207   - touchkit->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
208   - touchkit->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
  205 + usb_to_input_id(udev, &touchkit->input.id);
209 206 touchkit->input.dev = &intf->dev;
210 207  
211 208 touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
drivers/usb/input/usbkbd.c
... ... @@ -32,6 +32,7 @@
32 32 #include <linux/input.h>
33 33 #include <linux/init.h>
34 34 #include <linux/usb.h>
  35 +#include <linux/usb_input.h>
35 36  
36 37 /*
37 38 * Version Information
... ... @@ -288,10 +289,7 @@
288 289  
289 290 kbd->dev.name = kbd->name;
290 291 kbd->dev.phys = kbd->phys;
291   - kbd->dev.id.bustype = BUS_USB;
292   - kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
293   - kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
294   - kbd->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
  292 + usb_to_input_id(dev, &kbd->dev.id);
295 293 kbd->dev.dev = &iface->dev;
296 294  
297 295 if (dev->manufacturer)
drivers/usb/input/usbmouse.c
... ... @@ -32,6 +32,7 @@
32 32 #include <linux/module.h>
33 33 #include <linux/init.h>
34 34 #include <linux/usb.h>
  35 +#include <linux/usb_input.h>
35 36  
36 37 /*
37 38 * Version Information
... ... @@ -171,10 +172,7 @@
171 172  
172 173 mouse->dev.name = mouse->name;
173 174 mouse->dev.phys = mouse->phys;
174   - mouse->dev.id.bustype = BUS_USB;
175   - mouse->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
176   - mouse->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
177   - mouse->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
  175 + usb_to_input_id(dev, &mouse->dev.id);
178 176 mouse->dev.dev = &intf->dev;
179 177  
180 178 if (dev->manufacturer)
drivers/usb/input/wacom.c
... ... @@ -69,6 +69,7 @@
69 69 #include <linux/module.h>
70 70 #include <linux/init.h>
71 71 #include <linux/usb.h>
  72 +#include <linux/usb_input.h>
72 73 #include <asm/unaligned.h>
73 74 #include <asm/byteorder.h>
74 75  
... ... @@ -823,10 +824,7 @@
823 824  
824 825 wacom->dev.name = wacom->features->name;
825 826 wacom->dev.phys = wacom->phys;
826   - wacom->dev.id.bustype = BUS_USB;
827   - wacom->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
828   - wacom->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
829   - wacom->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
  827 + usb_to_input_id(dev, &wacom->dev.id);
830 828 wacom->dev.dev = &intf->dev;
831 829 wacom->usbdev = dev;
832 830  
drivers/usb/input/xpad.c
... ... @@ -62,6 +62,7 @@
62 62 #include <linux/module.h>
63 63 #include <linux/smp_lock.h>
64 64 #include <linux/usb.h>
  65 +#include <linux/usb_input.h>
65 66  
66 67 #define DRIVER_VERSION "v0.0.5"
67 68 #define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
... ... @@ -256,10 +257,7 @@
256 257  
257 258 xpad->udev = udev;
258 259  
259   - xpad->dev.id.bustype = BUS_USB;
260   - xpad->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
261   - xpad->dev.id.product = le16_to_cpu(udev->descriptor.idProduct);
262   - xpad->dev.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
  260 + usb_to_input_id(udev, &xpad->dev.id);
263 261 xpad->dev.dev = &intf->dev;
264 262 xpad->dev.private = xpad;
265 263 xpad->dev.name = xpad_device[i].name;
drivers/usb/media/konicawc.c
... ... @@ -16,6 +16,7 @@
16 16 #include <linux/module.h>
17 17 #include <linux/init.h>
18 18 #include <linux/input.h>
  19 +#include <linux/usb_input.h>
19 20  
20 21 #include "usbvideo.h"
21 22  
... ... @@ -845,10 +846,7 @@
845 846 cam->input.private = cam;
846 847 cam->input.evbit[0] = BIT(EV_KEY);
847 848 cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
848   - cam->input.id.bustype = BUS_USB;
849   - cam->input.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
850   - cam->input.id.product = le16_to_cpu(dev->descriptor.idProduct);
851   - cam->input.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
  849 + usb_to_input_id(dev, &cam->input.id);
852 850 input_register_device(&cam->input);
853 851  
854 852 usb_make_path(dev, cam->input_physname, 56);
include/linux/usb_input.h
  1 +#ifndef __USB_INPUT_H
  2 +#define __USB_INPUT_H
  3 +
  4 +/*
  5 + * Copyright (C) 2005 Dmitry Torokhov
  6 + *
  7 + * This program is free software; you can redistribute it and/or modify it
  8 + * under the terms of the GNU General Public License version 2 as published by
  9 + * the Free Software Foundation.
  10 + */
  11 +
  12 +#include <linux/usb.h>
  13 +#include <linux/input.h>
  14 +#include <asm/byteorder.h>
  15 +
  16 +static inline void
  17 +usb_to_input_id(const struct usb_device *dev, struct input_id *id)
  18 +{
  19 + id->bustype = BUS_USB;
  20 + id->vendor = le16_to_cpu(dev->descriptor.idVendor);
  21 + id->product = le16_to_cpu(dev->descriptor.idProduct);
  22 + id->version = le16_to_cpu(dev->descriptor.bcdDevice);
  23 +}
  24 +
  25 +#endif