Skip to content

Commit 24e166f

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
HID: core: Add hid_hw_may_wakeup() function
Add a hid_hw_may_wakeup() function, which is the equivalent of device_may_wakeup() for hid devices. In most cases this just returns device_may_wakeup(hdev->dev.parent), but for some ll-drivers this is not correct. E.g. usb_hid_driver instantiated hid devices have their parent set to the usb-interface to which the usb_hid_driver is bound, but the power/wakeup* sysfs attributes are part of the usb-device, which is the usb-interface's parent. For these special cases a new may_wakeup callback is added to hid_ll_driver, so that ll-drivers can override the default behavior. Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 231bc53 commit 24e166f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

include/linux/hid.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ struct hid_driver {
800800
* @raw_request: send raw report request to device (e.g. feature report)
801801
* @output_report: send output report to device
802802
* @idle: send idle request to device
803+
* @may_wakeup: return if device may act as a wakeup source during system-suspend
803804
*/
804805
struct hid_ll_driver {
805806
int (*start)(struct hid_device *hdev);
@@ -824,6 +825,7 @@ struct hid_ll_driver {
824825
int (*output_report) (struct hid_device *hdev, __u8 *buf, size_t len);
825826

826827
int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
828+
bool (*may_wakeup)(struct hid_device *hdev);
827829
};
828830

829831
extern struct hid_ll_driver i2c_hid_ll_driver;
@@ -1149,6 +1151,22 @@ static inline int hid_hw_idle(struct hid_device *hdev, int report, int idle,
11491151
return 0;
11501152
}
11511153

1154+
/**
1155+
* hid_may_wakeup - return if the hid device may act as a wakeup source during system-suspend
1156+
*
1157+
* @hdev: hid device
1158+
*/
1159+
static inline bool hid_hw_may_wakeup(struct hid_device *hdev)
1160+
{
1161+
if (hdev->ll_driver->may_wakeup)
1162+
return hdev->ll_driver->may_wakeup(hdev);
1163+
1164+
if (hdev->dev.parent)
1165+
return device_may_wakeup(hdev->dev.parent);
1166+
1167+
return false;
1168+
}
1169+
11521170
/**
11531171
* hid_hw_wait - wait for buffered io to complete
11541172
*

0 commit comments

Comments
 (0)