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

HID: use hid_hw_wait() instead of direct call to usbhid

This removes most of the dependencies between hid drivers and usbhid.

The patch was constructed by replacing all occurences of
usbhid_wait_io() by its hid_hw_wait() counterpart.
Then, drivers not requiring USB_HID anymore have their USB_HID
dependency cleaned in the Kconfig file.

As of today, few drivers are still requiring an explicit USB layer
dependency:
* ntrig (a patch is on its way)
* multitouch (one patch following and another on its way)
* lenovo tpkbd
* roccat
* sony

The last three are two deeply using direct calls to the usb subsystem
to be able to be cleaned right now.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Benjamin Tissoires and committed by
Jiri Kosina
b7966a4d d8814272

+18 -22
+1 -1
drivers/hid/Kconfig
··· 479 479 480 480 config HID_PICOLCD 481 481 tristate "PicoLCD (graphic version)" 482 - depends on USB_HID 482 + depends on HID 483 483 ---help--- 484 484 This provides support for Minibox PicoLCD devices, currently 485 485 only the graphical ones are supported.
+2 -2
drivers/hid/hid-ntrig.c
··· 119 119 return -EINVAL; 120 120 121 121 hid_hw_request(hdev, report, HID_REQ_GET_REPORT); 122 - usbhid_wait_io(hdev); 122 + hid_hw_wait(hdev); 123 123 return (int)report->field[0]->value[0]; 124 124 } 125 125 ··· 937 937 if (report) { 938 938 /* Let the device settle to ensure the wakeup message gets 939 939 * through */ 940 - usbhid_wait_io(hdev); 940 + hid_hw_wait(hdev); 941 941 hid_hw_request(hdev, report, HID_REQ_GET_REPORT); 942 942 943 943 /*
+2 -3
drivers/hid/hid-picolcd_fb.c
··· 19 19 20 20 #include <linux/hid.h> 21 21 #include <linux/vmalloc.h> 22 - #include "usbhid/usbhid.h" 23 22 24 23 #include <linux/fb.h> 25 24 #include <linux/module.h> ··· 268 269 mutex_unlock(&info->lock); 269 270 if (!data) 270 271 return; 271 - usbhid_wait_io(data->hdev); 272 + hid_hw_wait(data->hdev); 272 273 mutex_lock(&info->lock); 273 274 n = 0; 274 275 } ··· 286 287 spin_unlock_irqrestore(&fbdata->lock, flags); 287 288 mutex_unlock(&info->lock); 288 289 if (data) 289 - usbhid_wait_io(data->hdev); 290 + hid_hw_wait(data->hdev); 290 291 return; 291 292 } 292 293 out:
+2 -3
drivers/hid/hid-sensor-hub.c
··· 18 18 */ 19 19 #include <linux/device.h> 20 20 #include <linux/hid.h> 21 - #include "usbhid/usbhid.h" 22 21 #include <linux/module.h> 23 22 #include <linux/slab.h> 24 23 #include <linux/mfd/core.h> ··· 203 204 } 204 205 hid_set_field(report->field[field_index], 0, value); 205 206 hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT); 206 - usbhid_wait_io(hsdev->hdev); 207 + hid_hw_wait(hsdev->hdev); 207 208 208 209 done_proc: 209 210 mutex_unlock(&data->mutex); ··· 226 227 goto done_proc; 227 228 } 228 229 hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT); 229 - usbhid_wait_io(hsdev->hdev); 230 + hid_hw_wait(hsdev->hdev); 230 231 *value = report->field[field_index]->value[0]; 231 232 232 233 done_proc:
+1 -2
drivers/hid/usbhid/hid-core.c
··· 705 705 return 0; 706 706 } 707 707 708 - int usbhid_wait_io(struct hid_device *hid) 708 + static int usbhid_wait_io(struct hid_device *hid) 709 709 { 710 710 struct usbhid_device *usbhid = hid->driver_data; 711 711 ··· 719 719 720 720 return 0; 721 721 } 722 - EXPORT_SYMBOL_GPL(usbhid_wait_io); 723 722 724 723 static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle) 725 724 {
+8 -8
drivers/hid/usbhid/hid-pidff.c
··· 471 471 472 472 pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; 473 473 pidff->block_load_status->value[0] = 0; 474 - usbhid_wait_io(pidff->hid); 474 + hid_hw_wait(pidff->hid); 475 475 476 476 for (j = 0; j < 60; j++) { 477 477 hid_dbg(pidff->hid, "pid_block_load requested\n"); 478 478 hid_hw_request(pidff->hid, pidff->reports[PID_BLOCK_LOAD], 479 479 HID_REQ_GET_REPORT); 480 - usbhid_wait_io(pidff->hid); 480 + hid_hw_wait(pidff->hid); 481 481 if (pidff->block_load_status->value[0] == 482 482 pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { 483 483 hid_dbg(pidff->hid, "device reported free memory: %d bytes\n", ··· 551 551 effect_id, pidff->pid_id[effect_id]); 552 552 /* Wait for the queue to clear. We do not want a full fifo to 553 553 prevent the effect removal. */ 554 - usbhid_wait_io(pidff->hid); 554 + hid_hw_wait(pidff->hid); 555 555 pidff_playback_pid(pidff, pid_id, 0); 556 556 pidff_erase_pid(pidff, pid_id); 557 557 ··· 1159 1159 pidff->device_control->value[0] = pidff->control_id[PID_RESET]; 1160 1160 /* We reset twice as sometimes hid_wait_io isn't waiting long enough */ 1161 1161 hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT); 1162 - usbhid_wait_io(hid); 1162 + hid_hw_wait(hid); 1163 1163 hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT); 1164 - usbhid_wait_io(hid); 1164 + hid_hw_wait(hid); 1165 1165 1166 1166 pidff->device_control->value[0] = 1167 1167 pidff->control_id[PID_ENABLE_ACTUATORS]; 1168 1168 hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT); 1169 - usbhid_wait_io(hid); 1169 + hid_hw_wait(hid); 1170 1170 1171 1171 /* pool report is sometimes messed up, refetch it */ 1172 1172 hid_hw_request(hid, pidff->reports[PID_POOL], HID_REQ_GET_REPORT); 1173 - usbhid_wait_io(hid); 1173 + hid_hw_wait(hid); 1174 1174 1175 1175 if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { 1176 1176 while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) { ··· 1183 1183 hid_dbg(pidff->hid, "pid_pool requested again\n"); 1184 1184 hid_hw_request(hid, pidff->reports[PID_POOL], 1185 1185 HID_REQ_GET_REPORT); 1186 - usbhid_wait_io(hid); 1186 + hid_hw_wait(hid); 1187 1187 } 1188 1188 } 1189 1189 }
+2 -2
drivers/hid/usbhid/hiddev.c
··· 706 706 break; 707 707 708 708 hid_hw_request(hid, report, HID_REQ_GET_REPORT); 709 - usbhid_wait_io(hid); 709 + hid_hw_wait(hid); 710 710 711 711 r = 0; 712 712 break; ··· 725 725 break; 726 726 727 727 hid_hw_request(hid, report, HID_REQ_SET_REPORT); 728 - usbhid_wait_io(hid); 728 + hid_hw_wait(hid); 729 729 730 730 r = 0; 731 731 break;
-1
drivers/hid/usbhid/usbhid.h
··· 34 34 #include <linux/input.h> 35 35 36 36 /* API provided by hid-core.c for USB HID drivers */ 37 - int usbhid_wait_io(struct hid_device* hid); 38 37 void usbhid_close(struct hid_device *hid); 39 38 int usbhid_open(struct hid_device *hid); 40 39 void usbhid_init_reports(struct hid_device *hid);