Skip to content

Commit

Permalink
HID: core: remove #ifdef CONFIG_PM from hid_driver
Browse files Browse the repository at this point in the history
Allow HID drivers to pass ->suspend, ->resume and ->reset_resume via
pm_ptr().
Through the usage of pm_ptr() the CONFIG_PM-dependent code will always be
compiled, protecting against bitrot.
The linker will then garbage-collect the unused function avoiding any overhead.

The only overhead in the final kernel image and at runtime are a few
extra bytes in 'struct hid_driver'.

The same approach is chosen by 'struct usb_driver' and other subsystems.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20231012-hid-pm_ptr-v1-1-0a71531ca93b@weissschuh.net
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
  • Loading branch information
Thomas Weißschuh authored and Benjamin Tissoires committed Oct 25, 2023
1 parent bab19d1 commit df8b030
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/linux/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,11 @@ struct hid_driver {
void (*feature_mapping)(struct hid_device *hdev,
struct hid_field *field,
struct hid_usage *usage);
#ifdef CONFIG_PM

int (*suspend)(struct hid_device *hdev, pm_message_t message);
int (*resume)(struct hid_device *hdev);
int (*reset_resume)(struct hid_device *hdev);
#endif

/* private: */
struct device_driver driver;
};
Expand Down

0 comments on commit df8b030

Please sign in to comment.