]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
USB HID: provide hook for hidraw write()
authorJiri Kosina <jkosina@suse.cz>
Mon, 14 May 2007 07:54:30 +0000 (09:54 +0200)
committerJiri Kosina <jkosina@suse.cz>
Sun, 14 Oct 2007 12:47:26 +0000 (14:47 +0200)
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>
drivers/hid/usbhid/hid-core.c

index 0a1f2b52a12fa4bab847f905e8f5069e87cb5944..74b817d7968dac0d871c81750d7a23b83f3e684f 100644 (file)
@@ -628,6 +628,28 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
        return 0;
 }
 
+static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count)
+{
+       struct usbhid_device *usbhid = hid->driver_data;
+       struct usb_device *dev = hid_to_usb_dev(hid);
+       struct usb_interface *intf = usbhid->intf;
+       struct usb_host_interface *interface = intf->cur_altsetting;
+       int ret;
+
+       ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+               HID_REQ_SET_REPORT,
+               USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+               cpu_to_le16(((HID_OUTPUT_REPORT + 1) << 8) | *buf),
+               interface->desc.bInterfaceNumber, buf + 1, count - 1,
+               USB_CTRL_SET_TIMEOUT);
+
+       /* count also the report id */
+       if (ret > 0)
+               ret++;
+
+       return ret;
+}
+
 static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
 {
        struct usbhid_device *usbhid = hid->driver_data;
@@ -871,6 +893,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
        hid->hiddev_hid_event = hiddev_hid_event;
        hid->hiddev_report_event = hiddev_report_event;
 #endif
+       hid->hid_output_raw_report = usbhid_output_raw_report;
        return hid;
 
 fail: