diff options
author | Hans de Goede <hdegoede@redhat.com> | 2021-05-29 18:14:21 +0300 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2021-06-25 15:02:58 +0300 |
commit | 24e166f43e93de0e9b0a460ecfe4bab1f12212d7 (patch) | |
tree | 742acbeb0c903086fc3008ad795c7a15ee40705d /include/linux/hid.h | |
parent | 231bc539066760aaa44d46818c85b14ca2f56d9f (diff) | |
download | linux-24e166f43e93de0e9b0a460ecfe4bab1f12212d7.tar.xz |
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 <hdegoede@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'include/linux/hid.h')
-rw-r--r-- | include/linux/hid.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/hid.h b/include/linux/hid.h index 10e922cee4eb..51a4dad3565e 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -800,6 +800,7 @@ struct hid_driver { * @raw_request: send raw report request to device (e.g. feature report) * @output_report: send output report to device * @idle: send idle request to device + * @may_wakeup: return if device may act as a wakeup source during system-suspend */ struct hid_ll_driver { int (*start)(struct hid_device *hdev); @@ -824,6 +825,7 @@ struct hid_ll_driver { int (*output_report) (struct hid_device *hdev, __u8 *buf, size_t len); int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype); + bool (*may_wakeup)(struct hid_device *hdev); }; extern struct hid_ll_driver i2c_hid_ll_driver; @@ -1150,6 +1152,22 @@ static inline int hid_hw_idle(struct hid_device *hdev, int report, int idle, } /** + * hid_may_wakeup - return if the hid device may act as a wakeup source during system-suspend + * + * @hdev: hid device + */ +static inline bool hid_hw_may_wakeup(struct hid_device *hdev) +{ + if (hdev->ll_driver->may_wakeup) + return hdev->ll_driver->may_wakeup(hdev); + + if (hdev->dev.parent) + return device_may_wakeup(hdev->dev.parent); + + return false; +} + +/** * hid_hw_wait - wait for buffered io to complete * * @hdev: hid device |