Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: make .raw_request mandatory

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>

authored by

Benjamin Tissoires and committed by
Jiri Kosina
3c86726c 2ebaebcf

+12 -11
+2 -1
Documentation/hid/hid-transport.txt
··· 283 283 int reqtype) 284 284 Same as ->request() but provides the report as raw buffer. This request shall 285 285 be synchronous. A transport driver must not use ->wait() to complete such 286 - requests. 286 + requests. This request is mandatory and hid core will reject the device if 287 + it is missing. 287 288 288 289 - int (*output_report) (struct hid_device *hdev, __u8 *buf, size_t len) 289 290 Send raw output report via intr channel. Used by some HID device drivers
+8 -3
drivers/hid/hid-core.c
··· 1330 1330 int ret; 1331 1331 int len; 1332 1332 1333 - if (!hid->ll_driver->raw_request) 1334 - return; 1335 - 1336 1333 buf = hid_alloc_report_buf(report, GFP_KERNEL); 1337 1334 if (!buf) 1338 1335 return; ··· 2467 2470 * wait for coming driver */ 2468 2471 if (hid_ignore(hdev)) 2469 2472 return -ENODEV; 2473 + 2474 + /* 2475 + * Check for the mandatory transport channel. 2476 + */ 2477 + if (!hdev->ll_driver->raw_request) { 2478 + hid_err(hdev, "transport driver missing .raw_request()\n"); 2479 + return -EINVAL; 2480 + } 2470 2481 2471 2482 /* 2472 2483 * Read the device report descriptor once and use as template
+1 -3
drivers/hid/hid-input.c
··· 1266 1266 } 1267 1267 1268 1268 input_set_drvdata(input_dev, hid); 1269 - if (hid->ll_driver->request || hid->ll_driver->output_report || 1270 - hid->ll_driver->raw_request) 1271 - input_dev->event = hidinput_input_event; 1269 + input_dev->event = hidinput_input_event; 1272 1270 input_dev->open = hidinput_open; 1273 1271 input_dev->close = hidinput_close; 1274 1272 input_dev->setkeycode = hidinput_setkeycode;
+1 -4
include/linux/hid.h
··· 992 992 if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf) 993 993 return -EINVAL; 994 994 995 - if (hdev->ll_driver->raw_request) 996 - return hdev->ll_driver->raw_request(hdev, reportnum, buf, len, 995 + return hdev->ll_driver->raw_request(hdev, reportnum, buf, len, 997 996 rtype, reqtype); 998 - 999 - return -ENOSYS; 1000 997 } 1001 998 1002 999 /**