hidraw.c (da733563be5a9da26fe81d9f007262d00b846e22) hidraw.c (b6787242f32700377d3da3b8d788ab3928bab849)
1/*
2 * HID raw devices, giving access to raw HID events.
3 *
4 * In comparison to hiddev, this device does not process the
5 * hid events at all (no parsing, no lookups). This lets applications
6 * to work on raw hid events as they want to, and avoids a need to
7 * use a transport-specific userspace libhid/libusb libraries.
8 *

--- 73 unchanged lines hidden (view full) ---

82 }
83
84 if (ret)
85 goto out;
86
87 len = list->buffer[list->tail].len > count ?
88 count : list->buffer[list->tail].len;
89
1/*
2 * HID raw devices, giving access to raw HID events.
3 *
4 * In comparison to hiddev, this device does not process the
5 * hid events at all (no parsing, no lookups). This lets applications
6 * to work on raw hid events as they want to, and avoids a need to
7 * use a transport-specific userspace libhid/libusb libraries.
8 *

--- 73 unchanged lines hidden (view full) ---

82 }
83
84 if (ret)
85 goto out;
86
87 len = list->buffer[list->tail].len > count ?
88 count : list->buffer[list->tail].len;
89
90 if (copy_to_user(buffer, list->buffer[list->tail].value, len)) {
91 ret = -EFAULT;
92 goto out;
90 if (list->buffer[list->tail].value) {
91 if (copy_to_user(buffer, list->buffer[list->tail].value, len)) {
92 ret = -EFAULT;
93 goto out;
94 }
95 ret = len;
93 }
96 }
94 ret = len;
95
96 kfree(list->buffer[list->tail].value);
97 list->tail = (list->tail + 1) & (HIDRAW_BUFFER_SIZE - 1);
98 }
99out:
100 mutex_unlock(&list->read_mutex);
101 return ret;
102}

--- 329 unchanged lines hidden (view full) ---

432 .release = hidraw_release,
433 .unlocked_ioctl = hidraw_ioctl,
434#ifdef CONFIG_COMPAT
435 .compat_ioctl = hidraw_ioctl,
436#endif
437 .llseek = noop_llseek,
438};
439
97
98 kfree(list->buffer[list->tail].value);
99 list->tail = (list->tail + 1) & (HIDRAW_BUFFER_SIZE - 1);
100 }
101out:
102 mutex_unlock(&list->read_mutex);
103 return ret;
104}

--- 329 unchanged lines hidden (view full) ---

434 .release = hidraw_release,
435 .unlocked_ioctl = hidraw_ioctl,
436#ifdef CONFIG_COMPAT
437 .compat_ioctl = hidraw_ioctl,
438#endif
439 .llseek = noop_llseek,
440};
441
440void hidraw_report_event(struct hid_device *hid, u8 *data, int len)
442int hidraw_report_event(struct hid_device *hid, u8 *data, int len)
441{
442 struct hidraw *dev = hid->hidraw;
443 struct hidraw_list *list;
443{
444 struct hidraw *dev = hid->hidraw;
445 struct hidraw_list *list;
446 int ret = 0;
444
445 list_for_each_entry(list, &dev->list, node) {
447
448 list_for_each_entry(list, &dev->list, node) {
446 list->buffer[list->head].value = kmemdup(data, len, GFP_ATOMIC);
449 if (!(list->buffer[list->head].value = kmemdup(data, len, GFP_ATOMIC))) {
450 ret = -ENOMEM;
451 break;
452 }
447 list->buffer[list->head].len = len;
448 list->head = (list->head + 1) & (HIDRAW_BUFFER_SIZE - 1);
449 kill_fasync(&list->fasync, SIGIO, POLL_IN);
450 }
451
452 wake_up_interruptible(&dev->wait);
453 list->buffer[list->head].len = len;
454 list->head = (list->head + 1) & (HIDRAW_BUFFER_SIZE - 1);
455 kill_fasync(&list->fasync, SIGIO, POLL_IN);
456 }
457
458 wake_up_interruptible(&dev->wait);
459 return ret;
453}
454EXPORT_SYMBOL_GPL(hidraw_report_event);
455
456int hidraw_connect(struct hid_device *hid)
457{
458 int minor, result;
459 struct hidraw *dev;
460

--- 110 unchanged lines hidden ---
460}
461EXPORT_SYMBOL_GPL(hidraw_report_event);
462
463int hidraw_connect(struct hid_device *hid)
464{
465 int minor, result;
466 struct hidraw *dev;
467

--- 110 unchanged lines hidden ---