HID: introduce helper to access hid_output_raw_report()
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Wed, 5 Feb 2014 21:33:23 +0000 (16:33 -0500)
committerJiri Kosina <jkosina@suse.cz>
Mon, 17 Feb 2014 13:05:59 +0000 (14:05 +0100)
Add a helper to access hdev->hid_output_raw_report().

To convert the drivers, use the following snippets:

for i in drivers/hid/*.c
do
  sed -i.bak "s/[^ \t]*->hid_output_raw_report(/hid_output_raw_report(/g" $i
done

Then manually fix for checkpatch.pl

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>
drivers/hid/hid-input.c
drivers/hid/hid-lg.c
drivers/hid/hid-magicmouse.c
drivers/hid/hid-sony.c
drivers/hid/hid-thingm.c
drivers/hid/hid-wacom.c
drivers/hid/hid-wiimote-core.c
drivers/hid/hidraw.c
include/linux/hid.h

index 5bd17b2568562aa56007ad01c224105981ee212b..15959fbae26828c13759a3f1d6c23ba936df7f7c 100644 (file)
@@ -1184,7 +1184,7 @@ static void hidinput_led_worker(struct work_struct *work)
 
        hid_output_report(report, buf);
        /* synchronous output report */
-       hid->hid_output_raw_report(hid, buf, len, HID_OUTPUT_REPORT);
+       hid_output_raw_report(hid, buf, len, HID_OUTPUT_REPORT);
        kfree(buf);
 }
 
index 9fe9d4ac3114bb224f942678de76191fbe846edc..76ed7e512dcf28c9aa9c6965891d7c6856840295 100644 (file)
@@ -692,7 +692,8 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
        if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) {
                unsigned char buf[] = { 0x00, 0xAF,  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
-               ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
+               ret = hid_output_raw_report(hdev, buf, sizeof(buf),
+                                           HID_FEATURE_REPORT);
 
                if (ret >= 0) {
                        /* insert a little delay of 10 jiffies ~ 40ms */
@@ -704,7 +705,8 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
                        buf[1] = 0xB2;
                        get_random_bytes(&buf[2], 2);
 
-                       ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
+                       ret = hid_output_raw_report(hdev, buf, sizeof(buf),
+                                                   HID_FEATURE_REPORT);
                }
        }
 
index 3b43d1cfa9368609302de46a73658779199d446f..cb5db3afc690be109fe654f11f05391fda1c00e6 100644 (file)
@@ -538,7 +538,7 @@ static int magicmouse_probe(struct hid_device *hdev,
         * but there seems to be no other way of switching the mode.
         * Thus the super-ugly hacky success check below.
         */
-       ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
+       ret = hid_output_raw_report(hdev, feature, sizeof(feature),
                        HID_FEATURE_REPORT);
        if (ret != -EIO && ret != sizeof(feature)) {
                hid_err(hdev, "unable to request touch data (%d)\n", ret);
index 3930acbdee987ee2810c64f68ca72036e8b46617..075089b372365ed2deb6c675564e0224f3ee7298 100644 (file)
@@ -720,7 +720,8 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
 static int sixaxis_set_operational_bt(struct hid_device *hdev)
 {
        unsigned char buf[] = { 0xf4,  0x42, 0x03, 0x00, 0x00 };
-       return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
+       return hid_output_raw_report(hdev, buf, sizeof(buf),
+                                    HID_FEATURE_REPORT);
 }
 
 static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds)
@@ -942,8 +943,7 @@ static void sixaxis_state_worker(struct work_struct *work)
        buf[10] |= sc->led_state[2] << 3;
        buf[10] |= sc->led_state[3] << 4;
 
-       sc->hdev->hid_output_raw_report(sc->hdev, buf, sizeof(buf),
-                                       HID_OUTPUT_REPORT);
+       hid_output_raw_report(sc->hdev, buf, sizeof(buf), HID_OUTPUT_REPORT);
 }
 
 static void dualshock4_state_worker(struct work_struct *work)
index 99342cfa0ea2f82591831aaa21fcd9b4e11915c3..7dd3197f3b3eac9747c918e530bd3afcf071b826 100644 (file)
@@ -48,8 +48,8 @@ static int blink1_send_command(struct blink1_data *data,
                        buf[0], buf[1], buf[2], buf[3], buf[4],
                        buf[5], buf[6], buf[7], buf[8]);
 
-       ret = data->hdev->hid_output_raw_report(data->hdev, buf,
-                       BLINK1_CMD_SIZE, HID_FEATURE_REPORT);
+       ret = hid_output_raw_report(data->hdev, buf, BLINK1_CMD_SIZE,
+                                   HID_FEATURE_REPORT);
 
        return ret < 0 ? ret : 0;
 }
