aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/usbhid/hiddev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/usbhid/hiddev.c')
-rw-r--r--drivers/hid/usbhid/hiddev.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 254a003af048..0a29c51114aa 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -266,13 +266,15 @@ static int hiddev_open(struct inode *inode, struct file *file)
266{ 266{
267 struct hiddev_list *list; 267 struct hiddev_list *list;
268 struct usb_interface *intf; 268 struct usb_interface *intf;
269 struct hid_device *hid;
269 struct hiddev *hiddev; 270 struct hiddev *hiddev;
270 int res; 271 int res;
271 272
272 intf = usb_find_interface(&hiddev_driver, iminor(inode)); 273 intf = usb_find_interface(&hiddev_driver, iminor(inode));
273 if (!intf) 274 if (!intf)
274 return -ENODEV; 275 return -ENODEV;
275 hiddev = usb_get_intfdata(intf); 276 hid = usb_get_intfdata(intf);
277 hiddev = hid->hiddev;
276 278
277 if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL))) 279 if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
278 return -ENOMEM; 280 return -ENOMEM;
@@ -587,7 +589,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
587 struct hiddev_list *list = file->private_data; 589 struct hiddev_list *list = file->private_data;
588 struct hiddev *hiddev = list->hiddev; 590 struct hiddev *hiddev = list->hiddev;
589 struct hid_device *hid = hiddev->hid; 591 struct hid_device *hid = hiddev->hid;
590 struct usb_device *dev = hid_to_usb_dev(hid); 592 struct usb_device *dev;
591 struct hiddev_collection_info cinfo; 593 struct hiddev_collection_info cinfo;
592 struct hiddev_report_info rinfo; 594 struct hiddev_report_info rinfo;
593 struct hiddev_field_info finfo; 595 struct hiddev_field_info finfo;
@@ -601,9 +603,11 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
601 /* Called without BKL by compat methods so no BKL taken */ 603 /* Called without BKL by compat methods so no BKL taken */
602 604
603 /* FIXME: Who or what stop this racing with a disconnect ?? */ 605 /* FIXME: Who or what stop this racing with a disconnect ?? */
604 if (!hiddev->exist) 606 if (!hiddev->exist || !hid)
605 return -EIO; 607 return -EIO;
606 608
609 dev = hid_to_usb_dev(hid);
610
607 switch (cmd) { 611 switch (cmd) {
608 612
609 case HIDIOCGVERSION: 613 case HIDIOCGVERSION:
@@ -888,7 +892,6 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
888 hid->hiddev = hiddev; 892 hid->hiddev = hiddev;
889 hiddev->hid = hid; 893 hiddev->hid = hid;
890 hiddev->exist = 1; 894 hiddev->exist = 1;
891 usb_set_intfdata(usbhid->intf, usbhid);
892 retval = usb_register_dev(usbhid->intf, &hiddev_class); 895 retval = usb_register_dev(usbhid->intf, &hiddev_class);
893 if (retval) { 896 if (retval) {
894 err_hid("Not able to get a minor for this device."); 897 err_hid("Not able to get a minor for this device.");