aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/hiddev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input/hiddev.c')
-rw-r--r--drivers/usb/input/hiddev.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index 96b7c9067951..4c13331b5f41 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -95,7 +95,7 @@ hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
95 return NULL; 95 return NULL;
96 rinfo->report_id = ((struct hid_report *) list)->id; 96 rinfo->report_id = ((struct hid_report *) list)->id;
97 break; 97 break;
98 98
99 case HID_REPORT_ID_NEXT: 99 case HID_REPORT_ID_NEXT:
100 list = (struct list_head *) 100 list = (struct list_head *)
101 report_enum->report_id_hash[rinfo->report_id & HID_REPORT_ID_MASK]; 101 report_enum->report_id_hash[rinfo->report_id & HID_REPORT_ID_MASK];
@@ -106,7 +106,7 @@ hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
106 return NULL; 106 return NULL;
107 rinfo->report_id = ((struct hid_report *) list)->id; 107 rinfo->report_id = ((struct hid_report *) list)->id;
108 break; 108 break;
109 109
110 default: 110 default:
111 return NULL; 111 return NULL;
112 } 112 }
@@ -158,7 +158,7 @@ static void hiddev_send_event(struct hid_device *hid,
158 if (uref->field_index != HID_FIELD_INDEX_NONE || 158 if (uref->field_index != HID_FIELD_INDEX_NONE ||
159 (list->flags & HIDDEV_FLAG_REPORT) != 0) { 159 (list->flags & HIDDEV_FLAG_REPORT) != 0) {
160 list->buffer[list->head] = *uref; 160 list->buffer[list->head] = *uref;
161 list->head = (list->head + 1) & 161 list->head = (list->head + 1) &
162 (HIDDEV_BUFFER_SIZE - 1); 162 (HIDDEV_BUFFER_SIZE - 1);
163 kill_fasync(&list->fasync, SIGIO, POLL_IN); 163 kill_fasync(&list->fasync, SIGIO, POLL_IN);
164 } 164 }
@@ -179,9 +179,9 @@ void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
179 unsigned type = field->report_type; 179 unsigned type = field->report_type;
180 struct hiddev_usage_ref uref; 180 struct hiddev_usage_ref uref;
181 181
182 uref.report_type = 182 uref.report_type =
183 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : 183 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
184 ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 184 ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
185 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); 185 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
186 uref.report_id = field->report->id; 186 uref.report_id = field->report->id;
187 uref.field_index = field->index; 187 uref.field_index = field->index;
@@ -199,9 +199,9 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
199 struct hiddev_usage_ref uref; 199 struct hiddev_usage_ref uref;
200 200
201 memset(&uref, 0, sizeof(uref)); 201 memset(&uref, 0, sizeof(uref));
202 uref.report_type = 202 uref.report_type =
203 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : 203 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
204 ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 204 ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
205 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); 205 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
206 uref.report_id = report->id; 206 uref.report_id = report->id;
207 uref.field_index = HID_FIELD_INDEX_NONE; 207 uref.field_index = HID_FIELD_INDEX_NONE;
@@ -236,7 +236,7 @@ static int hiddev_release(struct inode * inode, struct file * file)
236 *listptr = (*listptr)->next; 236 *listptr = (*listptr)->next;
237 237
238 if (!--list->hiddev->open) { 238 if (!--list->hiddev->open) {
239 if (list->hiddev->exist) 239 if (list->hiddev->exist)
240 hid_close(list->hiddev->hid); 240 hid_close(list->hiddev->hid);
241 else 241 else
242 kfree(list->hiddev); 242 kfree(list->hiddev);
@@ -303,7 +303,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
303 if (list->head == list->tail) { 303 if (list->head == list->tail) {
304 add_wait_queue(&list->hiddev->wait, &wait); 304 add_wait_queue(&list->hiddev->wait, &wait);
305 set_current_state(TASK_INTERRUPTIBLE); 305 set_current_state(TASK_INTERRUPTIBLE);
306 306
307 while (list->head == list->tail) { 307 while (list->head == list->tail) {
308 if (file->f_flags & O_NONBLOCK) { 308 if (file->f_flags & O_NONBLOCK) {
309 retval = -EAGAIN; 309 retval = -EAGAIN;
@@ -317,7 +317,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
317 retval = -EIO; 317 retval = -EIO;
318 break; 318 break;
319 } 319 }
320 320
321 schedule(); 321 schedule();
322 } 322 }
323 323
@@ -329,7 +329,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
329 return retval; 329 return retval;
330 330
331 331
332 while (list->head != list->tail && 332 while (list->head != list->tail &&
333 retval + event_size <= count) { 333 retval + event_size <= count) {
334 if ((list->flags & HIDDEV_FLAG_UREF) == 0) { 334 if ((list->flags & HIDDEV_FLAG_UREF) == 0) {
335 if (list->buffer[list->tail].field_index != 335 if (list->buffer[list->tail].field_index !=
@@ -405,10 +405,10 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
405 return -EINVAL; 405 return -EINVAL;
406 406
407 for (i = 0; i < hid->maxcollection; i++) 407 for (i = 0; i < hid->maxcollection; i++)
408 if (hid->collection[i].type == 408 if (hid->collection[i].type ==
409 HID_COLLECTION_APPLICATION && arg-- == 0) 409 HID_COLLECTION_APPLICATION && arg-- == 0)
410 break; 410 break;
411 411
412 if (i == hid->maxcollection) 412 if (i == hid->maxcollection)
413 return -EINVAL; 413 return -EINVAL;
414 414
@@ -562,7 +562,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
562 if (!uref_multi) 562 if (!uref_multi)
563 return -ENOMEM; 563 return -ENOMEM;
564 uref = &uref_multi->uref; 564 uref = &uref_multi->uref;
565 if (copy_from_user(uref, user_arg, sizeof(*uref))) 565 if (copy_from_user(uref, user_arg, sizeof(*uref)))
566 goto fault; 566 goto fault;
567 567
568 rinfo.report_type = uref->report_type; 568 rinfo.report_type = uref->report_type;
@@ -595,7 +595,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
595 return -ENOMEM; 595 return -ENOMEM;
596 uref = &uref_multi->uref; 596 uref = &uref_multi->uref;
597 if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) { 597 if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) {
598 if (copy_from_user(uref_multi, user_arg, 598 if (copy_from_user(uref_multi, user_arg,
599 sizeof(*uref_multi))) 599 sizeof(*uref_multi)))
600 goto fault; 600 goto fault;
601 } else { 601 } else {
@@ -603,7 +603,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
603 goto fault; 603 goto fault;
604 } 604 }
605 605
606 if (cmd != HIDIOCGUSAGE && 606 if (cmd != HIDIOCGUSAGE &&
607 cmd != HIDIOCGUSAGES && 607 cmd != HIDIOCGUSAGES &&
608 uref->report_type == HID_REPORT_TYPE_INPUT) 608 uref->report_type == HID_REPORT_TYPE_INPUT)
609 goto inval; 609 goto inval;
@@ -651,16 +651,16 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
651 return field->usage[uref->usage_index].collection_index; 651 return field->usage[uref->usage_index].collection_index;
652 case HIDIOCGUSAGES: 652 case HIDIOCGUSAGES:
653 for (i = 0; i < uref_multi->num_values; i++) 653 for (i = 0; i < uref_multi->num_values; i++)
654 uref_multi->values[i] = 654 uref_multi->values[i] =
655 field->value[uref->usage_index + i]; 655 field->value[uref->usage_index + i];
656 if (copy_to_user(user_arg, uref_multi, 656 if (copy_to_user(user_arg, uref_multi,
657 sizeof(*uref_multi))) 657 sizeof(*uref_multi)))
658 goto fault; 658 goto fault;
659 goto goodreturn; 659 goto goodreturn;
660 case HIDIOCSUSAGES: 660 case HIDIOCSUSAGES:
661 for (i = 0; i < uref_multi->num_values; i++) 661 for (i = 0; i < uref_multi->num_values; i++)
662 field->value[uref->usage_index + i] = 662 field->value[uref->usage_index + i] =
663 uref_multi->values[i]; 663 uref_multi->values[i];
664 goto goodreturn; 664 goto goodreturn;
665 } 665 }
666 666
@@ -670,7 +670,7 @@ goodreturn:
670fault: 670fault:
671 kfree(uref_multi); 671 kfree(uref_multi);
672 return -EFAULT; 672 return -EFAULT;
673inval: 673inval:
674 kfree(uref_multi); 674 kfree(uref_multi);
675 return -EINVAL; 675 return -EINVAL;
676 676
@@ -734,7 +734,7 @@ static struct usb_class_driver hiddev_class = {
734 .name = "usb/hid/hiddev%d", 734 .name = "usb/hid/hiddev%d",
735 .fops = &hiddev_fops, 735 .fops = &hiddev_fops,
736 .mode = S_IFCHR | S_IRUGO | S_IWUSR, 736 .mode = S_IFCHR | S_IRUGO | S_IWUSR,
737 .minor_base = HIDDEV_MINOR_BASE, 737 .minor_base = HIDDEV_MINOR_BASE,
738}; 738};
739 739
740/* 740/*
@@ -747,7 +747,7 @@ int hiddev_connect(struct hid_device *hid)
747 int retval; 747 int retval;
748 748
749 for (i = 0; i < hid->maxcollection; i++) 749 for (i = 0; i < hid->maxcollection; i++)
750 if (hid->collection[i].type == 750 if (hid->collection[i].type ==
751 HID_COLLECTION_APPLICATION && 751 HID_COLLECTION_APPLICATION &&
752 !IS_INPUT_APPLICATION(hid->collection[i].usage)) 752 !IS_INPUT_APPLICATION(hid->collection[i].usage))
753 break; 753 break;
@@ -755,11 +755,11 @@ int hiddev_connect(struct hid_device *hid)
755 if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0) 755 if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0)
756 return -1; 756 return -1;
757 757
758 if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) 758 if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL)))
759 return -1; 759 return -1;
760 memset(hiddev, 0, sizeof(struct hiddev)); 760 memset(hiddev, 0, sizeof(struct hiddev));
761 761
762 retval = usb_register_dev(hid->intf, &hiddev_class); 762 retval = usb_register_dev(hid->intf, &hiddev_class);
763 if (retval) { 763 if (retval) {
764 err("Not able to get a minor for this device."); 764 err("Not able to get a minor for this device.");
765 kfree(hiddev); 765 kfree(hiddev);
@@ -768,12 +768,12 @@ int hiddev_connect(struct hid_device *hid)
768 768
769 init_waitqueue_head(&hiddev->wait); 769 init_waitqueue_head(&hiddev->wait);
770 770
771 hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; 771 hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
772 772
773 hiddev->hid = hid; 773 hiddev->hid = hid;
774 hiddev->exist = 1; 774 hiddev->exist = 1;
775 775
776 hid->minor = hid->intf->minor; 776 hid->minor = hid->intf->minor;
777 hid->hiddev = hiddev; 777 hid->hiddev = hiddev;
778 778
779 return 0; 779 return 0;
@@ -818,7 +818,7 @@ void hiddev_disconnect(struct hid_device *hid)
818/* We never attach in this manner, and rely on HID to connect us. This 818/* We never attach in this manner, and rely on HID to connect us. This
819 * is why there is no disconnect routine defined in the usb_driver either. 819 * is why there is no disconnect routine defined in the usb_driver either.
820 */ 820 */
821static int hiddev_usbd_probe(struct usb_interface *intf, 821static int hiddev_usbd_probe(struct usb_interface *intf,
822 const struct usb_device_id *hiddev_info) 822 const struct usb_device_id *hiddev_info)
823{ 823{
824 return -ENODEV; 824 return -ENODEV;