index 60c75dcbbdb87109061e1d3f12d5e9710fdfe944..c720db912edba4bcec5d6fac1e1352cfa7a1f001 100644 (file)
@@ -128,8 +128,7 @@ static void wacom_set_image(struct hid_device *hdev, const char *image,
 
        rep_data[0] = WAC_CMD_ICON_START_STOP;
        rep_data[1] = 0;
-       ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
-                               HID_FEATURE_REPORT);
+       ret = hid_output_raw_report(hdev, rep_data, 2, HID_FEATURE_REPORT);
        if (ret < 0)
                goto err;
 
@@ -143,15 +142,14 @@ static void wacom_set_image(struct hid_device *hdev, const char *image,
                        rep_data[j + 3] = p[(i << 6) + j];
 
                rep_data[2] = i;
-               ret = hdev->hid_output_raw_report(hdev, rep_data, 67,
+               ret = hid_output_raw_report(hdev, rep_data, 67,
                                        HID_FEATURE_REPORT);
        }
 
        rep_data[0] = WAC_CMD_ICON_START_STOP;
        rep_data[1] = 0;
 
-       ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
-                               HID_FEATURE_REPORT);
+       ret = hid_output_raw_report(hdev, rep_data, 2, HID_FEATURE_REPORT);
 
 err:
        return;
@@ -183,7 +181,7 @@ static void wacom_leds_set_brightness(struct led_classdev *led_dev,
                buf[3] = value;
                /* use fixed brightness for OLEDs */
                buf[4] = 0x08;
-               hdev->hid_output_raw_report(hdev, buf, 9, HID_FEATURE_REPORT);
+               hid_output_raw_report(hdev, buf, 9, HID_FEATURE_REPORT);
                kfree(buf);
        }
 
@@ -339,7 +337,7 @@ static void wacom_set_features(struct hid_device *hdev, u8 speed)
                rep_data[0] = 0x03 ; rep_data[1] = 0x00;
                limit = 3;
                do {
-                       ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
+                       ret = hid_output_raw_report(hdev, rep_data, 2,
                                        HID_FEATURE_REPORT);
                } while (ret < 0 && limit-- > 0);
 
@@ -352,7 +350,7 @@ static void wacom_set_features(struct hid_device *hdev, u8 speed)
                        rep_data[1] = 0x00;
                        limit = 3;
                        do {
-                               ret = hdev->hid_output_raw_report(hdev,
+                               ret = hid_output_raw_report(hdev,
                                        rep_data, 2, HID_FEATURE_REPORT);
                        } while (ret < 0 && limit-- > 0);
 
@@ -378,7 +376,7 @@ static void wacom_set_features(struct hid_device *hdev, u8 speed)
                rep_data[0] = 0x03;
                rep_data[1] = wdata->features;
 
-               ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
+               ret = hid_output_raw_report(hdev, rep_data, 2,
                                        HID_FEATURE_REPORT);
                if (ret >= 0)
                        wdata->high_speed = speed;
index abb20db2b443ccdcc34159a97fcc83307db65c40..d7dc6c5bc244caaf090677a647d686a3921ec2a9 100644 (file)
@@ -35,7 +35,7 @@ static int wiimote_hid_send(struct hid_device *hdev, __u8 *buffer,
        if (!buf)
                return -ENOMEM;
 
-       ret = hdev->hid_output_raw_report(hdev, buf, count, HID_OUTPUT_REPORT);
+       ret = hid_output_raw_report(hdev, buf, count, HID_OUTPUT_REPORT);
 
        kfree(buf);
        return ret;
index 4b2dc956c702dcbb27f8fa47264d1a20a39255c4..f8708c93f85cec5a5a780d0b09282aa803e32f66 100644 (file)
@@ -153,7 +153,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
                goto out_free;
        }
 
-       ret = dev->hid_output_raw_report(dev, buf, count, report_type);
+       ret = hid_output_raw_report(dev, buf, count, report_type);
 out_free:
        kfree(buf);
 out:
index c56681a66b0b04689f9ae32d0423b31943484d83..a837ede65ec6875044c9ae51642fd52d8d2c2301 100644 (file)
@@ -1011,6 +1011,22 @@ static inline int hid_hw_output_report(struct hid_device *hdev, __u8 *buf,
        return -ENOSYS;
 }
 
+/**
+ * hid_output_raw_report - send an output or a feature report to the device
+ *
+ * @hdev: hid device
+ * @buf: raw data to transfer
+ * @len: length of buf
+ * @report_type: HID_FEATURE_REPORT or HID_OUTPUT_REPORT
+ *
+ * @return: count of data transfered, negative if error
+ */
+static inline int hid_output_raw_report(struct hid_device *hdev, __u8 *buf,
+                                       size_t len, unsigned char report_type)
+{
+       return hdev->hid_output_raw_report(hdev, buf, len, report_type);
+}
+
 /**
  * hid_hw_idle - send idle request to device
  *