Merge branch 'for-3.15/hid-cp2112' into for-3.15/hid-core-ll-transport-cleanup
diff --git a/Documentation/hid/hid-transport.txt b/Documentation/hid/hid-transport.txt
index 9dbbcea..3dcba9f 100644
--- a/Documentation/hid/hid-transport.txt
+++ b/Documentation/hid/hid-transport.txt
@@ -283,7 +283,8 @@
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
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 2011136..ddb981d 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1330,9 +1330,6 @@
int ret;
int len;
- if (!hid->ll_driver->raw_request)
- return;
-
buf = hid_alloc_report_buf(report, GFP_KERNEL);
if (!buf)
return;
@@ -2473,6 +2470,14 @@
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.
*/
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 15959fb..f5aef79 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1150,7 +1150,7 @@
led_work);
struct hid_field *field;
struct hid_report *report;
- int len;
+ int len, ret;
__u8 *buf;
field = hidinput_get_led_field(hid);
@@ -1184,7 +1184,10 @@
hid_output_report(report, buf);
/* synchronous output report */
- hid_output_raw_report(hid, buf, len, HID_OUTPUT_REPORT);
+ ret = hid_hw_output_report(hid, buf, len);
+ if (ret == -ENOSYS)
+ hid_hw_raw_request(hid, report->id, buf, len, HID_OUTPUT_REPORT,
+ HID_REQ_SET_REPORT);
kfree(buf);
}
@@ -1263,8 +1266,7 @@
}
input_set_drvdata(input_dev, hid);
- if (hid->ll_driver->request || hid->hid_output_raw_report)
- 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;
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index f8708c9..2cc484c 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -123,10 +123,6 @@
dev = hidraw_table[minor]->hid;
- if (!dev->hid_output_raw_report) {
- ret = -ENODEV;
- goto out;
- }
if (count > HID_MAX_BUFFER_SIZE) {
hid_warn(dev, "pid %d passed too large report\n",
@@ -153,7 +149,20 @@
goto out_free;
}
- ret = hid_output_raw_report(dev, buf, count, report_type);
+ if (report_type == HID_OUTPUT_REPORT) {
+ ret = hid_hw_output_report(dev, buf, count);
+ /*
+ * compatibility with old implementation of USB-HID and I2C-HID:
+ * if the device does not support receiving output reports,
+ * on an interrupt endpoint, fallback to SET_REPORT HID command.
+ */
+ if (ret != -ENOSYS)
+ goto out_free;
+ }
+
+ ret = hid_hw_raw_request(dev, buf[0], buf, count, report_type,
+ HID_REQ_SET_REPORT);
+
out_free:
kfree(buf);
out:
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 60f3ff7..5eb282e 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -992,11 +992,8 @@
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;
}
/**