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.
This series only converts three users of CONFIG_PM in drivers/hid/ but
most of the others should be convertible, too.
Signed-off-by: Thomas Weißschuh <[email protected]>
---
Thomas Weißschuh (4):
HID: core: remove #ifdef CONFIG_PM from hid_driver
HID: usbhid: remove #ifdef CONFIG_PM
HID: multitouch: remove #ifdef CONFIG_PM
HID: rmi: remove #ifdef CONFIG_PM
drivers/hid/hid-multitouch.c | 10 +++-------
drivers/hid/hid-rmi.c | 10 +++-------
drivers/hid/usbhid/hid-core.c | 11 +++--------
include/linux/hid.h | 4 ++--
4 files changed, 11 insertions(+), 24 deletions(-)
---
base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
change-id: 20231012-hid-pm_ptr-e29ab5ee7ce7
Best regards,
--
Thomas Weißschuh <[email protected]>
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.
Signed-off-by: Thomas Weißschuh <[email protected]>
---
drivers/hid/usbhid/hid-core.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 257dd73e37bf..a90ed2ceae84 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1562,7 +1562,6 @@ static int hid_post_reset(struct usb_interface *intf)
return 0;
}
-#ifdef CONFIG_PM
static int hid_resume_common(struct hid_device *hid, bool driver_suspended)
{
int status = 0;
@@ -1654,8 +1653,6 @@ static int hid_reset_resume(struct usb_interface *intf)
return status;
}
-#endif /* CONFIG_PM */
-
static const struct usb_device_id hid_usb_ids[] = {
{ .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
.bInterfaceClass = USB_INTERFACE_CLASS_HID },
@@ -1668,11 +1665,9 @@ static struct usb_driver hid_driver = {
.name = "usbhid",
.probe = usbhid_probe,
.disconnect = usbhid_disconnect,
-#ifdef CONFIG_PM
- .suspend = hid_suspend,
- .resume = hid_resume,
- .reset_resume = hid_reset_resume,
-#endif
+ .suspend = pm_ptr(hid_suspend),
+ .resume = pm_ptr(hid_resume),
+ .reset_resume = pm_ptr(hid_reset_resume),
.pre_reset = hid_pre_reset,
.post_reset = hid_post_reset,
.id_table = hid_usb_ids,
--
2.42.0
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.
Signed-off-by: Thomas Weißschuh <[email protected]>
---
drivers/hid/hid-rmi.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 84e7ba5314d3..d4af17fdba46 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -436,7 +436,6 @@ static void rmi_report(struct hid_device *hid, struct hid_report *report)
input_sync(field->hidinput->input);
}
-#ifdef CONFIG_PM
static int rmi_suspend(struct hid_device *hdev, pm_message_t message)
{
struct rmi_data *data = hid_get_drvdata(hdev);
@@ -483,7 +482,6 @@ static int rmi_post_resume(struct hid_device *hdev)
hid_hw_close(hdev);
return ret;
}
-#endif /* CONFIG_PM */
static int rmi_hid_reset(struct rmi_transport_dev *xport, u16 reset_addr)
{
@@ -774,11 +772,9 @@ static struct hid_driver rmi_driver = {
.report = rmi_report,
.input_mapping = rmi_input_mapping,
.input_configured = rmi_input_configured,
-#ifdef CONFIG_PM
- .suspend = rmi_suspend,
- .resume = rmi_post_resume,
- .reset_resume = rmi_post_resume,
-#endif
+ .suspend = pm_ptr(rmi_suspend),
+ .resume = pm_ptr(rmi_post_resume),
+ .reset_resume = pm_ptr(rmi_post_resume),
};
module_hid_driver(rmi_driver);
--
2.42.0
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.
Signed-off-by: Thomas Weißschuh <[email protected]>
---
drivers/hid/hid-multitouch.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 521b2ffb4244..2cdfc2a70a83 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1802,7 +1802,6 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
return 0;
}
-#ifdef CONFIG_PM
static int mt_suspend(struct hid_device *hdev, pm_message_t state)
{
struct mt_device *td = hid_get_drvdata(hdev);
@@ -1836,7 +1835,6 @@ static int mt_resume(struct hid_device *hdev)
return 0;
}
-#endif
static void mt_remove(struct hid_device *hdev)
{
@@ -2255,10 +2253,8 @@ static struct hid_driver mt_driver = {
.usage_table = mt_grabbed_usages,
.event = mt_event,
.report = mt_report,
-#ifdef CONFIG_PM
- .suspend = mt_suspend,
- .reset_resume = mt_reset_resume,
- .resume = mt_resume,
-#endif
+ .suspend = pm_ptr(mt_suspend),
+ .reset_resume = pm_ptr(mt_reset_resume),
+ .resume = pm_ptr(mt_resume),
};
module_hid_driver(mt_driver);
--
2.42.0
On Thu, 12 Oct 2023 12:23:37 +0200, Thomas Weißschuh wrote:
> 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.
>
> This series only converts three users of CONFIG_PM in drivers/hid/ but
> most of the others should be convertible, too.
>
> [...]
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git (for-6.7/config_pm), thanks!
[1/4] HID: core: remove #ifdef CONFIG_PM from hid_driver
https://git.kernel.org/hid/hid/c/df8b030d82dd
[2/4] HID: usbhid: remove #ifdef CONFIG_PM
https://git.kernel.org/hid/hid/c/f354872108eb
[3/4] HID: multitouch: remove #ifdef CONFIG_PM
https://git.kernel.org/hid/hid/c/fc2543414c3e
[4/4] HID: rmi: remove #ifdef CONFIG_PM
https://git.kernel.org/hid/hid/c/eeebfe6259ba
Cheers,
--
Benjamin Tissoires <[email protected]>