Skip to content

Commit 9a83563

Browse files
dtorJiri Kosina
authored andcommitted
HID: hiddev: use hid_hw_power instead of usbhid_get/put_power
Instead of calling into usbhid code directly, let's use the standard accessors for the transport HID drivers, and stop clobbering their error codes with -EIO. This also allows us to remove usbhid_get/put_power(), leaving only usbhid_power(). Signed-off-by: Dmitry Torokhov <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent d36b7d4 commit 9a83563

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

drivers/hid/usbhid/hid-core.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,16 +1203,19 @@ static void usbhid_stop(struct hid_device *hid)
12031203

12041204
static int usbhid_power(struct hid_device *hid, int lvl)
12051205
{
1206+
struct usbhid_device *usbhid = hid->driver_data;
12061207
int r = 0;
12071208

12081209
switch (lvl) {
12091210
case PM_HINT_FULLON:
1210-
r = usbhid_get_power(hid);
1211+
r = usb_autopm_get_interface(usbhid->intf);
12111212
break;
1213+
12121214
case PM_HINT_NORMAL:
1213-
usbhid_put_power(hid);
1215+
usb_autopm_put_interface(usbhid->intf);
12141216
break;
12151217
}
1218+
12161219
return r;
12171220
}
12181221

@@ -1492,21 +1495,6 @@ static int hid_post_reset(struct usb_interface *intf)
14921495
return 0;
14931496
}
14941497

1495-
int usbhid_get_power(struct hid_device *hid)
1496-
{
1497-
struct usbhid_device *usbhid = hid->driver_data;
1498-
1499-
return usb_autopm_get_interface(usbhid->intf);
1500-
}
1501-
1502-
void usbhid_put_power(struct hid_device *hid)
1503-
{
1504-
struct usbhid_device *usbhid = hid->driver_data;
1505-
1506-
usb_autopm_put_interface(usbhid->intf);
1507-
}
1508-
1509-
15101498
#ifdef CONFIG_PM
15111499
static int hid_resume_common(struct hid_device *hid, bool driver_suspended)
15121500
{

drivers/hid/usbhid/hiddev.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int hiddev_release(struct inode * inode, struct file * file)
238238
if (!--list->hiddev->open) {
239239
if (list->hiddev->exist) {
240240
hid_hw_close(list->hiddev->hid);
241-
usbhid_put_power(list->hiddev->hid);
241+
hid_hw_power(list->hiddev->hid, PM_HINT_NORMAL);
242242
} else {
243243
mutex_unlock(&list->hiddev->existancelock);
244244
kfree(list->hiddev);
@@ -299,19 +299,17 @@ static int hiddev_open(struct inode *inode, struct file *file)
299299
if (!list->hiddev->open++)
300300
if (list->hiddev->exist) {
301301
struct hid_device *hid = hiddev->hid;
302-
res = usbhid_get_power(hid);
303-
if (res < 0) {
304-
res = -EIO;
302+
res = hid_hw_power(hid, PM_HINT_FULLON);
303+
if (res < 0)
305304
goto bail_unlock;
306-
}
307305
res = hid_hw_open(hid);
308306
if (res < 0)
309-
goto bail_put_power;
307+
goto bail_normal_power;
310308
}
311309
mutex_unlock(&hiddev->existancelock);
312310
return 0;
313-
bail_put_power:
314-
usbhid_put_power(hid);
311+
bail_normal_power:
312+
hid_hw_power(hid, PM_HINT_NORMAL);
315313
bail_unlock:
316314
mutex_unlock(&hiddev->existancelock);
317315
bail:

drivers/hid/usbhid/usbhid.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535

3636
/* API provided by hid-core.c for USB HID drivers */
3737
void usbhid_init_reports(struct hid_device *hid);
38-
int usbhid_get_power(struct hid_device *hid);
39-
void usbhid_put_power(struct hid_device *hid);
4038
struct usb_interface *usbhid_find_interface(int minor);
4139

4240
/* iofl flags */

0 commit comments

Comments
 (0)