Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB HID: provide hook for hidraw write()

Add hook in usbhid for write() callback from hidraw. Sends the
report to the device through control pipe.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

+23
+23
drivers/hid/usbhid/hid-core.c
··· 628 628 return 0; 629 629 } 630 630 631 + static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count) 632 + { 633 + struct usbhid_device *usbhid = hid->driver_data; 634 + struct usb_device *dev = hid_to_usb_dev(hid); 635 + struct usb_interface *intf = usbhid->intf; 636 + struct usb_host_interface *interface = intf->cur_altsetting; 637 + int ret; 638 + 639 + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 640 + HID_REQ_SET_REPORT, 641 + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 642 + cpu_to_le16(((HID_OUTPUT_REPORT + 1) << 8) | *buf), 643 + interface->desc.bInterfaceNumber, buf + 1, count - 1, 644 + USB_CTRL_SET_TIMEOUT); 645 + 646 + /* count also the report id */ 647 + if (ret > 0) 648 + ret++; 649 + 650 + return ret; 651 + } 652 + 631 653 static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) 632 654 { 633 655 struct usbhid_device *usbhid = hid->driver_data; ··· 893 871 hid->hiddev_hid_event = hiddev_hid_event; 894 872 hid->hiddev_report_event = hiddev_report_event; 895 873 #endif 874 + hid->hid_output_raw_report = usbhid_output_raw_report; 896 875 return hid; 897 876 898 877 fail: