HID: make .raw_request mandatory
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Thu, 20 Feb 2014 20:24:49 +0000 (15:24 -0500)
committerJiri Kosina <jkosina@suse.cz>
Mon, 24 Feb 2014 16:23:15 +0000 (17:23 +0100)
SET_REPORT and GET_REPORT are mandatory in the HID specification.
Make the corresponding API in hid-core mandatory too, which removes the
need to test against it in some various places.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Documentation/hid/hid-transport.txt
drivers/hid/hid-core.c
drivers/hid/hid-input.c
include/linux/hid.h

index 9dbbceaef4f37f4fce3ba03b9bccd38d27bd2f84..3dcba9fd4a3aaae1be0b60d132fca31914a4c02e 100644 (file)
@@ -283,7 +283,8 @@ The available HID callbacks are:
                        int reqtype)
    Same as ->request() but provides the report as raw buffer. This request shall
    be synchronous. A transport driver must not use ->wait() to complete such
-   requests.
+   requests. This request is mandatory and hid core will reject the device if
+   it is missing.
 
  - int (*output_report) (struct hid_device *hdev, __u8 *buf, size_t len)
    Send raw output report via intr channel. Used by some HID device drivers
index b6ae69711d2ae3f9f3b6384abf2c214e8e34fade..0b57babe3f9f7a20bff6d92328d2542f966c52ab 100644 (file)
@@ -1330,9 +1330,6 @@ void __hid_request(struct hid_device *hid, struct hid_report *report,
        int ret;
        int len;
 
-       if (!hid->ll_driver->raw_request)
-               return;
-
        buf = hid_alloc_report_buf(report, GFP_KERNEL);
        if (!buf)
                return;
@@ -2471,6 +2468,14 @@ int hid_add_device(struct hid_device *hdev)
        if (hid_ignore(hdev))
                return -ENODEV;
 
+       /*
+        * Check for the mandatory transport channel.
+        */
+        if (!hdev->ll_driver->raw_request) {
+               hid_err(hdev, "transport driver missing .raw_request()\n");
+               return -EINVAL;
+        }
+
        /*
         * Read the device report descriptor once and use as template
         * for the driver-specific modifications.
index 310b96779e8e389a74dbe5e7dc8f662299de2437..f5aef792f13b6dd235bdfcaf0b43cf6f9802cc48 100644 (file)
@@ -1266,9 +1266,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid)
        }
 
        input_set_drvdata(input_dev, hid);
-       if (hid->ll_driver->request || hid->ll_driver->output_report ||
-           hid->ll_driver->raw_request)
-               input_dev->event = hidinput_input_event;
+       input_dev->event = hidinput_input_event;
        input_dev->open = hidinput_open;
        input_dev->close = hidinput_close;
        input_dev->setkeycode = hidinput_setkeycode;
index 60f3ff7623764919f226aef493af78adfef5c31f..5eb282e0dff7b486dcd19406e03e430a45cf86f7 100644 (file)
@@ -992,11 +992,8 @@ static inline int hid_hw_raw_request(struct hid_device *hdev,
        if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
                return -EINVAL;
 
-       if (hdev->ll_driver->raw_request)
-               return hdev->ll_driver->raw_request(hdev, reportnum, buf, len,
+       return hdev->ll_driver->raw_request(hdev, reportnum, buf, len,
                                                    rtype, reqtype);
-
-       return -ENOSYS;
 }
 
 /**