diff options
author | Jiri Kosina <jkosina@suse.cz> | 2006-12-08 12:41:03 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-12-08 13:43:14 -0500 |
commit | 4916b3a57fc94664677d439b911b8aaf86c7ec23 (patch) | |
tree | fc8038ec52950ddfdb1c6c66f90eb1c381e446ca /drivers/usb/input | |
parent | 229695e51efc4ed5e04ab471c82591d0f432909d (diff) |
[PATCH] Generic HID layer - USB API
- 'dev' in struct hid_device changed from struct usb_device to
struct device and fixed all the users
- renamed functions which are part of USB HID API from 'hid_*' to
'usbhid_*'
- force feedback initialization moved from common part into USB-specific
driver
- added usbhid.h header for USB HID API users
- removed USB-specific fields from struct hid_device and moved them
to new usbhid_device, which is pointed to by hid_device->driver_data
- fixed all USB users to use this new structure
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/input')
-rw-r--r-- | drivers/usb/input/hid-core.c | 419 | ||||
-rw-r--r-- | drivers/usb/input/hid-ff.c | 4 | ||||
-rw-r--r-- | drivers/usb/input/hid-lgff.c | 5 | ||||
-rw-r--r-- | drivers/usb/input/hid-pidff.c | 54 | ||||
-rw-r--r-- | drivers/usb/input/hid-tmff.c | 3 | ||||
-rw-r--r-- | drivers/usb/input/hid-zpff.c | 5 | ||||
-rw-r--r-- | drivers/usb/input/hiddev.c | 31 | ||||
-rw-r--r-- | drivers/usb/input/usbhid.h | 84 |
8 files changed, 367 insertions, 238 deletions
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 462947f74135..0991c4b751a6 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | #include <linux/hid.h> | 36 | #include <linux/hid.h> |
37 | #include <linux/hiddev.h> | 37 | #include <linux/hiddev.h> |
38 | #include "usbhid.h" | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Version Information | 41 | * Version Information |
@@ -66,15 +67,16 @@ static int hid_start_in(struct hid_device *hid) | |||
66 | { | 67 | { |
67 | unsigned long flags; | 68 | unsigned long flags; |
68 | int rc = 0; | 69 | int rc = 0; |
70 | struct usbhid_device *usbhid = hid->driver_data; | ||
69 | 71 | ||
70 | spin_lock_irqsave(&hid->inlock, flags); | 72 | spin_lock_irqsave(&usbhid->inlock, flags); |
71 | if (hid->open > 0 && !test_bit(HID_SUSPENDED, &hid->iofl) && | 73 | if (hid->open > 0 && !test_bit(HID_SUSPENDED, &usbhid->iofl) && |
72 | !test_and_set_bit(HID_IN_RUNNING, &hid->iofl)) { | 74 | !test_and_set_bit(HID_IN_RUNNING, &usbhid->iofl)) { |
73 | rc = usb_submit_urb(hid->urbin, GFP_ATOMIC); | 75 | rc = usb_submit_urb(usbhid->urbin, GFP_ATOMIC); |
74 | if (rc != 0) | 76 | if (rc != 0) |
75 | clear_bit(HID_IN_RUNNING, &hid->iofl); | 77 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
76 | } | 78 | } |
77 | spin_unlock_irqrestore(&hid->inlock, flags); | 79 | spin_unlock_irqrestore(&usbhid->inlock, flags); |
78 | return rc; | 80 | return rc; |
79 | } | 81 | } |
80 | 82 | ||
@@ -82,8 +84,9 @@ static int hid_start_in(struct hid_device *hid) | |||
82 | static void hid_retry_timeout(unsigned long _hid) | 84 | static void hid_retry_timeout(unsigned long _hid) |
83 | { | 85 | { |
84 | struct hid_device *hid = (struct hid_device *) _hid; | 86 | struct hid_device *hid = (struct hid_device *) _hid; |
87 | struct usbhid_device *usbhid = hid->driver_data; | ||
85 | 88 | ||
86 | dev_dbg(&hid->intf->dev, "retrying intr urb\n"); | 89 | dev_dbg(&usbhid->intf->dev, "retrying intr urb\n"); |
87 | if (hid_start_in(hid)) | 90 | if (hid_start_in(hid)) |
88 | hid_io_error(hid); | 91 | hid_io_error(hid); |
89 | } | 92 | } |
@@ -91,38 +94,39 @@ static void hid_retry_timeout(unsigned long _hid) | |||
91 | /* Workqueue routine to reset the device or clear a halt */ | 94 | /* Workqueue routine to reset the device or clear a halt */ |
92 | static void hid_reset(struct work_struct *work) | 95 | static void hid_reset(struct work_struct *work) |
93 | { | 96 | { |
94 | struct hid_device *hid = | 97 | struct usbhid_device *usbhid = |
95 | container_of(work, struct hid_device, reset_work); | 98 | container_of(work, struct usbhid_device, reset_work); |
99 | struct hid_device *hid = usbhid->hid; | ||
96 | int rc_lock, rc = 0; | 100 | int rc_lock, rc = 0; |
97 | 101 | ||
98 | if (test_bit(HID_CLEAR_HALT, &hid->iofl)) { | 102 | if (test_bit(HID_CLEAR_HALT, &usbhid->iofl)) { |
99 | dev_dbg(&hid->intf->dev, "clear halt\n"); | 103 | dev_dbg(&usbhid->intf->dev, "clear halt\n"); |
100 | rc = usb_clear_halt(hid->dev, hid->urbin->pipe); | 104 | rc = usb_clear_halt(to_usb_device(hid->dev), usbhid->urbin->pipe); |
101 | clear_bit(HID_CLEAR_HALT, &hid->iofl); | 105 | clear_bit(HID_CLEAR_HALT, &usbhid->iofl); |
102 | hid_start_in(hid); | 106 | hid_start_in(hid); |
103 | } | 107 | } |
104 | 108 | ||
105 | else if (test_bit(HID_RESET_PENDING, &hid->iofl)) { | 109 | else if (test_bit(HID_RESET_PENDING, &usbhid->iofl)) { |
106 | dev_dbg(&hid->intf->dev, "resetting device\n"); | 110 | dev_dbg(&usbhid->intf->dev, "resetting device\n"); |
107 | rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf); | 111 | rc = rc_lock = usb_lock_device_for_reset(to_usb_device(hid->dev), usbhid->intf); |
108 | if (rc_lock >= 0) { | 112 | if (rc_lock >= 0) { |
109 | rc = usb_reset_composite_device(hid->dev, hid->intf); | 113 | rc = usb_reset_composite_device(to_usb_device(hid->dev), usbhid->intf); |
110 | if (rc_lock) | 114 | if (rc_lock) |
111 | usb_unlock_device(hid->dev); | 115 | usb_unlock_device(to_usb_device(hid->dev)); |
112 | } | 116 | } |
113 | clear_bit(HID_RESET_PENDING, &hid->iofl); | 117 | clear_bit(HID_RESET_PENDING, &usbhid->iofl); |
114 | } | 118 | } |
115 | 119 | ||
116 | switch (rc) { | 120 | switch (rc) { |
117 | case 0: | 121 | case 0: |
118 | if (!test_bit(HID_IN_RUNNING, &hid->iofl)) | 122 | if (!test_bit(HID_IN_RUNNING, &usbhid->iofl)) |
119 | hid_io_error(hid); | 123 | hid_io_error(hid); |
120 | break; | 124 | break; |
121 | default: | 125 | default: |
122 | err("can't reset device, %s-%s/input%d, status %d", | 126 | err("can't reset device, %s-%s/input%d, status %d", |
123 | hid->dev->bus->bus_name, | 127 | to_usb_device(hid->dev)->bus->bus_name, |
124 | hid->dev->devpath, | 128 | to_usb_device(hid->dev)->devpath, |
125 | hid->ifnum, rc); | 129 | usbhid->ifnum, rc); |
126 | /* FALLTHROUGH */ | 130 | /* FALLTHROUGH */ |
127 | case -EHOSTUNREACH: | 131 | case -EHOSTUNREACH: |
128 | case -ENODEV: | 132 | case -ENODEV: |
@@ -135,33 +139,34 @@ static void hid_reset(struct work_struct *work) | |||
135 | static void hid_io_error(struct hid_device *hid) | 139 | static void hid_io_error(struct hid_device *hid) |
136 | { | 140 | { |
137 | unsigned long flags; | 141 | unsigned long flags; |
142 | struct usbhid_device *usbhid = hid->driver_data; | ||
138 | 143 | ||
139 | spin_lock_irqsave(&hid->inlock, flags); | 144 | spin_lock_irqsave(&usbhid->inlock, flags); |
140 | 145 | ||
141 | /* Stop when disconnected */ | 146 | /* Stop when disconnected */ |
142 | if (usb_get_intfdata(hid->intf) == NULL) | 147 | if (usb_get_intfdata(usbhid->intf) == NULL) |
143 | goto done; | 148 | goto done; |
144 | 149 | ||
145 | /* When an error occurs, retry at increasing intervals */ | 150 | /* When an error occurs, retry at increasing intervals */ |
146 | if (hid->retry_delay == 0) { | 151 | if (usbhid->retry_delay == 0) { |
147 | hid->retry_delay = 13; /* Then 26, 52, 104, 104, ... */ | 152 | usbhid->retry_delay = 13; /* Then 26, 52, 104, 104, ... */ |
148 | hid->stop_retry = jiffies + msecs_to_jiffies(1000); | 153 | usbhid->stop_retry = jiffies + msecs_to_jiffies(1000); |
149 | } else if (hid->retry_delay < 100) | 154 | } else if (usbhid->retry_delay < 100) |
150 | hid->retry_delay *= 2; | 155 | usbhid->retry_delay *= 2; |
151 | 156 | ||
152 | if (time_after(jiffies, hid->stop_retry)) { | 157 | if (time_after(jiffies, usbhid->stop_retry)) { |
153 | 158 | ||
154 | /* Retries failed, so do a port reset */ | 159 | /* Retries failed, so do a port reset */ |
155 | if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) { | 160 | if (!test_and_set_bit(HID_RESET_PENDING, &usbhid->iofl)) { |
156 | schedule_work(&hid->reset_work); | 161 | schedule_work(&usbhid->reset_work); |
157 | goto done; | 162 | goto done; |
158 | } | 163 | } |
159 | } | 164 | } |
160 | 165 | ||
161 | mod_timer(&hid->io_retry, | 166 | mod_timer(&usbhid->io_retry, |
162 | jiffies + msecs_to_jiffies(hid->retry_delay)); | 167 | jiffies + msecs_to_jiffies(usbhid->retry_delay)); |
163 | done: | 168 | done: |
164 | spin_unlock_irqrestore(&hid->inlock, flags); | 169 | spin_unlock_irqrestore(&usbhid->inlock, flags); |
165 | } | 170 | } |
166 | 171 | ||
167 | 172 | ||
@@ -230,28 +235,29 @@ static int hid_input_report(int type, struct urb *urb, int interrupt) | |||
230 | static void hid_irq_in(struct urb *urb) | 235 | static void hid_irq_in(struct urb *urb) |
231 | { | 236 | { |
232 | struct hid_device *hid = urb->context; | 237 | struct hid_device *hid = urb->context; |
238 | struct usbhid_device *usbhid = hid->driver_data; | ||
233 | int status; | 239 | int status; |
234 | 240 | ||
235 | switch (urb->status) { | 241 | switch (urb->status) { |
236 | case 0: /* success */ | 242 | case 0: /* success */ |
237 | hid->retry_delay = 0; | 243 | usbhid->retry_delay = 0; |
238 | hid_input_report(HID_INPUT_REPORT, urb, 1); | 244 | hid_input_report(HID_INPUT_REPORT, urb, 1); |
239 | break; | 245 | break; |
240 | case -EPIPE: /* stall */ | 246 | case -EPIPE: /* stall */ |
241 | clear_bit(HID_IN_RUNNING, &hid->iofl); | 247 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
242 | set_bit(HID_CLEAR_HALT, &hid->iofl); | 248 | set_bit(HID_CLEAR_HALT, &usbhid->iofl); |
243 | schedule_work(&hid->reset_work); | 249 | schedule_work(&usbhid->reset_work); |
244 | return; | 250 | return; |
245 | case -ECONNRESET: /* unlink */ | 251 | case -ECONNRESET: /* unlink */ |
246 | case -ENOENT: | 252 | case -ENOENT: |
247 | case -ESHUTDOWN: /* unplug */ | 253 | case -ESHUTDOWN: /* unplug */ |
248 | clear_bit(HID_IN_RUNNING, &hid->iofl); | 254 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
249 | return; | 255 | return; |
250 | case -EILSEQ: /* protocol error or unplug */ | 256 | case -EILSEQ: /* protocol error or unplug */ |
251 | case -EPROTO: /* protocol error or unplug */ | 257 | case -EPROTO: /* protocol error or unplug */ |
252 | case -ETIME: /* protocol error or unplug */ | 258 | case -ETIME: /* protocol error or unplug */ |
253 | case -ETIMEDOUT: /* Should never happen, but... */ | 259 | case -ETIMEDOUT: /* Should never happen, but... */ |
254 | clear_bit(HID_IN_RUNNING, &hid->iofl); | 260 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
255 | hid_io_error(hid); | 261 | hid_io_error(hid); |
256 | return; | 262 | return; |
257 | default: /* error */ | 263 | default: /* error */ |
@@ -260,12 +266,12 @@ static void hid_irq_in(struct urb *urb) | |||
260 | 266 | ||
261 | status = usb_submit_urb(urb, GFP_ATOMIC); | 267 | status = usb_submit_urb(urb, GFP_ATOMIC); |
262 | if (status) { | 268 | if (status) { |
263 | clear_bit(HID_IN_RUNNING, &hid->iofl); | 269 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
264 | if (status != -EPERM) { | 270 | if (status != -EPERM) { |
265 | err("can't resubmit intr, %s-%s/input%d, status %d", | 271 | err("can't resubmit intr, %s-%s/input%d, status %d", |
266 | hid->dev->bus->bus_name, | 272 | to_usb_device(hid->dev)->bus->bus_name, |
267 | hid->dev->devpath, | 273 | to_usb_device(hid->dev)->devpath, |
268 | hid->ifnum, status); | 274 | usbhid->ifnum, status); |
269 | hid_io_error(hid); | 275 | hid_io_error(hid); |
270 | } | 276 | } |
271 | } | 277 | } |
@@ -291,16 +297,17 @@ struct hid_field *hid_find_field_by_usage(struct hid_device *hid, __u32 wanted_u | |||
291 | static int hid_submit_out(struct hid_device *hid) | 297 | static int hid_submit_out(struct hid_device *hid) |
292 | { | 298 | { |
293 | struct hid_report *report; | 299 | struct hid_report *report; |
300 | struct usbhid_device *usbhid = hid->driver_data; | ||
294 | 301 | ||
295 | report = hid->out[hid->outtail]; | 302 | report = usbhid->out[usbhid->outtail]; |
296 | 303 | ||
297 | hid_output_report(report, hid->outbuf); | 304 | hid_output_report(report, usbhid->outbuf); |
298 | hid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); | 305 | usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); |
299 | hid->urbout->dev = hid->dev; | 306 | usbhid->urbout->dev = to_usb_device(hid->dev); |
300 | 307 | ||
301 | dbg("submitting out urb"); | 308 | dbg("submitting out urb"); |
302 | 309 | ||
303 | if (usb_submit_urb(hid->urbout, GFP_ATOMIC)) { | 310 | if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) { |
304 | err("usb_submit_urb(out) failed"); | 311 | err("usb_submit_urb(out) failed"); |
305 | return -1; | 312 | return -1; |
306 | } | 313 | } |
@@ -313,42 +320,43 @@ static int hid_submit_ctrl(struct hid_device *hid) | |||
313 | struct hid_report *report; | 320 | struct hid_report *report; |
314 | unsigned char dir; | 321 | unsigned char dir; |
315 | int len; | 322 | int len; |
323 | struct usbhid_device *usbhid = hid->driver_data; | ||
316 | 324 | ||
317 | report = hid->ctrl[hid->ctrltail].report; | 325 | report = usbhid->ctrl[usbhid->ctrltail].report; |
318 | dir = hid->ctrl[hid->ctrltail].dir; | 326 | dir = usbhid->ctrl[usbhid->ctrltail].dir; |
319 | 327 | ||
320 | len = ((report->size - 1) >> 3) + 1 + (report->id > 0); | 328 | len = ((report->size - 1) >> 3) + 1 + (report->id > 0); |
321 | if (dir == USB_DIR_OUT) { | 329 | if (dir == USB_DIR_OUT) { |
322 | hid_output_report(report, hid->ctrlbuf); | 330 | hid_output_report(report, usbhid->ctrlbuf); |
323 | hid->urbctrl->pipe = usb_sndctrlpipe(hid->dev, 0); | 331 | usbhid->urbctrl->pipe = usb_sndctrlpipe(to_usb_device(hid->dev), 0); |
324 | hid->urbctrl->transfer_buffer_length = len; | 332 | usbhid->urbctrl->transfer_buffer_length = len; |
325 | } else { | 333 | } else { |
326 | int maxpacket, padlen; | 334 | int maxpacket, padlen; |
327 | 335 | ||
328 | hid->urbctrl->pipe = usb_rcvctrlpipe(hid->dev, 0); | 336 | usbhid->urbctrl->pipe = usb_rcvctrlpipe(to_usb_device(hid->dev), 0); |
329 | maxpacket = usb_maxpacket(hid->dev, hid->urbctrl->pipe, 0); | 337 | maxpacket = usb_maxpacket(to_usb_device(hid->dev), usbhid->urbctrl->pipe, 0); |
330 | if (maxpacket > 0) { | 338 | if (maxpacket > 0) { |
331 | padlen = (len + maxpacket - 1) / maxpacket; | 339 | padlen = (len + maxpacket - 1) / maxpacket; |
332 | padlen *= maxpacket; | 340 | padlen *= maxpacket; |
333 | if (padlen > hid->bufsize) | 341 | if (padlen > usbhid->bufsize) |
334 | padlen = hid->bufsize; | 342 | padlen = usbhid->bufsize; |
335 | } else | 343 | } else |
336 | padlen = 0; | 344 | padlen = 0; |
337 | hid->urbctrl->transfer_buffer_length = padlen; | 345 | usbhid->urbctrl->transfer_buffer_length = padlen; |
338 | } | 346 | } |
339 | hid->urbctrl->dev = hid->dev; | 347 | usbhid->urbctrl->dev = to_usb_device(hid->dev); |
340 | 348 | ||
341 | hid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir; | 349 | usbhid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir; |
342 | hid->cr->bRequest = (dir == USB_DIR_OUT) ? HID_REQ_SET_REPORT : HID_REQ_GET_REPORT; | 350 | usbhid->cr->bRequest = (dir == USB_DIR_OUT) ? HID_REQ_SET_REPORT : HID_REQ_GET_REPORT; |
343 | hid->cr->wValue = cpu_to_le16(((report->type + 1) << 8) | report->id); | 351 | usbhid->cr->wValue = cpu_to_le16(((report->type + 1) << 8) | report->id); |
344 | hid->cr->wIndex = cpu_to_le16(hid->ifnum); | 352 | usbhid->cr->wIndex = cpu_to_le16(usbhid->ifnum); |
345 | hid->cr->wLength = cpu_to_le16(len); | 353 | usbhid->cr->wLength = cpu_to_le16(len); |
346 | 354 | ||
347 | dbg("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u", | 355 | dbg("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u", |
348 | hid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report", | 356 | usbhid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report", |
349 | hid->cr->wValue, hid->cr->wIndex, hid->cr->wLength); | 357 | usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength); |
350 | 358 | ||
351 | if (usb_submit_urb(hid->urbctrl, GFP_ATOMIC)) { | 359 | if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) { |
352 | err("usb_submit_urb(ctrl) failed"); | 360 | err("usb_submit_urb(ctrl) failed"); |
353 | return -1; | 361 | return -1; |
354 | } | 362 | } |
@@ -363,6 +371,7 @@ static int hid_submit_ctrl(struct hid_device *hid) | |||
363 | static void hid_irq_out(struct urb *urb) | 371 | static void hid_irq_out(struct urb *urb) |
364 | { | 372 | { |
365 | struct hid_device *hid = urb->context; | 373 | struct hid_device *hid = urb->context; |
374 | struct usbhid_device *usbhid = hid->driver_data; | ||
366 | unsigned long flags; | 375 | unsigned long flags; |
367 | int unplug = 0; | 376 | int unplug = 0; |
368 | 377 | ||
@@ -380,24 +389,24 @@ static void hid_irq_out(struct urb *urb) | |||
380 | warn("output irq status %d received", urb->status); | 389 | warn("output irq status %d received", urb->status); |
381 | } | 390 | } |
382 | 391 | ||
383 | spin_lock_irqsave(&hid->outlock, flags); | 392 | spin_lock_irqsave(&usbhid->outlock, flags); |
384 | 393 | ||
385 | if (unplug) | 394 | if (unplug) |
386 | hid->outtail = hid->outhead; | 395 | usbhid->outtail = usbhid->outhead; |
387 | else | 396 | else |
388 | hid->outtail = (hid->outtail + 1) & (HID_OUTPUT_FIFO_SIZE - 1); | 397 | usbhid->outtail = (usbhid->outtail + 1) & (HID_OUTPUT_FIFO_SIZE - 1); |
389 | 398 | ||
390 | if (hid->outhead != hid->outtail) { | 399 | if (usbhid->outhead != usbhid->outtail) { |
391 | if (hid_submit_out(hid)) { | 400 | if (hid_submit_out(hid)) { |
392 | clear_bit(HID_OUT_RUNNING, &hid->iofl); | 401 | clear_bit(HID_OUT_RUNNING, &usbhid->iofl); |
393 | wake_up(&hid->wait); | 402 | wake_up(&hid->wait); |
394 | } | 403 | } |
395 | spin_unlock_irqrestore(&hid->outlock, flags); | 404 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
396 | return; | 405 | return; |
397 | } | 406 | } |
398 | 407 | ||
399 | clear_bit(HID_OUT_RUNNING, &hid->iofl); | 408 | clear_bit(HID_OUT_RUNNING, &usbhid->iofl); |
400 | spin_unlock_irqrestore(&hid->outlock, flags); | 409 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
401 | wake_up(&hid->wait); | 410 | wake_up(&hid->wait); |
402 | } | 411 | } |
403 | 412 | ||
@@ -408,15 +417,16 @@ static void hid_irq_out(struct urb *urb) | |||
408 | static void hid_ctrl(struct urb *urb) | 417 | static void hid_ctrl(struct urb *urb) |
409 | { | 418 | { |
410 | struct hid_device *hid = urb->context; | 419 | struct hid_device *hid = urb->context; |
420 | struct usbhid_device *usbhid = hid->driver_data; | ||
411 | unsigned long flags; | 421 | unsigned long flags; |
412 | int unplug = 0; | 422 | int unplug = 0; |
413 | 423 | ||
414 | spin_lock_irqsave(&hid->ctrllock, flags); | 424 | spin_lock_irqsave(&usbhid->ctrllock, flags); |
415 | 425 | ||
416 | switch (urb->status) { | 426 | switch (urb->status) { |
417 | case 0: /* success */ | 427 | case 0: /* success */ |
418 | if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) | 428 | if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) |
419 | hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0); | 429 | hid_input_report(usbhid->ctrl[usbhid->ctrltail].report->type, urb, 0); |
420 | break; | 430 | break; |
421 | case -ESHUTDOWN: /* unplug */ | 431 | case -ESHUTDOWN: /* unplug */ |
422 | unplug = 1; | 432 | unplug = 1; |
@@ -431,70 +441,71 @@ static void hid_ctrl(struct urb *urb) | |||
431 | } | 441 | } |
432 | 442 | ||
433 | if (unplug) | 443 | if (unplug) |
434 | hid->ctrltail = hid->ctrlhead; | 444 | usbhid->ctrltail = usbhid->ctrlhead; |
435 | else | 445 | else |
436 | hid->ctrltail = (hid->ctrltail + 1) & (HID_CONTROL_FIFO_SIZE - 1); | 446 | usbhid->ctrltail = (usbhid->ctrltail + 1) & (HID_CONTROL_FIFO_SIZE - 1); |
437 | 447 | ||
438 | if (hid->ctrlhead != hid->ctrltail) { | 448 | if (usbhid->ctrlhead != usbhid->ctrltail) { |
439 | if (hid_submit_ctrl(hid)) { | 449 | if (hid_submit_ctrl(hid)) { |
440 | clear_bit(HID_CTRL_RUNNING, &hid->iofl); | 450 | clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); |
441 | wake_up(&hid->wait); | 451 | wake_up(&hid->wait); |
442 | } | 452 | } |
443 | spin_unlock_irqrestore(&hid->ctrllock, flags); | 453 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
444 | return; | 454 | return; |
445 | } | 455 | } |
446 | 456 | ||
447 | clear_bit(HID_CTRL_RUNNING, &hid->iofl); | 457 | clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); |
448 | spin_unlock_irqrestore(&hid->ctrllock, flags); | 458 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
449 | wake_up(&hid->wait); | 459 | wake_up(&hid->wait); |
450 | } | 460 | } |
451 | 461 | ||
452 | void hid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir) | 462 | void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir) |
453 | { | 463 | { |
454 | int head; | 464 | int head; |
455 | unsigned long flags; | 465 | unsigned long flags; |
466 | struct usbhid_device *usbhid = hid->driver_data; | ||
456 | 467 | ||
457 | if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN) | 468 | if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN) |
458 | return; | 469 | return; |
459 | 470 | ||
460 | if (hid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) { | 471 | if (usbhid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) { |
461 | 472 | ||
462 | spin_lock_irqsave(&hid->outlock, flags); | 473 | spin_lock_irqsave(&usbhid->outlock, flags); |
463 | 474 | ||
464 | if ((head = (hid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == hid->outtail) { | 475 | if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) { |
465 | spin_unlock_irqrestore(&hid->outlock, flags); | 476 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
466 | warn("output queue full"); | 477 | warn("output queue full"); |
467 | return; | 478 | return; |
468 | } | 479 | } |
469 | 480 | ||
470 | hid->out[hid->outhead] = report; | 481 | usbhid->out[usbhid->outhead] = report; |
471 | hid->outhead = head; | 482 | usbhid->outhead = head; |
472 | 483 | ||
473 | if (!test_and_set_bit(HID_OUT_RUNNING, &hid->iofl)) | 484 | if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl)) |
474 | if (hid_submit_out(hid)) | 485 | if (hid_submit_out(hid)) |
475 | clear_bit(HID_OUT_RUNNING, &hid->iofl); | 486 | clear_bit(HID_OUT_RUNNING, &usbhid->iofl); |
476 | 487 | ||
477 | spin_unlock_irqrestore(&hid->outlock, flags); | 488 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
478 | return; | 489 | return; |
479 | } | 490 | } |
480 | 491 | ||
481 | spin_lock_irqsave(&hid->ctrllock, flags); | 492 | spin_lock_irqsave(&usbhid->ctrllock, flags); |
482 | 493 | ||
483 | if ((head = (hid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == hid->ctrltail) { | 494 | if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) { |
484 | spin_unlock_irqrestore(&hid->ctrllock, flags); | 495 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
485 | warn("control queue full"); | 496 | warn("control queue full"); |
486 | return; | 497 | return; |
487 | } | 498 | } |
488 | 499 | ||
489 | hid->ctrl[hid->ctrlhead].report = report; | 500 | usbhid->ctrl[usbhid->ctrlhead].report = report; |
490 | hid->ctrl[hid->ctrlhead].dir = dir; | 501 | usbhid->ctrl[usbhid->ctrlhead].dir = dir; |
491 | hid->ctrlhead = head; | 502 | usbhid->ctrlhead = head; |
492 | 503 | ||
493 | if (!test_and_set_bit(HID_CTRL_RUNNING, &hid->iofl)) | 504 | if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl)) |
494 | if (hid_submit_ctrl(hid)) | 505 | if (hid_submit_ctrl(hid)) |
495 | clear_bit(HID_CTRL_RUNNING, &hid->iofl); | 506 | clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); |
496 | 507 | ||
497 | spin_unlock_irqrestore(&hid->ctrllock, flags); | 508 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
498 | } | 509 | } |
499 | 510 | ||
500 | static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 511 | static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
@@ -515,15 +526,17 @@ static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, un | |||
515 | } | 526 | } |
516 | 527 | ||
517 | hid_set_field(field, offset, value); | 528 | hid_set_field(field, offset, value); |
518 | hid_submit_report(hid, field->report, USB_DIR_OUT); | 529 | usbhid_submit_report(hid, field->report, USB_DIR_OUT); |
519 | 530 | ||
520 | return 0; | 531 | return 0; |
521 | } | 532 | } |
522 | 533 | ||
523 | int hid_wait_io(struct hid_device *hid) | 534 | int usbhid_wait_io(struct hid_device *hid) |
524 | { | 535 | { |
525 | if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &hid->iofl) && | 536 | struct usbhid_device *usbhid = hid->driver_data; |
526 | !test_bit(HID_OUT_RUNNING, &hid->iofl)), | 537 | |
538 | if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl) && | ||
539 | !test_bit(HID_OUT_RUNNING, &usbhid->iofl)), | ||
527 | 10*HZ)) { | 540 | 10*HZ)) { |
528 | dbg("timeout waiting for ctrl or out queue to clear"); | 541 | dbg("timeout waiting for ctrl or out queue to clear"); |
529 | return -1; | 542 | return -1; |
@@ -555,7 +568,7 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, | |||
555 | return result; | 568 | return result; |
556 | } | 569 | } |
557 | 570 | ||
558 | int hid_open(struct hid_device *hid) | 571 | int usbhid_open(struct hid_device *hid) |
559 | { | 572 | { |
560 | ++hid->open; | 573 | ++hid->open; |
561 | if (hid_start_in(hid)) | 574 | if (hid_start_in(hid)) |
@@ -563,22 +576,24 @@ int hid_open(struct hid_device *hid) | |||
563 | return 0; | 576 | return 0; |
564 | } | 577 | } |
565 | 578 | ||
566 | void hid_close(struct hid_device *hid) | 579 | void usbhid_close(struct hid_device *hid) |
567 | { | 580 | { |
581 | struct usbhid_device *usbhid = hid->driver_data; | ||
582 | |||
568 | if (!--hid->open) | 583 | if (!--hid->open) |
569 | usb_kill_urb(hid->urbin); | 584 | usb_kill_urb(usbhid->urbin); |
570 | } | 585 | } |
571 | 586 | ||
572 | static int hidinput_open(struct input_dev *dev) | 587 | static int hidinput_open(struct input_dev *dev) |
573 | { | 588 | { |
574 | struct hid_device *hid = dev->private; | 589 | struct hid_device *hid = dev->private; |
575 | return hid_open(hid); | 590 | return usbhid_open(hid); |
576 | } | 591 | } |
577 | 592 | ||
578 | static void hidinput_close(struct input_dev *dev) | 593 | static void hidinput_close(struct input_dev *dev) |
579 | { | 594 | { |
580 | struct hid_device *hid = dev->private; | 595 | struct hid_device *hid = dev->private; |
581 | hid_close(hid); | 596 | usbhid_close(hid); |
582 | } | 597 | } |
583 | 598 | ||
584 | #define USB_VENDOR_ID_PANJIT 0x134c | 599 | #define USB_VENDOR_ID_PANJIT 0x134c |
@@ -590,26 +605,27 @@ static void hidinput_close(struct input_dev *dev) | |||
590 | * Initialize all reports | 605 | * Initialize all reports |
591 | */ | 606 | */ |
592 | 607 | ||
593 | void hid_init_reports(struct hid_device *hid) | 608 | void usbhid_init_reports(struct hid_device *hid) |
594 | { | 609 | { |
595 | struct hid_report *report; | 610 | struct hid_report *report; |
611 | struct usbhid_device *usbhid = hid->driver_data; | ||
596 | int err, ret; | 612 | int err, ret; |
597 | 613 | ||
598 | list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) | 614 | list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) |
599 | hid_submit_report(hid, report, USB_DIR_IN); | 615 | usbhid_submit_report(hid, report, USB_DIR_IN); |
600 | 616 | ||
601 | list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) | 617 | list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) |
602 | hid_submit_report(hid, report, USB_DIR_IN); | 618 | usbhid_submit_report(hid, report, USB_DIR_IN); |
603 | 619 | ||
604 | err = 0; | 620 | err = 0; |
605 | ret = hid_wait_io(hid); | 621 | ret = usbhid_wait_io(hid); |
606 | while (ret) { | 622 | while (ret) { |
607 | err |= ret; | 623 | err |= ret; |
608 | if (test_bit(HID_CTRL_RUNNING, &hid->iofl)) | 624 | if (test_bit(HID_CTRL_RUNNING, &usbhid->iofl)) |
609 | usb_kill_urb(hid->urbctrl); | 625 | usb_kill_urb(usbhid->urbctrl); |
610 | if (test_bit(HID_OUT_RUNNING, &hid->iofl)) | 626 | if (test_bit(HID_OUT_RUNNING, &usbhid->iofl)) |
611 | usb_kill_urb(hid->urbout); | 627 | usb_kill_urb(usbhid->urbout); |
612 | ret = hid_wait_io(hid); | 628 | ret = usbhid_wait_io(hid); |
613 | } | 629 | } |
614 | 630 | ||
615 | if (err) | 631 | if (err) |
@@ -1022,13 +1038,15 @@ static void hid_find_max_report(struct hid_device *hid, unsigned int type, int * | |||
1022 | 1038 | ||
1023 | static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) | 1039 | static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) |
1024 | { | 1040 | { |
1025 | if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->inbuf_dma))) | 1041 | struct usbhid_device *usbhid = hid->driver_data; |
1042 | |||
1043 | if (!(usbhid->inbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->inbuf_dma))) | ||
1026 | return -1; | 1044 | return -1; |
1027 | if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->outbuf_dma))) | 1045 | if (!(usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->outbuf_dma))) |
1028 | return -1; | 1046 | return -1; |
1029 | if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), GFP_ATOMIC, &hid->cr_dma))) | 1047 | if (!(usbhid->cr = usb_buffer_alloc(dev, sizeof(*(usbhid->cr)), GFP_ATOMIC, &usbhid->cr_dma))) |
1030 | return -1; | 1048 | return -1; |
1031 | if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->ctrlbuf_dma))) | 1049 | if (!(usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->ctrlbuf_dma))) |
1032 | return -1; | 1050 | return -1; |
1033 | 1051 | ||
1034 | return 0; | 1052 | return 0; |
@@ -1036,14 +1054,16 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) | |||
1036 | 1054 | ||
1037 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) | 1055 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) |
1038 | { | 1056 | { |
1039 | if (hid->inbuf) | 1057 | struct usbhid_device *usbhid = hid->driver_data; |
1040 | usb_buffer_free(dev, hid->bufsize, hid->inbuf, hid->inbuf_dma); | 1058 | |
1041 | if (hid->outbuf) | 1059 | if (usbhid->inbuf) |
1042 | usb_buffer_free(dev, hid->bufsize, hid->outbuf, hid->outbuf_dma); | 1060 | usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); |
1043 | if (hid->cr) | 1061 | if (usbhid->outbuf) |
1044 | usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma); | 1062 | usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); |
1045 | if (hid->ctrlbuf) | 1063 | if (usbhid->cr) |
1046 | usb_buffer_free(dev, hid->bufsize, hid->ctrlbuf, hid->ctrlbuf_dma); | 1064 | usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma); |
1065 | if (usbhid->ctrlbuf) | ||
1066 | usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); | ||
1047 | } | 1067 | } |
1048 | 1068 | ||
1049 | /* | 1069 | /* |
@@ -1069,6 +1089,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1069 | unsigned quirks = 0, rsize = 0; | 1089 | unsigned quirks = 0, rsize = 0; |
1070 | char *rdesc; | 1090 | char *rdesc; |
1071 | int n, len, insize = 0; | 1091 | int n, len, insize = 0; |
1092 | struct usbhid_device *usbhid; | ||
1072 | 1093 | ||
1073 | /* Ignore all Wacom devices */ | 1094 | /* Ignore all Wacom devices */ |
1074 | if (le16_to_cpu(dev->descriptor.idVendor) == USB_VENDOR_ID_WACOM) | 1095 | if (le16_to_cpu(dev->descriptor.idVendor) == USB_VENDOR_ID_WACOM) |
@@ -1138,13 +1159,19 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1138 | kfree(rdesc); | 1159 | kfree(rdesc); |
1139 | hid->quirks = quirks; | 1160 | hid->quirks = quirks; |
1140 | 1161 | ||
1141 | hid->bufsize = HID_MIN_BUFFER_SIZE; | 1162 | if (!(usbhid = kzalloc(sizeof(struct usbhid_device), GFP_KERNEL))) |
1142 | hid_find_max_report(hid, HID_INPUT_REPORT, &hid->bufsize); | 1163 | goto fail; |
1143 | hid_find_max_report(hid, HID_OUTPUT_REPORT, &hid->bufsize); | 1164 | |
1144 | hid_find_max_report(hid, HID_FEATURE_REPORT, &hid->bufsize); | 1165 | hid->driver_data = usbhid; |
1166 | usbhid->hid = hid; | ||
1167 | |||
1168 | usbhid->bufsize = HID_MIN_BUFFER_SIZE; | ||
1169 | hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize); | ||
1170 | hid_find_max_report(hid, HID_OUTPUT_REPORT, &usbhid->bufsize); | ||
1171 | hid_find_max_report(hid, HID_FEATURE_REPORT, &usbhid->bufsize); | ||
1145 | 1172 | ||
1146 | if (hid->bufsize > HID_MAX_BUFFER_SIZE) | 1173 | if (usbhid->bufsize > HID_MAX_BUFFER_SIZE) |
1147 | hid->bufsize = HID_MAX_BUFFER_SIZE; | 1174 | usbhid->bufsize = HID_MAX_BUFFER_SIZE; |
1148 | 1175 | ||
1149 | hid_find_max_report(hid, HID_INPUT_REPORT, &insize); | 1176 | hid_find_max_report(hid, HID_INPUT_REPORT, &insize); |
1150 | 1177 | ||
@@ -1173,47 +1200,47 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1173 | interval = hid_mousepoll_interval; | 1200 | interval = hid_mousepoll_interval; |
1174 | 1201 | ||
1175 | if (usb_endpoint_dir_in(endpoint)) { | 1202 | if (usb_endpoint_dir_in(endpoint)) { |
1176 | if (hid->urbin) | 1203 | if (usbhid->urbin) |
1177 | continue; | 1204 | continue; |
1178 | if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) | 1205 | if (!(usbhid->urbin = usb_alloc_urb(0, GFP_KERNEL))) |
1179 | goto fail; | 1206 | goto fail; |
1180 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 1207 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
1181 | usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, insize, | 1208 | usb_fill_int_urb(usbhid->urbin, dev, pipe, usbhid->inbuf, insize, |
1182 | hid_irq_in, hid, interval); | 1209 | hid_irq_in, hid, interval); |
1183 | hid->urbin->transfer_dma = hid->inbuf_dma; | 1210 | usbhid->urbin->transfer_dma = usbhid->inbuf_dma; |
1184 | hid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 1211 | usbhid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
1185 | } else { | 1212 | } else { |
1186 | if (hid->urbout) | 1213 | if (usbhid->urbout) |
1187 | continue; | 1214 | continue; |
1188 | if (!(hid->urbout = usb_alloc_urb(0, GFP_KERNEL))) | 1215 | if (!(usbhid->urbout = usb_alloc_urb(0, GFP_KERNEL))) |
1189 | goto fail; | 1216 | goto fail; |
1190 | pipe = usb_sndintpipe(dev, endpoint->bEndpointAddress); | 1217 | pipe = usb_sndintpipe(dev, endpoint->bEndpointAddress); |
1191 | usb_fill_int_urb(hid->urbout, dev, pipe, hid->outbuf, 0, | 1218 | usb_fill_int_urb(usbhid->urbout, dev, pipe, usbhid->outbuf, 0, |
1192 | hid_irq_out, hid, interval); | 1219 | hid_irq_out, hid, interval); |
1193 | hid->urbout->transfer_dma = hid->outbuf_dma; | 1220 | usbhid->urbout->transfer_dma = usbhid->outbuf_dma; |
1194 | hid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 1221 | usbhid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
1195 | } | 1222 | } |
1196 | } | 1223 | } |
1197 | 1224 | ||
1198 | if (!hid->urbin) { | 1225 | if (!usbhid->urbin) { |
1199 | err("couldn't find an input interrupt endpoint"); | 1226 | err("couldn't find an input interrupt endpoint"); |
1200 | goto fail; | 1227 | goto fail; |
1201 | } | 1228 | } |
1202 | 1229 | ||
1203 | init_waitqueue_head(&hid->wait); | 1230 | init_waitqueue_head(&hid->wait); |
1204 | 1231 | ||
1205 | INIT_WORK(&hid->reset_work, hid_reset); | 1232 | INIT_WORK(&usbhid->reset_work, hid_reset); |
1206 | setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid); | 1233 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); |
1207 | 1234 | ||
1208 | spin_lock_init(&hid->inlock); | 1235 | spin_lock_init(&usbhid->inlock); |
1209 | spin_lock_init(&hid->outlock); | 1236 | spin_lock_init(&usbhid->outlock); |
1210 | spin_lock_init(&hid->ctrllock); | 1237 | spin_lock_init(&usbhid->ctrllock); |
1211 | 1238 | ||
1212 | hid->version = le16_to_cpu(hdesc->bcdHID); | 1239 | hid->version = le16_to_cpu(hdesc->bcdHID); |
1213 | hid->country = hdesc->bCountryCode; | 1240 | hid->country = hdesc->bCountryCode; |
1214 | hid->dev = dev; | 1241 | hid->dev = &dev->dev; |
1215 | hid->intf = intf; | 1242 | usbhid->intf = intf; |
1216 | hid->ifnum = interface->desc.bInterfaceNumber; | 1243 | usbhid->ifnum = interface->desc.bInterfaceNumber; |
1217 | 1244 | ||
1218 | hid->name[0] = 0; | 1245 | hid->name[0] = 0; |
1219 | 1246 | ||
@@ -1245,15 +1272,15 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1245 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) | 1272 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) |
1246 | hid->uniq[0] = 0; | 1273 | hid->uniq[0] = 0; |
1247 | 1274 | ||
1248 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); | 1275 | usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
1249 | if (!hid->urbctrl) | 1276 | if (!usbhid->urbctrl) |
1250 | goto fail; | 1277 | goto fail; |
1251 | 1278 | ||
1252 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, | 1279 | usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr, |
1253 | hid->ctrlbuf, 1, hid_ctrl, hid); | 1280 | usbhid->ctrlbuf, 1, hid_ctrl, hid); |
1254 | hid->urbctrl->setup_dma = hid->cr_dma; | 1281 | usbhid->urbctrl->setup_dma = usbhid->cr_dma; |
1255 | hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; | 1282 | usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma; |
1256 | hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); | 1283 | usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
1257 | hid->hidinput_input_event = usb_hidinput_input_event; | 1284 | hid->hidinput_input_event = usb_hidinput_input_event; |
1258 | hid->hidinput_open = hidinput_open; | 1285 | hid->hidinput_open = hidinput_open; |
1259 | hid->hidinput_close = hidinput_close; | 1286 | hid->hidinput_close = hidinput_close; |
@@ -1261,9 +1288,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1261 | return hid; | 1288 | return hid; |
1262 | 1289 | ||
1263 | fail: | 1290 | fail: |
1264 | usb_free_urb(hid->urbin); | 1291 | usb_free_urb(usbhid->urbin); |
1265 | usb_free_urb(hid->urbout); | 1292 | usb_free_urb(usbhid->urbout); |
1266 | usb_free_urb(hid->urbctrl); | 1293 | usb_free_urb(usbhid->urbctrl); |
1267 | hid_free_buffers(dev, hid); | 1294 | hid_free_buffers(dev, hid); |
1268 | hid_free_device(hid); | 1295 | hid_free_device(hid); |
1269 | 1296 | ||
@@ -1273,18 +1300,21 @@ fail: | |||
1273 | static void hid_disconnect(struct usb_interface *intf) | 1300 | static void hid_disconnect(struct usb_interface *intf) |
1274 | { | 1301 | { |
1275 | struct hid_device *hid = usb_get_intfdata (intf); | 1302 | struct hid_device *hid = usb_get_intfdata (intf); |
1303 | struct usbhid_device *usbhid; | ||
1276 | 1304 | ||
1277 | if (!hid) | 1305 | if (!hid) |
1278 | return; | 1306 | return; |
1279 | 1307 | ||
1280 | spin_lock_irq(&hid->inlock); /* Sync with error handler */ | 1308 | usbhid = hid->driver_data; |
1309 | |||
1310 | spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ | ||
1281 | usb_set_intfdata(intf, NULL); | 1311 | usb_set_intfdata(intf, NULL); |
1282 | spin_unlock_irq(&hid->inlock); | 1312 | spin_unlock_irq(&usbhid->inlock); |
1283 | usb_kill_urb(hid->urbin); | 1313 | usb_kill_urb(usbhid->urbin); |
1284 | usb_kill_urb(hid->urbout); | 1314 | usb_kill_urb(usbhid->urbout); |
1285 | usb_kill_urb(hid->urbctrl); | 1315 | usb_kill_urb(usbhid->urbctrl); |
1286 | 1316 | ||
1287 | del_timer_sync(&hid->io_retry); | 1317 | del_timer_sync(&usbhid->io_retry); |
1288 | flush_scheduled_work(); | 1318 | flush_scheduled_work(); |
1289 | 1319 | ||
1290 | if (hid->claimed & HID_CLAIMED_INPUT) | 1320 | if (hid->claimed & HID_CLAIMED_INPUT) |
@@ -1292,11 +1322,11 @@ static void hid_disconnect(struct usb_interface *intf) | |||
1292 | if (hid->claimed & HID_CLAIMED_HIDDEV) | 1322 | if (hid->claimed & HID_CLAIMED_HIDDEV) |
1293 | hiddev_disconnect(hid); | 1323 | hiddev_disconnect(hid); |
1294 | 1324 | ||
1295 | usb_free_urb(hid->urbin); | 1325 | usb_free_urb(usbhid->urbin); |
1296 | usb_free_urb(hid->urbctrl); | 1326 | usb_free_urb(usbhid->urbctrl); |
1297 | usb_free_urb(hid->urbout); | 1327 | usb_free_urb(usbhid->urbout); |
1298 | 1328 | ||
1299 | hid_free_buffers(hid->dev, hid); | 1329 | hid_free_buffers(to_usb_device(hid->dev), hid); |
1300 | hid_free_device(hid); | 1330 | hid_free_device(hid); |
1301 | } | 1331 | } |
1302 | 1332 | ||
@@ -1313,7 +1343,7 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1313 | if (!(hid = usb_hid_configure(intf))) | 1343 | if (!(hid = usb_hid_configure(intf))) |
1314 | return -ENODEV; | 1344 | return -ENODEV; |
1315 | 1345 | ||
1316 | hid_init_reports(hid); | 1346 | usbhid_init_reports(hid); |
1317 | hid_dump_device(hid); | 1347 | hid_dump_device(hid); |
1318 | 1348 | ||
1319 | if (!hidinput_connect(hid)) | 1349 | if (!hidinput_connect(hid)) |
@@ -1329,6 +1359,13 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1329 | return -ENODEV; | 1359 | return -ENODEV; |
1330 | } | 1360 | } |
1331 | 1361 | ||
1362 | /* This only gets called when we are a single-input (most of the | ||
1363 | * time). IOW, not a HID_QUIRK_MULTI_INPUT. The hid_ff_init() is | ||
1364 | * only useful in this case, and not for multi-input quirks. */ | ||
1365 | if ((hid->claimed & HID_CLAIMED_INPUT) && | ||
1366 | !(hid->quirks & HID_QUIRK_MULTI_INPUT)) | ||
1367 | hid_ff_init(hid); | ||
1368 | |||
1332 | printk(KERN_INFO); | 1369 | printk(KERN_INFO); |
1333 | 1370 | ||
1334 | if (hid->claimed & HID_CLAIMED_INPUT) | 1371 | if (hid->claimed & HID_CLAIMED_INPUT) |
@@ -1359,12 +1396,13 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1359 | static int hid_suspend(struct usb_interface *intf, pm_message_t message) | 1396 | static int hid_suspend(struct usb_interface *intf, pm_message_t message) |
1360 | { | 1397 | { |
1361 | struct hid_device *hid = usb_get_intfdata (intf); | 1398 | struct hid_device *hid = usb_get_intfdata (intf); |
1399 | struct usbhid_device *usbhid = hid->driver_data; | ||
1362 | 1400 | ||
1363 | spin_lock_irq(&hid->inlock); /* Sync with error handler */ | 1401 | spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ |
1364 | set_bit(HID_SUSPENDED, &hid->iofl); | 1402 | set_bit(HID_SUSPENDED, &usbhid->iofl); |
1365 | spin_unlock_irq(&hid->inlock); | 1403 | spin_unlock_irq(&usbhid->inlock); |
1366 | del_timer(&hid->io_retry); | 1404 | del_timer(&usbhid->io_retry); |
1367 | usb_kill_urb(hid->urbin); | 1405 | usb_kill_urb(usbhid->urbin); |
1368 | dev_dbg(&intf->dev, "suspend\n"); | 1406 | dev_dbg(&intf->dev, "suspend\n"); |
1369 | return 0; | 1407 | return 0; |
1370 | } | 1408 | } |
@@ -1372,10 +1410,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message) | |||
1372 | static int hid_resume(struct usb_interface *intf) | 1410 | static int hid_resume(struct usb_interface *intf) |
1373 | { | 1411 | { |
1374 | struct hid_device *hid = usb_get_intfdata (intf); | 1412 | struct hid_device *hid = usb_get_intfdata (intf); |
1413 | struct usbhid_device *usbhid = hid->driver_data; | ||
1375 | int status; | 1414 | int status; |
1376 | 1415 | ||
1377 | clear_bit(HID_SUSPENDED, &hid->iofl); | 1416 | clear_bit(HID_SUSPENDED, &usbhid->iofl); |
1378 | hid->retry_delay = 0; | 1417 | usbhid->retry_delay = 0; |
1379 | status = hid_start_in(hid); | 1418 | status = hid_start_in(hid); |
1380 | dev_dbg(&intf->dev, "resume status %d\n", status); | 1419 | dev_dbg(&intf->dev, "resume status %d\n", status); |
1381 | return status; | 1420 | return status; |
diff --git a/drivers/usb/input/hid-ff.c b/drivers/usb/input/hid-ff.c index 7ecdafa8eb7b..f8f660ee3fac 100644 --- a/drivers/usb/input/hid-ff.c +++ b/drivers/usb/input/hid-ff.c | |||
@@ -70,8 +70,8 @@ static struct hid_ff_initializer inits[] = { | |||
70 | int hid_ff_init(struct hid_device* hid) | 70 | int hid_ff_init(struct hid_device* hid) |
71 | { | 71 | { |
72 | struct hid_ff_initializer *init; | 72 | struct hid_ff_initializer *init; |
73 | int vendor = le16_to_cpu(hid->dev->descriptor.idVendor); | 73 | int vendor = le16_to_cpu(to_usb_device(hid->dev)->descriptor.idVendor); |
74 | int product = le16_to_cpu(hid->dev->descriptor.idProduct); | 74 | int product = le16_to_cpu(to_usb_device(hid->dev)->descriptor.idProduct); |
75 | 75 | ||
76 | for (init = inits; init->idVendor; init++) | 76 | for (init = inits; init->idVendor; init++) |
77 | if (init->idVendor == vendor && init->idProduct == product) | 77 | if (init->idVendor == vendor && init->idProduct == product) |
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index e977ba3d17e0..e47466268565 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/input.h> | 30 | #include <linux/input.h> |
31 | #include <linux/usb.h> | 31 | #include <linux/usb.h> |
32 | #include <linux/hid.h> | 32 | #include <linux/hid.h> |
33 | #include "usbhid.h" | ||
33 | 34 | ||
34 | struct device_type { | 35 | struct device_type { |
35 | u16 idVendor; | 36 | u16 idVendor; |
@@ -75,7 +76,7 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef | |||
75 | report->field[0]->value[2] = x; | 76 | report->field[0]->value[2] = x; |
76 | report->field[0]->value[3] = y; | 77 | report->field[0]->value[3] = y; |
77 | dbg("(x, y)=(%04x, %04x)", x, y); | 78 | dbg("(x, y)=(%04x, %04x)", x, y); |
78 | hid_submit_report(hid, report, USB_DIR_OUT); | 79 | usbhid_submit_report(hid, report, USB_DIR_OUT); |
79 | break; | 80 | break; |
80 | 81 | ||
81 | case FF_RUMBLE: | 82 | case FF_RUMBLE: |
@@ -90,7 +91,7 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef | |||
90 | report->field[0]->value[2] = left; | 91 | report->field[0]->value[2] = left; |
91 | report->field[0]->value[3] = right; | 92 | report->field[0]->value[3] = right; |
92 | dbg("(left, right)=(%04x, %04x)", left, right); | 93 | dbg("(left, right)=(%04x, %04x)", left, right); |
93 | hid_submit_report(hid, report, USB_DIR_OUT); | 94 | usbhid_submit_report(hid, report, USB_DIR_OUT); |
94 | break; | 95 | break; |
95 | } | 96 | } |
96 | return 0; | 97 | return 0; |
diff --git a/drivers/usb/input/hid-pidff.c b/drivers/usb/input/hid-pidff.c index b4caea3864e3..cbd2d53fefff 100644 --- a/drivers/usb/input/hid-pidff.c +++ b/drivers/usb/input/hid-pidff.c | |||
@@ -262,7 +262,7 @@ static void pidff_set_envelope_report(struct pidff_device *pidff, | |||
262 | debug("attack %u => %d", envelope->attack_level, | 262 | debug("attack %u => %d", envelope->attack_level, |
263 | pidff->set_envelope[PID_ATTACK_LEVEL].value[0]); | 263 | pidff->set_envelope[PID_ATTACK_LEVEL].value[0]); |
264 | 264 | ||
265 | hid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE], | 265 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE], |
266 | USB_DIR_OUT); | 266 | USB_DIR_OUT); |
267 | } | 267 | } |
268 | 268 | ||
@@ -289,7 +289,7 @@ static void pidff_set_constant_force_report(struct pidff_device *pidff, | |||
289 | pidff_set_signed(&pidff->set_constant[PID_MAGNITUDE], | 289 | pidff_set_signed(&pidff->set_constant[PID_MAGNITUDE], |
290 | effect->u.constant.level); | 290 | effect->u.constant.level); |
291 | 291 | ||
292 | hid_submit_report(pidff->hid, pidff->reports[PID_SET_CONSTANT], | 292 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONSTANT], |
293 | USB_DIR_OUT); | 293 | USB_DIR_OUT); |
294 | } | 294 | } |
295 | 295 | ||
@@ -324,7 +324,7 @@ static void pidff_set_effect_report(struct pidff_device *pidff, | |||
324 | pidff->effect_direction); | 324 | pidff->effect_direction); |
325 | pidff->set_effect[PID_START_DELAY].value[0] = effect->replay.delay; | 325 | pidff->set_effect[PID_START_DELAY].value[0] = effect->replay.delay; |
326 | 326 | ||
327 | hid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT], | 327 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT], |
328 | USB_DIR_OUT); | 328 | USB_DIR_OUT); |
329 | } | 329 | } |
330 | 330 | ||
@@ -356,7 +356,7 @@ static void pidff_set_periodic_report(struct pidff_device *pidff, | |||
356 | pidff_set(&pidff->set_periodic[PID_PHASE], effect->u.periodic.phase); | 356 | pidff_set(&pidff->set_periodic[PID_PHASE], effect->u.periodic.phase); |
357 | pidff->set_periodic[PID_PERIOD].value[0] = effect->u.periodic.period; | 357 | pidff->set_periodic[PID_PERIOD].value[0] = effect->u.periodic.period; |
358 | 358 | ||
359 | hid_submit_report(pidff->hid, pidff->reports[PID_SET_PERIODIC], | 359 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_PERIODIC], |
360 | USB_DIR_OUT); | 360 | USB_DIR_OUT); |
361 | 361 | ||
362 | } | 362 | } |
@@ -398,8 +398,8 @@ static void pidff_set_condition_report(struct pidff_device *pidff, | |||
398 | effect->u.condition[i].left_saturation); | 398 | effect->u.condition[i].left_saturation); |
399 | pidff_set(&pidff->set_condition[PID_DEAD_BAND], | 399 | pidff_set(&pidff->set_condition[PID_DEAD_BAND], |
400 | effect->u.condition[i].deadband); | 400 | effect->u.condition[i].deadband); |
401 | hid_wait_io(pidff->hid); | 401 | usbhid_wait_io(pidff->hid); |
402 | hid_submit_report(pidff->hid, pidff->reports[PID_SET_CONDITION], | 402 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONDITION], |
403 | USB_DIR_OUT); | 403 | USB_DIR_OUT); |
404 | } | 404 | } |
405 | } | 405 | } |
@@ -440,7 +440,7 @@ static void pidff_set_ramp_force_report(struct pidff_device *pidff, | |||
440 | effect->u.ramp.start_level); | 440 | effect->u.ramp.start_level); |
441 | pidff_set_signed(&pidff->set_ramp[PID_RAMP_END], | 441 | pidff_set_signed(&pidff->set_ramp[PID_RAMP_END], |
442 | effect->u.ramp.end_level); | 442 | effect->u.ramp.end_level); |
443 | hid_submit_report(pidff->hid, pidff->reports[PID_SET_RAMP], | 443 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_RAMP], |
444 | USB_DIR_OUT); | 444 | USB_DIR_OUT); |
445 | } | 445 | } |
446 | 446 | ||
@@ -465,19 +465,19 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum) | |||
465 | int j; | 465 | int j; |
466 | 466 | ||
467 | pidff->create_new_effect_type->value[0] = efnum; | 467 | pidff->create_new_effect_type->value[0] = efnum; |
468 | hid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT], | 468 | usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT], |
469 | USB_DIR_OUT); | 469 | USB_DIR_OUT); |
470 | debug("create_new_effect sent, type: %d", efnum); | 470 | debug("create_new_effect sent, type: %d", efnum); |
471 | 471 | ||
472 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; | 472 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; |
473 | pidff->block_load_status->value[0] = 0; | 473 | pidff->block_load_status->value[0] = 0; |
474 | hid_wait_io(pidff->hid); | 474 | usbhid_wait_io(pidff->hid); |
475 | 475 | ||
476 | for (j = 0; j < 60; j++) { | 476 | for (j = 0; j < 60; j++) { |
477 | debug("pid_block_load requested"); | 477 | debug("pid_block_load requested"); |
478 | hid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD], | 478 | usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD], |
479 | USB_DIR_IN); | 479 | USB_DIR_IN); |
480 | hid_wait_io(pidff->hid); | 480 | usbhid_wait_io(pidff->hid); |
481 | if (pidff->block_load_status->value[0] == | 481 | if (pidff->block_load_status->value[0] == |
482 | pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { | 482 | pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { |
483 | debug("device reported free memory: %d bytes", | 483 | debug("device reported free memory: %d bytes", |
@@ -513,8 +513,8 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n) | |||
513 | pidff->effect_operation[PID_LOOP_COUNT].value[0] = n; | 513 | pidff->effect_operation[PID_LOOP_COUNT].value[0] = n; |
514 | } | 514 | } |
515 | 515 | ||
516 | hid_wait_io(pidff->hid); | 516 | usbhid_wait_io(pidff->hid); |
517 | hid_submit_report(pidff->hid, pidff->reports[PID_EFFECT_OPERATION], | 517 | usbhid_submit_report(pidff->hid, pidff->reports[PID_EFFECT_OPERATION], |
518 | USB_DIR_OUT); | 518 | USB_DIR_OUT); |
519 | } | 519 | } |
520 | 520 | ||
@@ -536,7 +536,7 @@ static int pidff_playback(struct input_dev *dev, int effect_id, int value) | |||
536 | static void pidff_erase_pid(struct pidff_device *pidff, int pid_id) | 536 | static void pidff_erase_pid(struct pidff_device *pidff, int pid_id) |
537 | { | 537 | { |
538 | pidff->block_free[PID_EFFECT_BLOCK_INDEX].value[0] = pid_id; | 538 | pidff->block_free[PID_EFFECT_BLOCK_INDEX].value[0] = pid_id; |
539 | hid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_FREE], | 539 | usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_FREE], |
540 | USB_DIR_OUT); | 540 | USB_DIR_OUT); |
541 | } | 541 | } |
542 | 542 | ||
@@ -716,7 +716,7 @@ static void pidff_set_gain(struct input_dev *dev, u16 gain) | |||
716 | struct pidff_device *pidff = dev->ff->private; | 716 | struct pidff_device *pidff = dev->ff->private; |
717 | 717 | ||
718 | pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], gain); | 718 | pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], gain); |
719 | hid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN], | 719 | usbhid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN], |
720 | USB_DIR_OUT); | 720 | USB_DIR_OUT); |
721 | } | 721 | } |
722 | 722 | ||
@@ -741,7 +741,7 @@ static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude) | |||
741 | pidff_set(&pidff->set_effect[PID_GAIN], magnitude); | 741 | pidff_set(&pidff->set_effect[PID_GAIN], magnitude); |
742 | pidff->set_effect[PID_START_DELAY].value[0] = 0; | 742 | pidff->set_effect[PID_START_DELAY].value[0] = 0; |
743 | 743 | ||
744 | hid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT], | 744 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT], |
745 | USB_DIR_OUT); | 745 | USB_DIR_OUT); |
746 | } | 746 | } |
747 | 747 | ||
@@ -1165,19 +1165,19 @@ static void pidff_reset(struct pidff_device *pidff) | |||
1165 | 1165 | ||
1166 | pidff->device_control->value[0] = pidff->control_id[PID_RESET]; | 1166 | pidff->device_control->value[0] = pidff->control_id[PID_RESET]; |
1167 | /* We reset twice as sometimes hid_wait_io isn't waiting long enough */ | 1167 | /* We reset twice as sometimes hid_wait_io isn't waiting long enough */ |
1168 | hid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); | 1168 | usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); |
1169 | hid_wait_io(hid); | 1169 | usbhid_wait_io(hid); |
1170 | hid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); | 1170 | usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); |
1171 | hid_wait_io(hid); | 1171 | usbhid_wait_io(hid); |
1172 | 1172 | ||
1173 | pidff->device_control->value[0] = | 1173 | pidff->device_control->value[0] = |
1174 | pidff->control_id[PID_ENABLE_ACTUATORS]; | 1174 | pidff->control_id[PID_ENABLE_ACTUATORS]; |
1175 | hid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); | 1175 | usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); |
1176 | hid_wait_io(hid); | 1176 | usbhid_wait_io(hid); |
1177 | 1177 | ||
1178 | /* pool report is sometimes messed up, refetch it */ | 1178 | /* pool report is sometimes messed up, refetch it */ |
1179 | hid_submit_report(hid, pidff->reports[PID_POOL], USB_DIR_IN); | 1179 | usbhid_submit_report(hid, pidff->reports[PID_POOL], USB_DIR_IN); |
1180 | hid_wait_io(hid); | 1180 | usbhid_wait_io(hid); |
1181 | 1181 | ||
1182 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { | 1182 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { |
1183 | int sim_effects = pidff->pool[PID_SIMULTANEOUS_MAX].value[0]; | 1183 | int sim_effects = pidff->pool[PID_SIMULTANEOUS_MAX].value[0]; |
@@ -1189,9 +1189,9 @@ static void pidff_reset(struct pidff_device *pidff) | |||
1189 | break; | 1189 | break; |
1190 | } | 1190 | } |
1191 | debug("pid_pool requested again"); | 1191 | debug("pid_pool requested again"); |
1192 | hid_submit_report(hid, pidff->reports[PID_POOL], | 1192 | usbhid_submit_report(hid, pidff->reports[PID_POOL], |
1193 | USB_DIR_IN); | 1193 | USB_DIR_IN); |
1194 | hid_wait_io(hid); | 1194 | usbhid_wait_io(hid); |
1195 | } | 1195 | } |
1196 | } | 1196 | } |
1197 | } | 1197 | } |
@@ -1277,7 +1277,7 @@ int hid_pidff_init(struct hid_device *hid) | |||
1277 | 1277 | ||
1278 | if (test_bit(FF_GAIN, dev->ffbit)) { | 1278 | if (test_bit(FF_GAIN, dev->ffbit)) { |
1279 | pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff); | 1279 | pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff); |
1280 | hid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN], | 1280 | usbhid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN], |
1281 | USB_DIR_OUT); | 1281 | USB_DIR_OUT); |
1282 | } | 1282 | } |
1283 | 1283 | ||
diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c index 1cd1418ad6ac..ab67331620d0 100644 --- a/drivers/usb/input/hid-tmff.c +++ b/drivers/usb/input/hid-tmff.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/usb.h> | 33 | #include <linux/usb.h> |
34 | 34 | ||
35 | #include <linux/hid.h> | 35 | #include <linux/hid.h> |
36 | #include "usbhid.h" | ||
36 | 37 | ||
37 | /* Usages for thrustmaster devices I know about */ | 38 | /* Usages for thrustmaster devices I know about */ |
38 | #define THRUSTMASTER_USAGE_RUMBLE_LR (HID_UP_GENDESK | 0xbb) | 39 | #define THRUSTMASTER_USAGE_RUMBLE_LR (HID_UP_GENDESK | 0xbb) |
@@ -70,7 +71,7 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef | |||
70 | tmff->rumble->value[0] = left; | 71 | tmff->rumble->value[0] = left; |
71 | tmff->rumble->value[1] = right; | 72 | tmff->rumble->value[1] = right; |
72 | dbg("(left,right)=(%08x, %08x)", left, right); | 73 | dbg("(left,right)=(%08x, %08x)", left, right); |
73 | hid_submit_report(hid, tmff->report, USB_DIR_OUT); | 74 | usbhid_submit_report(hid, tmff->report, USB_DIR_OUT); |
74 | 75 | ||
75 | return 0; | 76 | return 0; |
76 | } | 77 | } |
diff --git a/drivers/usb/input/hid-zpff.c b/drivers/usb/input/hid-zpff.c index af1bfae39dce..7bd8238ca212 100644 --- a/drivers/usb/input/hid-zpff.c +++ b/drivers/usb/input/hid-zpff.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/input.h> | 28 | #include <linux/input.h> |
29 | #include <linux/usb.h> | 29 | #include <linux/usb.h> |
30 | #include <linux/hid.h> | 30 | #include <linux/hid.h> |
31 | #include "usbhid.h" | ||
31 | 32 | ||
32 | struct zpff_device { | 33 | struct zpff_device { |
33 | struct hid_report *report; | 34 | struct hid_report *report; |
@@ -56,7 +57,7 @@ static int hid_zpff_play(struct input_dev *dev, void *data, | |||
56 | zpff->report->field[2]->value[0] = left; | 57 | zpff->report->field[2]->value[0] = left; |
57 | zpff->report->field[3]->value[0] = right; | 58 | zpff->report->field[3]->value[0] = right; |
58 | debug("running with 0x%02x 0x%02x", left, right); | 59 | debug("running with 0x%02x 0x%02x", left, right); |
59 | hid_submit_report(hid, zpff->report, USB_DIR_OUT); | 60 | usbhid_submit_report(hid, zpff->report, USB_DIR_OUT); |
60 | 61 | ||
61 | return 0; | 62 | return 0; |
62 | } | 63 | } |
@@ -101,7 +102,7 @@ int hid_zpff_init(struct hid_device *hid) | |||
101 | zpff->report->field[1]->value[0] = 0x02; | 102 | zpff->report->field[1]->value[0] = 0x02; |
102 | zpff->report->field[2]->value[0] = 0x00; | 103 | zpff->report->field[2]->value[0] = 0x00; |
103 | zpff->report->field[3]->value[0] = 0x00; | 104 | zpff->report->field[3]->value[0] = 0x00; |
104 | hid_submit_report(hid, zpff->report, USB_DIR_OUT); | 105 | usbhid_submit_report(hid, zpff->report, USB_DIR_OUT); |
105 | 106 | ||
106 | printk(KERN_INFO "Force feedback for Zeroplus based devices by " | 107 | printk(KERN_INFO "Force feedback for Zeroplus based devices by " |
107 | "Anssi Hannula <anssi.hannula@gmail.com>\n"); | 108 | "Anssi Hannula <anssi.hannula@gmail.com>\n"); |
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 07d7996575cd..0c2647eb9eec 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c | |||
@@ -240,7 +240,7 @@ static int hiddev_release(struct inode * inode, struct file * file) | |||
240 | 240 | ||
241 | if (!--list->hiddev->open) { | 241 | if (!--list->hiddev->open) { |
242 | if (list->hiddev->exist) | 242 | if (list->hiddev->exist) |
243 | hid_close(list->hiddev->hid); | 243 | usbhid_close(list->hiddev->hid); |
244 | else | 244 | else |
245 | kfree(list->hiddev); | 245 | kfree(list->hiddev); |
246 | } | 246 | } |
@@ -271,7 +271,7 @@ static int hiddev_open(struct inode *inode, struct file *file) | |||
271 | 271 | ||
272 | if (!list->hiddev->open++) | 272 | if (!list->hiddev->open++) |
273 | if (list->hiddev->exist) | 273 | if (list->hiddev->exist) |
274 | hid_open(hiddev_table[i]->hid); | 274 | usbhid_open(hiddev_table[i]->hid); |
275 | 275 | ||
276 | return 0; | 276 | return 0; |
277 | } | 277 | } |
@@ -383,7 +383,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
383 | struct hiddev_list *list = file->private_data; | 383 | struct hiddev_list *list = file->private_data; |
384 | struct hiddev *hiddev = list->hiddev; | 384 | struct hiddev *hiddev = list->hiddev; |
385 | struct hid_device *hid = hiddev->hid; | 385 | struct hid_device *hid = hiddev->hid; |
386 | struct usb_device *dev = hid->dev; | 386 | struct usb_device *dev = to_usb_device(hid->dev); |
387 | struct hiddev_collection_info cinfo; | 387 | struct hiddev_collection_info cinfo; |
388 | struct hiddev_report_info rinfo; | 388 | struct hiddev_report_info rinfo; |
389 | struct hiddev_field_info finfo; | 389 | struct hiddev_field_info finfo; |
@@ -392,6 +392,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
392 | struct hiddev_devinfo dinfo; | 392 | struct hiddev_devinfo dinfo; |
393 | struct hid_report *report; | 393 | struct hid_report *report; |
394 | struct hid_field *field; | 394 | struct hid_field *field; |
395 | struct usbhid_device *usbhid = hid->driver_data; | ||
395 | void __user *user_arg = (void __user *)arg; | 396 | void __user *user_arg = (void __user *)arg; |
396 | int i; | 397 | int i; |
397 | 398 | ||
@@ -421,7 +422,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
421 | dinfo.bustype = BUS_USB; | 422 | dinfo.bustype = BUS_USB; |
422 | dinfo.busnum = dev->bus->busnum; | 423 | dinfo.busnum = dev->bus->busnum; |
423 | dinfo.devnum = dev->devnum; | 424 | dinfo.devnum = dev->devnum; |
424 | dinfo.ifnum = hid->ifnum; | 425 | dinfo.ifnum = usbhid->ifnum; |
425 | dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor); | 426 | dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor); |
426 | dinfo.product = le16_to_cpu(dev->descriptor.idProduct); | 427 | dinfo.product = le16_to_cpu(dev->descriptor.idProduct); |
427 | dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice); | 428 | dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice); |
@@ -480,7 +481,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
480 | } | 481 | } |
481 | 482 | ||
482 | case HIDIOCINITREPORT: | 483 | case HIDIOCINITREPORT: |
483 | hid_init_reports(hid); | 484 | usbhid_init_reports(hid); |
484 | 485 | ||
485 | return 0; | 486 | return 0; |
486 | 487 | ||
@@ -494,8 +495,8 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
494 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 495 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) |
495 | return -EINVAL; | 496 | return -EINVAL; |
496 | 497 | ||
497 | hid_submit_report(hid, report, USB_DIR_IN); | 498 | usbhid_submit_report(hid, report, USB_DIR_IN); |
498 | hid_wait_io(hid); | 499 | usbhid_wait_io(hid); |
499 | 500 | ||
500 | return 0; | 501 | return 0; |
501 | 502 | ||
@@ -509,8 +510,8 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
509 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 510 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) |
510 | return -EINVAL; | 511 | return -EINVAL; |
511 | 512 | ||
512 | hid_submit_report(hid, report, USB_DIR_OUT); | 513 | usbhid_submit_report(hid, report, USB_DIR_OUT); |
513 | hid_wait_io(hid); | 514 | usbhid_wait_io(hid); |
514 | 515 | ||
515 | return 0; | 516 | return 0; |
516 | 517 | ||
@@ -746,6 +747,7 @@ static struct usb_class_driver hiddev_class = { | |||
746 | int hiddev_connect(struct hid_device *hid) | 747 | int hiddev_connect(struct hid_device *hid) |
747 | { | 748 | { |
748 | struct hiddev *hiddev; | 749 | struct hiddev *hiddev; |
750 | struct usbhid_device *usbhid = hid->driver_data; | ||
749 | int i; | 751 | int i; |
750 | int retval; | 752 | int retval; |
751 | 753 | ||
@@ -761,7 +763,7 @@ int hiddev_connect(struct hid_device *hid) | |||
761 | if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL))) | 763 | if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL))) |
762 | return -1; | 764 | return -1; |
763 | 765 | ||
764 | retval = usb_register_dev(hid->intf, &hiddev_class); | 766 | retval = usb_register_dev(usbhid->intf, &hiddev_class); |
765 | if (retval) { | 767 | if (retval) { |
766 | err("Not able to get a minor for this device."); | 768 | err("Not able to get a minor for this device."); |
767 | kfree(hiddev); | 769 | kfree(hiddev); |
@@ -773,10 +775,10 @@ int hiddev_connect(struct hid_device *hid) | |||
773 | hiddev->hid = hid; | 775 | hiddev->hid = hid; |
774 | hiddev->exist = 1; | 776 | hiddev->exist = 1; |
775 | 777 | ||
776 | hid->minor = hid->intf->minor; | 778 | hid->minor = usbhid->intf->minor; |
777 | hid->hiddev = hiddev; | 779 | hid->hiddev = hiddev; |
778 | 780 | ||
779 | hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; | 781 | hiddev_table[usbhid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; |
780 | 782 | ||
781 | return 0; | 783 | return 0; |
782 | } | 784 | } |
@@ -789,14 +791,15 @@ static struct usb_class_driver hiddev_class; | |||
789 | void hiddev_disconnect(struct hid_device *hid) | 791 | void hiddev_disconnect(struct hid_device *hid) |
790 | { | 792 | { |
791 | struct hiddev *hiddev = hid->hiddev; | 793 | struct hiddev *hiddev = hid->hiddev; |
794 | struct usbhid_device *usbhid = hid->driver_data; | ||
792 | 795 | ||
793 | hiddev->exist = 0; | 796 | hiddev->exist = 0; |
794 | 797 | ||
795 | hiddev_table[hiddev->hid->minor - HIDDEV_MINOR_BASE] = NULL; | 798 | hiddev_table[hiddev->hid->minor - HIDDEV_MINOR_BASE] = NULL; |
796 | usb_deregister_dev(hiddev->hid->intf, &hiddev_class); | 799 | usb_deregister_dev(usbhid->intf, &hiddev_class); |
797 | 800 | ||
798 | if (hiddev->open) { | 801 | if (hiddev->open) { |
799 | hid_close(hiddev->hid); | 802 | usbhid_close(hiddev->hid); |
800 | wake_up_interruptible(&hiddev->wait); | 803 | wake_up_interruptible(&hiddev->wait); |
801 | } else { | 804 | } else { |
802 | kfree(hiddev); | 805 | kfree(hiddev); |
diff --git a/drivers/usb/input/usbhid.h b/drivers/usb/input/usbhid.h new file mode 100644 index 000000000000..830107e5251f --- /dev/null +++ b/drivers/usb/input/usbhid.h | |||
@@ -0,0 +1,84 @@ | |||
1 | #ifndef __USBHID_H | ||
2 | #define __USBHID_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (c) 1999 Andreas Gal | ||
6 | * Copyright (c) 2000-2001 Vojtech Pavlik | ||
7 | * Copyright (c) 2006 Jiri Kosina | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #include <linux/types.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/list.h> | ||
30 | #include <linux/timer.h> | ||
31 | #include <linux/workqueue.h> | ||
32 | #include <linux/input.h> | ||
33 | |||
34 | /* API provided by hid-core.c for USB HID drivers */ | ||
35 | int usbhid_wait_io(struct hid_device* hid); | ||
36 | void usbhid_close(struct hid_device *hid); | ||
37 | int usbhid_open(struct hid_device *hid); | ||
38 | void usbhid_init_reports(struct hid_device *hid); | ||
39 | void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir); | ||
40 | |||
41 | /* | ||
42 | * USB-specific HID struct, to be pointed to | ||
43 | * from struct hid_device->driver_data | ||
44 | */ | ||
45 | |||
46 | struct usbhid_device { | ||
47 | struct hid_device *hid; /* pointer to corresponding HID dev */ | ||
48 | |||
49 | struct usb_interface *intf; /* USB interface */ | ||
50 | int ifnum; /* USB interface number */ | ||
51 | |||
52 | unsigned int bufsize; /* URB buffer size */ | ||
53 | |||
54 | struct urb *urbin; /* Input URB */ | ||
55 | char *inbuf; /* Input buffer */ | ||
56 | dma_addr_t inbuf_dma; /* Input buffer dma */ | ||
57 | spinlock_t inlock; /* Input fifo spinlock */ | ||
58 | |||
59 | struct urb *urbctrl; /* Control URB */ | ||
60 | struct usb_ctrlrequest *cr; /* Control request struct */ | ||
61 | dma_addr_t cr_dma; /* Control request struct dma */ | ||
62 | struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */ | ||
63 | unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */ | ||
64 | char *ctrlbuf; /* Control buffer */ | ||
65 | dma_addr_t ctrlbuf_dma; /* Control buffer dma */ | ||
66 | spinlock_t ctrllock; /* Control fifo spinlock */ | ||
67 | |||
68 | struct urb *urbout; /* Output URB */ | ||
69 | struct hid_report *out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */ | ||
70 | unsigned char outhead, outtail; /* Output pipe fifo head & tail */ | ||
71 | char *outbuf; /* Output buffer */ | ||
72 | dma_addr_t outbuf_dma; /* Output buffer dma */ | ||
73 | spinlock_t outlock; /* Output fifo spinlock */ | ||
74 | |||
75 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ | ||
76 | struct timer_list io_retry; /* Retry timer */ | ||
77 | unsigned long stop_retry; /* Time to give up, in jiffies */ | ||
78 | unsigned int retry_delay; /* Delay length in ms */ | ||
79 | struct work_struct reset_work; /* Task context for resets */ | ||
80 | |||
81 | }; | ||
82 | |||
83 | #endif | ||
84 | |||