diff options
Diffstat (limited to 'drivers/usb/input/xpad.c')
-rw-r--r-- | drivers/usb/input/xpad.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index e4bc76ebc835..735723912950 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c | |||
@@ -267,7 +267,7 @@ exit: | |||
267 | 267 | ||
268 | static int xpad_open (struct input_dev *dev) | 268 | static int xpad_open (struct input_dev *dev) |
269 | { | 269 | { |
270 | struct usb_xpad *xpad = dev->private; | 270 | struct usb_xpad *xpad = input_get_drvdata(dev); |
271 | 271 | ||
272 | xpad->irq_in->dev = xpad->udev; | 272 | xpad->irq_in->dev = xpad->udev; |
273 | if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) | 273 | if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) |
@@ -278,7 +278,7 @@ static int xpad_open (struct input_dev *dev) | |||
278 | 278 | ||
279 | static void xpad_close (struct input_dev *dev) | 279 | static void xpad_close (struct input_dev *dev) |
280 | { | 280 | { |
281 | struct usb_xpad *xpad = dev->private; | 281 | struct usb_xpad *xpad = input_get_drvdata(dev); |
282 | 282 | ||
283 | usb_kill_urb(xpad->irq_in); | 283 | usb_kill_urb(xpad->irq_in); |
284 | } | 284 | } |
@@ -312,6 +312,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
312 | struct input_dev *input_dev; | 312 | struct input_dev *input_dev; |
313 | struct usb_endpoint_descriptor *ep_irq_in; | 313 | struct usb_endpoint_descriptor *ep_irq_in; |
314 | int i; | 314 | int i; |
315 | int error = -ENOMEM; | ||
315 | 316 | ||
316 | for (i = 0; xpad_device[i].idVendor; i++) { | 317 | for (i = 0; xpad_device[i].idVendor; i++) { |
317 | if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && | 318 | if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && |
@@ -344,8 +345,10 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
344 | input_dev->name = xpad_device[i].name; | 345 | input_dev->name = xpad_device[i].name; |
345 | input_dev->phys = xpad->phys; | 346 | input_dev->phys = xpad->phys; |
346 | usb_to_input_id(udev, &input_dev->id); | 347 | usb_to_input_id(udev, &input_dev->id); |
347 | input_dev->cdev.dev = &intf->dev; | 348 | input_dev->dev.parent = &intf->dev; |
348 | input_dev->private = xpad; | 349 | |
350 | input_set_drvdata(input_dev, xpad); | ||
351 | |||
349 | input_dev->open = xpad_open; | 352 | input_dev->open = xpad_open; |
350 | input_dev->close = xpad_close; | 353 | input_dev->close = xpad_close; |
351 | 354 | ||
@@ -373,15 +376,18 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
373 | xpad->irq_in->transfer_dma = xpad->idata_dma; | 376 | xpad->irq_in->transfer_dma = xpad->idata_dma; |
374 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 377 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
375 | 378 | ||
376 | input_register_device(xpad->dev); | 379 | error = input_register_device(xpad->dev); |
380 | if (error) | ||
381 | goto fail3; | ||
377 | 382 | ||
378 | usb_set_intfdata(intf, xpad); | 383 | usb_set_intfdata(intf, xpad); |
379 | return 0; | 384 | return 0; |
380 | 385 | ||
381 | fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | 386 | fail3: usb_free_urb(xpad->irq_in); |
382 | fail1: input_free_device(input_dev); | 387 | fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); |
388 | fail1: input_free_device(input_dev); | ||
383 | kfree(xpad); | 389 | kfree(xpad); |
384 | return -ENOMEM; | 390 | return error; |
385 | 391 | ||
386 | } | 392 | } |
387 | 393 | ||