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

HID: core: remove #ifdef CONFIG_PM from hid_driver

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>

authored by

Thomas Weißschuh and committed by
Benjamin Tissoires
df8b030d bab19d1b

+2 -2
+2 -2
include/linux/hid.h
··· 833 833 void (*feature_mapping)(struct hid_device *hdev, 834 834 struct hid_field *field, 835 835 struct hid_usage *usage); 836 - #ifdef CONFIG_PM 836 + 837 837 int (*suspend)(struct hid_device *hdev, pm_message_t message); 838 838 int (*resume)(struct hid_device *hdev); 839 839 int (*reset_resume)(struct hid_device *hdev); 840 - #endif 840 + 841 841 /* private: */ 842 842 struct device_driver driver; 843 843 };