aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2014-02-05 16:33:21 -0500
committerJiri Kosina <jkosina@suse.cz>2014-02-17 08:05:57 -0500
commitf9bcca405624c7f4a0cf4a1b78f8b3a312ca4dab (patch)
treec7219893848d053a3298dae8710eca89e00bf054 /drivers
parente9d5da97a6a8da75f8a58b722bbd59ef474e0f47 (diff)
HID: usbhid: remove duplicated code
Well, no use to keep twice the same code. Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/usbhid/hid-core.c64
1 files changed, 11 insertions, 53 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index f8ca312bae1b..406497b120ea 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -915,59 +915,6 @@ static int usbhid_set_raw_report(struct hid_device *hid, unsigned int reportnum,
915 return ret; 915 return ret;
916} 916}
917 917
918
919static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count,
920 unsigned char report_type)
921{
922 struct usbhid_device *usbhid = hid->driver_data;
923 struct usb_device *dev = hid_to_usb_dev(hid);
924 struct usb_interface *intf = usbhid->intf;
925 struct usb_host_interface *interface = intf->cur_altsetting;
926 int ret;
927
928 if (usbhid->urbout && report_type != HID_FEATURE_REPORT) {
929 int actual_length;
930 int skipped_report_id = 0;
931
932 if (buf[0] == 0x0) {
933 /* Don't send the Report ID */
934 buf++;
935 count--;
936 skipped_report_id = 1;
937 }
938 ret = usb_interrupt_msg(dev, usbhid->urbout->pipe,
939 buf, count, &actual_length,
940 USB_CTRL_SET_TIMEOUT);
941 /* return the number of bytes transferred */
942 if (ret == 0) {
943 ret = actual_length;
944 /* count also the report id */
945 if (skipped_report_id)
946 ret++;
947 }
948 } else {
949 int skipped_report_id = 0;
950 int report_id = buf[0];
951 if (buf[0] == 0x0) {
952 /* Don't send the Report ID */
953 buf++;
954 count--;
955 skipped_report_id = 1;
956 }
957 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
958 HID_REQ_SET_REPORT,
959 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
960 ((report_type + 1) << 8) | report_id,
961 interface->desc.bInterfaceNumber, buf, count,
962 USB_CTRL_SET_TIMEOUT);
963 /* count also the report id, if this was a numbered report. */
964 if (ret > 0 && skipped_report_id)
965 ret++;
966 }
967
968 return ret;
969}
970
971static int usbhid_output_report(struct hid_device *hid, __u8 *buf, size_t count) 918static int usbhid_output_report(struct hid_device *hid, __u8 *buf, size_t count)
972{ 919{
973 struct usbhid_device *usbhid = hid->driver_data; 920 struct usbhid_device *usbhid = hid->driver_data;
@@ -998,6 +945,17 @@ static int usbhid_output_report(struct hid_device *hid, __u8 *buf, size_t count)
998 return ret; 945 return ret;
999} 946}
1000 947
948static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf,
949 size_t count, unsigned char report_type)
950{
951 struct usbhid_device *usbhid = hid->driver_data;
952
953 if (usbhid->urbout && report_type != HID_FEATURE_REPORT)
954 return usbhid_output_report(hid, buf, count);
955
956 return usbhid_set_raw_report(hid, buf[0], buf, count, report_type);
957}
958
1001static void usbhid_restart_queues(struct usbhid_device *usbhid) 959static void usbhid_restart_queues(struct usbhid_device *usbhid)
1002{ 960{
1003 if (usbhid->urbout && !test_bit(HID_OUT_RUNNING, &usbhid->iofl)) 961 if (usbhid->urbout && !test_bit(HID_OUT_RUNNING, &usbhid->iofl))