linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/16] Input: Switch to new PM macros set 3
@ 2023-01-14 17:16 Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 01/16] Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr() Jonathan Cameron
                   ` (16 more replies)
  0 siblings, 17 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov
  Cc: jic23, Jonathan Cameron, Hans de Goede, Caleb Connolly,
	Andi Shyti, Matthias Schiffer, Lyude Paul, Andrew Duggan,
	Michael Hennerich, Javier Martinez Canillas, Linus Walleij

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Continuation of
https://lore.kernel.org/all/20230102181842.718010-1-jic23@kernel.org/

This time we have most of the remaining drivers where the changes needed
are more complex than the earlier straight conversions.

A separate series will deal with pm80x as the cleanup for that will
extend to MFD and RTC trees and cannot easily be broken up due to
some changes in exports.

There is a general mixture of cases in here:
1) More complex direct conversions - typically drivers with separate
   sleep and runtime pm ops.
2) Cases where the callbacks or struct dev_pm_ops is exported to
   multiple modules.
3) Refactors that avoid duplication of callbacks or exports.
4) A tweak to the core input handling to use the new macros - this
   is different from the driver changes, but seemed sensible.

Note there are a few cases in here where I a much more minimal
set of callbacks is provided than DEFINE_SIMPLE_DEV_PM_OPS() and
friends would set. I don't know the history behind those so whilst
they might well be fine converted to the generic macros, I've
left them alone.

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Caleb Connolly <caleb@connolly.tech>
Cc: Andi Shyti <andi@etezian.org>
Cc: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Andrew Duggan <aduggan@synaptics.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Javier Martinez Canillas <javier@dowhile0.org>
Cc: Linus Walleij <linus.walleij@linaro.org>

Jonathan Cameron (16):
  Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr()
  Input: axp20x-pek - switch to SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr()
  Input: samsung-keypad - switch to pm_ptr() and
    SYSTEM_SLEEP/RUNTIME_PM_OPS()
  Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
  Input: rmi4 - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr()
  Input: stmfts - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
  Input: ad714x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
  Input: adxl34x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
  Input: tsc200x - use EXPORT_GPL_SIMPLE_DEV_PM_OPS()
  Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS()
  Input: cyttsp - use EXPORT_GPL_SIMPLE_DEV_PM_OPS()
  Input: applespi - use pm_sleep_ptr() and SYSTEM_SLEEP_PM_OPS()
  Input: omap4-keyad - use pm_ptr() and RUNTIME_DEV_PM_OPS()
  Input: Use pm_sleep_ptr() to avoid need for ifdef CONFIG_PM_SLEEP
  Input: cma3000 - use pm_sleep_ptr() to allow removal of ifdef
    CONFIG_PM guards
  Input: wistron_btns -  use pm_sleep_ptr() to allow removal of ifdef
    CONFIG_PM guards

 drivers/input/input.c                    |  7 ++-----
 drivers/input/keyboard/applespi.c        | 10 +++++-----
 drivers/input/keyboard/omap4-keypad.c    |  6 +++---
 drivers/input/keyboard/samsung-keypad.c  | 12 ++++--------
 drivers/input/misc/ad714x-i2c.c          | 14 +------------
 drivers/input/misc/ad714x-spi.c          | 14 +------------
 drivers/input/misc/ad714x.c              | 12 ++++++------
 drivers/input/misc/ad714x.h              |  4 ++--
 drivers/input/misc/adxl34x-i2c.c         | 25 +-----------------------
 drivers/input/misc/adxl34x-spi.c         | 25 +-----------------------
 drivers/input/misc/adxl34x.c             | 16 +++++++++++----
 drivers/input/misc/adxl34x.h             |  4 ++--
 drivers/input/misc/axp20x-pek.c          | 12 +++++-------
 drivers/input/misc/cma3000_d0x_i2c.c     |  6 +-----
 drivers/input/misc/wistron_btns.c        |  6 +-----
 drivers/input/mouse/cyapa.c              | 14 ++++++-------
 drivers/input/rmi4/rmi_i2c.c             | 11 +++--------
 drivers/input/rmi4/rmi_smbus.c           | 15 +++++++-------
 drivers/input/rmi4/rmi_spi.c             | 11 +++--------
 drivers/input/touchscreen/cyttsp4_core.c |  9 ++-------
 drivers/input/touchscreen/cyttsp4_i2c.c  |  2 +-
 drivers/input/touchscreen/cyttsp4_spi.c  |  2 +-
 drivers/input/touchscreen/cyttsp_core.c  |  7 +++----
 drivers/input/touchscreen/cyttsp_i2c.c   |  2 +-
 drivers/input/touchscreen/cyttsp_spi.c   |  2 +-
 drivers/input/touchscreen/s6sy761.c      | 15 +++++++-------
 drivers/input/touchscreen/stmfts.c       | 14 ++++++-------
 drivers/input/touchscreen/tsc2004.c      |  2 +-
 drivers/input/touchscreen/tsc2005.c      |  2 +-
 drivers/input/touchscreen/tsc200x-core.c |  7 +++----
 30 files changed, 95 insertions(+), 193 deletions(-)

-- 
2.39.0


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 01/16] Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 02/16] Input: axp20x-pek - switch to SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr() Jonathan Cameron
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated as
they require explicit protection against unused function warnings.
The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/
RUNTIME_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/mouse/cyapa.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index 7e88a6ec7989..dd7b0d70d791 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -1349,7 +1349,7 @@ static int cyapa_probe(struct i2c_client *client)
 	return 0;
 }
 
-static int __maybe_unused cyapa_suspend(struct device *dev)
+static int cyapa_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct cyapa *cyapa = i2c_get_clientdata(client);
@@ -1397,7 +1397,7 @@ static int __maybe_unused cyapa_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused cyapa_resume(struct device *dev)
+static int cyapa_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct cyapa *cyapa = i2c_get_clientdata(client);
@@ -1424,7 +1424,7 @@ static int __maybe_unused cyapa_resume(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused cyapa_runtime_suspend(struct device *dev)
+static int cyapa_runtime_suspend(struct device *dev)
 {
 	struct cyapa *cyapa = dev_get_drvdata(dev);
 	int error;
@@ -1439,7 +1439,7 @@ static int __maybe_unused cyapa_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused cyapa_runtime_resume(struct device *dev)
+static int cyapa_runtime_resume(struct device *dev)
 {
 	struct cyapa *cyapa = dev_get_drvdata(dev);
 	int error;
@@ -1453,8 +1453,8 @@ static int __maybe_unused cyapa_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops cyapa_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(cyapa_suspend, cyapa_resume)
-	SET_RUNTIME_PM_OPS(cyapa_runtime_suspend, cyapa_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(cyapa_suspend, cyapa_resume)
+	RUNTIME_PM_OPS(cyapa_runtime_suspend, cyapa_runtime_resume, NULL)
 };
 
 static const struct i2c_device_id cyapa_id_table[] = {
@@ -1484,7 +1484,7 @@ MODULE_DEVICE_TABLE(of, cyapa_of_match);
 static struct i2c_driver cyapa_driver = {
 	.driver = {
 		.name = "cyapa",
-		.pm = &cyapa_pm_ops,
+		.pm = pm_ptr(&cyapa_pm_ops),
 		.acpi_match_table = ACPI_PTR(cyapa_acpi_id),
 		.of_match_table = of_match_ptr(cyapa_of_match),
 	},
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 02/16] Input: axp20x-pek - switch to SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 01/16] Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 03/16] Input: samsung-keypad - switch to pm_ptr() and SYSTEM_SLEEP/RUNTIME_PM_OPS() Jonathan Cameron
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron, Hans de Goede

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_sleep_ptr()
and SYSTEM_SLEEP_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.  Here the
additional .resume_noirq callback is protected with pm_sleep_ptr(). This
isn't strictly necessary but is done for consistency with the other
callbacks.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/misc/axp20x-pek.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 04da7916eb70..4581606a28d6 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -336,7 +336,7 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __maybe_unused axp20x_pek_suspend(struct device *dev)
+static int axp20x_pek_suspend(struct device *dev)
 {
 	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
 
@@ -355,7 +355,7 @@ static int __maybe_unused axp20x_pek_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused axp20x_pek_resume(struct device *dev)
+static int axp20x_pek_resume(struct device *dev)
 {
 	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
 
@@ -389,10 +389,8 @@ static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
 }
 
 static const struct dev_pm_ops axp20x_pek_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume)
-#ifdef CONFIG_PM_SLEEP
-	.resume_noirq = axp20x_pek_resume_noirq,
-#endif
+	SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume)
+	.resume_noirq = pm_sleep_ptr(axp20x_pek_resume_noirq),
 };
 
 static const struct platform_device_id axp_pek_id_match[] = {
@@ -413,7 +411,7 @@ static struct platform_driver axp20x_pek_driver = {
 	.id_table	= axp_pek_id_match,
 	.driver		= {
 		.name		= "axp20x-pek",
-		.pm		= &axp20x_pek_pm_ops,
+		.pm		= pm_sleep_ptr(&axp20x_pek_pm_ops),
 		.dev_groups	= axp20x_groups,
 	},
 };
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 03/16] Input: samsung-keypad - switch to pm_ptr() and SYSTEM_SLEEP/RUNTIME_PM_OPS()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 01/16] Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr() Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 02/16] Input: axp20x-pek - switch to SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 04/16] Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr() Jonathan Cameron
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The SET_ variants are deprecated as they require explicit protection
against unused function warnings.  The new combination of pm_ptr()
and SYSTEM_SLEEP/RUNTIME_DEV_PM_OPS() allow the compiler to see the
functions, thus suppressing the warning, but still allowing the unused
code to be removed. Thus also drop the #ifdef guards.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/keyboard/samsung-keypad.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index df0258dcf89e..09e883ea1352 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -458,7 +458,6 @@ static int samsung_keypad_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int samsung_keypad_runtime_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -503,9 +502,7 @@ static int samsung_keypad_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM_SLEEP
 static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad,
 					 bool enable)
 {
@@ -563,12 +560,11 @@ static int samsung_keypad_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops samsung_keypad_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(samsung_keypad_suspend, samsung_keypad_resume)
-	SET_RUNTIME_PM_OPS(samsung_keypad_runtime_suspend,
-			   samsung_keypad_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(samsung_keypad_suspend, samsung_keypad_resume)
+	RUNTIME_PM_OPS(samsung_keypad_runtime_suspend,
+		       samsung_keypad_runtime_resume, NULL)
 };
 
 #ifdef CONFIG_OF
@@ -598,7 +594,7 @@ static struct platform_driver samsung_keypad_driver = {
 	.driver		= {
 		.name	= "samsung-keypad",
 		.of_match_table = of_match_ptr(samsung_keypad_dt_match),
-		.pm	= &samsung_keypad_pm_ops,
+		.pm	= pm_ptr(&samsung_keypad_pm_ops),
 	},
 	.id_table	= samsung_keypad_driver_ids,
 };
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 04/16] Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (2 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 03/16] Input: samsung-keypad - switch to pm_ptr() and SYSTEM_SLEEP/RUNTIME_PM_OPS() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-16 14:20   ` Caleb Connolly
  2023-01-14 17:16 ` [PATCH 05/16] Input: rmi4 - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() " Jonathan Cameron
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov
  Cc: jic23, Jonathan Cameron, Caleb Connolly, Andi Shyti

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated as
they require explicit protection against unused function warnings.
The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/
RUNTIME_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Caleb Connolly <caleb@connolly.tech>
Cc: Andi Shyti <andi@etezian.org>
---
 drivers/input/touchscreen/s6sy761.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
index cc417c03aaca..371cf4848ad5 100644
--- a/drivers/input/touchscreen/s6sy761.c
+++ b/drivers/input/touchscreen/s6sy761.c
@@ -479,7 +479,7 @@ static void s6sy761_remove(struct i2c_client *client)
 	pm_runtime_disable(&client->dev);
 }
 
-static int __maybe_unused s6sy761_runtime_suspend(struct device *dev)
+static int s6sy761_runtime_suspend(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
 
@@ -487,7 +487,7 @@ static int __maybe_unused s6sy761_runtime_suspend(struct device *dev)
 				S6SY761_APPLICATION_MODE, S6SY761_APP_SLEEP);
 }
 
-static int __maybe_unused s6sy761_runtime_resume(struct device *dev)
+static int s6sy761_runtime_resume(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
 
@@ -495,7 +495,7 @@ static int __maybe_unused s6sy761_runtime_resume(struct device *dev)
 				S6SY761_APPLICATION_MODE, S6SY761_APP_NORMAL);
 }
 
-static int __maybe_unused s6sy761_suspend(struct device *dev)
+static int s6sy761_suspend(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
 
@@ -504,7 +504,7 @@ static int __maybe_unused s6sy761_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused s6sy761_resume(struct device *dev)
+static int s6sy761_resume(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
 
@@ -514,9 +514,8 @@ static int __maybe_unused s6sy761_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops s6sy761_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(s6sy761_suspend, s6sy761_resume)
-	SET_RUNTIME_PM_OPS(s6sy761_runtime_suspend,
-				s6sy761_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(s6sy761_suspend, s6sy761_resume)
+	RUNTIME_PM_OPS(s6sy761_runtime_suspend, s6sy761_runtime_resume, NULL)
 };
 
 #ifdef CONFIG_OF
@@ -537,7 +536,7 @@ static struct i2c_driver s6sy761_driver = {
 	.driver = {
 		.name = S6SY761_DEV_NAME,
 		.of_match_table = of_match_ptr(s6sy761_of_match),
-		.pm = &s6sy761_pm_ops,
+		.pm = pm_ptr(&s6sy761_pm_ops),
 	},
 	.probe_new = s6sy761_probe,
 	.remove = s6sy761_remove,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 05/16] Input: rmi4 - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (3 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 04/16] Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 06/16] Input: stmfts - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() " Jonathan Cameron
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov
  Cc: jic23, Jonathan Cameron, Matthias Schiffer, Lyude Paul, Andrew Duggan

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated
as they requires explicit protection against unused function warnings.
The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS() /
RUNTIME_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to
be removed. Thus also drop the #ifdef guards.

Whilst all 3 sets of callbacks are similar, there are small differences
that make it challenging to use a single pm_dev_ops structure - hence
leave the duplication as it stands.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Andrew Duggan <aduggan@synaptics.com>
---
 drivers/input/rmi4/rmi_i2c.c   | 11 +++--------
 drivers/input/rmi4/rmi_smbus.c | 15 +++++++--------
 drivers/input/rmi4/rmi_spi.c   | 11 +++--------
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index f2b75c6d3224..d69569ce8d8d 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -287,7 +287,6 @@ static int rmi_i2c_probe(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int rmi_i2c_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -323,9 +322,7 @@ static int rmi_i2c_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int rmi_i2c_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -361,12 +358,10 @@ static int rmi_i2c_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rmi_i2c_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(rmi_i2c_suspend, rmi_i2c_resume)
-	SET_RUNTIME_PM_OPS(rmi_i2c_runtime_suspend, rmi_i2c_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(rmi_i2c_suspend, rmi_i2c_resume)
+	RUNTIME_PM_OPS(rmi_i2c_runtime_suspend, rmi_i2c_runtime_resume, NULL)
 };
 
 static const struct i2c_device_id rmi_id[] = {
@@ -378,7 +373,7 @@ MODULE_DEVICE_TABLE(i2c, rmi_id);
 static struct i2c_driver rmi_i2c_driver = {
 	.driver = {
 		.name	= "rmi4_i2c",
-		.pm	= &rmi_i2c_pm,
+		.pm	= pm_ptr(&rmi_i2c_pm),
 		.of_match_table = of_match_ptr(rmi_i2c_of_match),
 	},
 	.id_table	= rmi_id,
diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c
index 8a9ee2bd7402..4bf0e1df6a4a 100644
--- a/drivers/input/rmi4/rmi_smbus.c
+++ b/drivers/input/rmi4/rmi_smbus.c
@@ -344,7 +344,7 @@ static void rmi_smb_remove(struct i2c_client *client)
 	rmi_unregister_transport_device(&rmi_smb->xport);
 }
 
-static int __maybe_unused rmi_smb_suspend(struct device *dev)
+static int rmi_smb_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
@@ -357,7 +357,7 @@ static int __maybe_unused rmi_smb_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused rmi_smb_runtime_suspend(struct device *dev)
+static int rmi_smb_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
@@ -370,7 +370,7 @@ static int __maybe_unused rmi_smb_runtime_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused rmi_smb_resume(struct device *dev)
+static int rmi_smb_resume(struct device *dev)
 {
 	struct i2c_client *client = container_of(dev, struct i2c_client, dev);
 	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
@@ -388,7 +388,7 @@ static int __maybe_unused rmi_smb_resume(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused rmi_smb_runtime_resume(struct device *dev)
+static int rmi_smb_runtime_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
@@ -402,9 +402,8 @@ static int __maybe_unused rmi_smb_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rmi_smb_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(rmi_smb_suspend, rmi_smb_resume)
-	SET_RUNTIME_PM_OPS(rmi_smb_runtime_suspend, rmi_smb_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(rmi_smb_suspend, rmi_smb_resume)
+	RUNTIME_PM_OPS(rmi_smb_runtime_suspend, rmi_smb_runtime_resume, NULL)
 };
 
 static const struct i2c_device_id rmi_id[] = {
@@ -416,7 +415,7 @@ MODULE_DEVICE_TABLE(i2c, rmi_id);
 static struct i2c_driver rmi_smb_driver = {
 	.driver = {
 		.name	= "rmi4_smbus",
-		.pm	= &rmi_smb_pm,
+		.pm	= pm_ptr(&rmi_smb_pm),
 	},
 	.id_table	= rmi_id,
 	.probe_new	= rmi_smb_probe,
diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c
index c82edda66b23..c5c5e7f3401e 100644
--- a/drivers/input/rmi4/rmi_spi.c
+++ b/drivers/input/rmi4/rmi_spi.c
@@ -447,7 +447,6 @@ static int rmi_spi_probe(struct spi_device *spi)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int rmi_spi_suspend(struct device *dev)
 {
 	struct spi_device *spi = to_spi_device(dev);
@@ -473,9 +472,7 @@ static int rmi_spi_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int rmi_spi_runtime_suspend(struct device *dev)
 {
 	struct spi_device *spi = to_spi_device(dev);
@@ -501,12 +498,10 @@ static int rmi_spi_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rmi_spi_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(rmi_spi_suspend, rmi_spi_resume)
-	SET_RUNTIME_PM_OPS(rmi_spi_runtime_suspend, rmi_spi_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(rmi_spi_suspend, rmi_spi_resume)
+	RUNTIME_PM_OPS(rmi_spi_runtime_suspend, rmi_spi_runtime_resume, NULL)
 };
 
 static const struct spi_device_id rmi_id[] = {
@@ -518,7 +513,7 @@ MODULE_DEVICE_TABLE(spi, rmi_id);
 static struct spi_driver rmi_spi_driver = {
 	.driver = {
 		.name	= "rmi4_spi",
-		.pm	= &rmi_spi_pm,
+		.pm	= pm_ptr(&rmi_spi_pm),
 		.of_match_table = of_match_ptr(rmi_spi_of_match),
 	},
 	.id_table	= rmi_id,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 06/16] Input: stmfts - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (4 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 05/16] Input: rmi4 - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() " Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 07/16] Input: ad714x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS() Jonathan Cameron
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron, Andi Shyti

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated as
they require explicit protection against unused function warnings.
The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/
RUNTIME_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andi Shyti <andi@etezian.org>
---
 drivers/input/touchscreen/stmfts.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
index d092e89d40e8..fdbf5e68943c 100644
--- a/drivers/input/touchscreen/stmfts.c
+++ b/drivers/input/touchscreen/stmfts.c
@@ -742,7 +742,7 @@ static void stmfts_remove(struct i2c_client *client)
 	pm_runtime_disable(&client->dev);
 }
 
-static int __maybe_unused stmfts_runtime_suspend(struct device *dev)
+static int stmfts_runtime_suspend(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
 	int ret;
@@ -754,7 +754,7 @@ static int __maybe_unused stmfts_runtime_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused stmfts_runtime_resume(struct device *dev)
+static int stmfts_runtime_resume(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
 	int ret;
@@ -766,7 +766,7 @@ static int __maybe_unused stmfts_runtime_resume(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused stmfts_suspend(struct device *dev)
+static int stmfts_suspend(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
 
@@ -775,7 +775,7 @@ static int __maybe_unused stmfts_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused stmfts_resume(struct device *dev)
+static int stmfts_resume(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
 
@@ -783,8 +783,8 @@ static int __maybe_unused stmfts_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops stmfts_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(stmfts_suspend, stmfts_resume)
-	SET_RUNTIME_PM_OPS(stmfts_runtime_suspend, stmfts_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(stmfts_suspend, stmfts_resume)
+	RUNTIME_PM_OPS(stmfts_runtime_suspend, stmfts_runtime_resume, NULL)
 };
 
 #ifdef CONFIG_OF
@@ -805,7 +805,7 @@ static struct i2c_driver stmfts_driver = {
 	.driver = {
 		.name = STMFTS_DEV_NAME,
 		.of_match_table = of_match_ptr(stmfts_of_match),
-		.pm = &stmfts_pm_ops,
+		.pm = pm_ptr(&stmfts_pm_ops),
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 	},
 	.probe_new = stmfts_probe,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 07/16] Input: ad714x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (5 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 06/16] Input: stmfts - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() " Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 08/16] Input: adxl34x " Jonathan Cameron
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron, Michael Hennerich

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The I2C and SPI PM callbacks were identical (though wrapped in some
bouncing out to the bus specific container of the struct device and
then back again to get the drvdata). As such rather than just moving
these to SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() take the opportunity
to unify the struct dev_pm_ops and use the new EXPORT_SIMPLE_DEV_PM_OPS()
macro so that we can drop the unused suspend and resume callbacks as well
as the structure if !CONFIG_PM_SLEEP without needing to mark the callbacks
__maybe_unused.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/input/misc/ad714x-i2c.c | 14 +-------------
 drivers/input/misc/ad714x-spi.c | 14 +-------------
 drivers/input/misc/ad714x.c     | 12 ++++++------
 drivers/input/misc/ad714x.h     |  4 ++--
 4 files changed, 10 insertions(+), 34 deletions(-)

diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c
index 5ef518a50e63..d8e39f4a57ac 100644
--- a/drivers/input/misc/ad714x-i2c.c
+++ b/drivers/input/misc/ad714x-i2c.c
@@ -12,18 +12,6 @@
 #include <linux/pm.h>
 #include "ad714x.h"
 
-static int __maybe_unused ad714x_i2c_suspend(struct device *dev)
-{
-	return ad714x_disable(i2c_get_clientdata(to_i2c_client(dev)));
-}
-
-static int __maybe_unused ad714x_i2c_resume(struct device *dev)
-{
-	return ad714x_enable(i2c_get_clientdata(to_i2c_client(dev)));
-}
-
-static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume);
-
 static int ad714x_i2c_write(struct ad714x_chip *chip,
 			    unsigned short reg, unsigned short data)
 {
@@ -96,7 +84,7 @@ MODULE_DEVICE_TABLE(i2c, ad714x_id);
 static struct i2c_driver ad714x_i2c_driver = {
 	.driver = {
 		.name = "ad714x_captouch",
-		.pm   = &ad714x_i2c_pm,
+		.pm   = pm_sleep_ptr(&ad714x_pm),
 	},
 	.probe_new = ad714x_i2c_probe,
 	.id_table = ad714x_id,
diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c
index 7d3bf434620f..eb13b4cd6594 100644
--- a/drivers/input/misc/ad714x-spi.c
+++ b/drivers/input/misc/ad714x-spi.c
@@ -15,18 +15,6 @@
 #define AD714x_SPI_CMD_PREFIX      0xE000   /* bits 15:11 */
 #define AD714x_SPI_READ            BIT(10)
 
-static int __maybe_unused ad714x_spi_suspend(struct device *dev)
-{
-	return ad714x_disable(spi_get_drvdata(to_spi_device(dev)));
-}
-
-static int __maybe_unused ad714x_spi_resume(struct device *dev)
-{
-	return ad714x_enable(spi_get_drvdata(to_spi_device(dev)));
-}
-
-static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume);
-
 static int ad714x_spi_read(struct ad714x_chip *chip,
 			   unsigned short reg, unsigned short *data, size_t len)
 {
@@ -103,7 +91,7 @@ static int ad714x_spi_probe(struct spi_device *spi)
 static struct spi_driver ad714x_spi_driver = {
 	.driver = {
 		.name	= "ad714x_captouch",
-		.pm	= &ad714x_spi_pm,
+		.pm	= pm_sleep_ptr(&ad714x_pm),
 	},
 	.probe		= ad714x_spi_probe,
 };
diff --git a/drivers/input/misc/ad714x.c b/drivers/input/misc/ad714x.c
index 43132d98feda..1acd8429c56c 100644
--- a/drivers/input/misc/ad714x.c
+++ b/drivers/input/misc/ad714x.c
@@ -1162,9 +1162,9 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
 }
 EXPORT_SYMBOL(ad714x_probe);
 
-#ifdef CONFIG_PM
-int ad714x_disable(struct ad714x_chip *ad714x)
+static int ad714x_suspend(struct device *dev)
 {
+	struct ad714x_chip *ad714x = dev_get_drvdata(dev);
 	unsigned short data;
 
 	dev_dbg(ad714x->dev, "%s enter\n", __func__);
@@ -1178,10 +1178,10 @@ int ad714x_disable(struct ad714x_chip *ad714x)
 
 	return 0;
 }
-EXPORT_SYMBOL(ad714x_disable);
 
-int ad714x_enable(struct ad714x_chip *ad714x)
+static int ad714x_resume(struct device *dev)
 {
+	struct ad714x_chip *ad714x = dev_get_drvdata(dev);
 	dev_dbg(ad714x->dev, "%s enter\n", __func__);
 
 	mutex_lock(&ad714x->mutex);
@@ -1201,8 +1201,8 @@ int ad714x_enable(struct ad714x_chip *ad714x)
 
 	return 0;
 }
-EXPORT_SYMBOL(ad714x_enable);
-#endif
+
+EXPORT_SIMPLE_DEV_PM_OPS(ad714x_pm, ad714x_suspend, ad714x_resume);
 
 MODULE_DESCRIPTION("Analog Devices AD714X Capacitance Touch Sensor Driver");
 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
diff --git a/drivers/input/misc/ad714x.h b/drivers/input/misc/ad714x.h
index af847b5f0d0e..dafa12325f27 100644
--- a/drivers/input/misc/ad714x.h
+++ b/drivers/input/misc/ad714x.h
@@ -8,6 +8,7 @@
 #ifndef _AD714X_H_
 #define _AD714X_H_
 
+#include <linux/pm.h>
 #include <linux/types.h>
 
 #define STAGE_NUM              12
@@ -45,8 +46,7 @@ struct ad714x_chip {
 
 };
 
-int ad714x_disable(struct ad714x_chip *ad714x);
-int ad714x_enable(struct ad714x_chip *ad714x);
+extern const struct dev_pm_ops ad714x_pm;
 struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
 				 ad714x_read_t read, ad714x_write_t write);
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 08/16] Input: adxl34x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (6 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 07/16] Input: ad714x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 09/16] Input: tsc200x - use EXPORT_GPL_SIMPLE_DEV_PM_OPS() Jonathan Cameron
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron, Michael Hennerich

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The I2C and SPI PM callbacks were identical (though wrapped in some
bouncing out to the bus specific container of the struct device and
then back again to get the drvdata).  As such rather than just moving
these to SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() take the opportunity
to unify the struct dev_pm_ops and use the new EXPORT_SIMPLE_DEV_PM_OPS()
macro so that we can drop the unused suspend and resume callbacks as well
as the structure if !CONFIG_PM_SLEEP without needing to mark the callbacks
__maybe_unused.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/input/misc/adxl34x-i2c.c | 25 +------------------------
 drivers/input/misc/adxl34x-spi.c | 25 +------------------------
 drivers/input/misc/adxl34x.c     | 16 ++++++++++++----
 drivers/input/misc/adxl34x.h     |  4 ++--
 4 files changed, 16 insertions(+), 54 deletions(-)

diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c
index a8ceea36d80a..1c75d98c85a7 100644
--- a/drivers/input/misc/adxl34x-i2c.c
+++ b/drivers/input/misc/adxl34x-i2c.c
@@ -105,29 +105,6 @@ static void adxl34x_i2c_remove(struct i2c_client *client)
 	adxl34x_remove(ac);
 }
 
-static int __maybe_unused adxl34x_i2c_suspend(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adxl34x *ac = i2c_get_clientdata(client);
-
-	adxl34x_suspend(ac);
-
-	return 0;
-}
-
-static int __maybe_unused adxl34x_i2c_resume(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adxl34x *ac = i2c_get_clientdata(client);
-
-	adxl34x_resume(ac);
-
-	return 0;
-}
-
-static SIMPLE_DEV_PM_OPS(adxl34x_i2c_pm, adxl34x_i2c_suspend,
-			 adxl34x_i2c_resume);
-
 static const struct i2c_device_id adxl34x_id[] = {
 	{ "adxl34x", 0 },
 	{ }
@@ -155,7 +132,7 @@ MODULE_DEVICE_TABLE(of, adxl34x_of_id);
 static struct i2c_driver adxl34x_driver = {
 	.driver = {
 		.name = "adxl34x",
-		.pm = &adxl34x_i2c_pm,
+		.pm = pm_sleep_ptr(&adxl34x_pm),
 		.of_match_table = adxl34x_of_id,
 	},
 	.probe_new = adxl34x_i2c_probe,
diff --git a/drivers/input/misc/adxl34x-spi.c b/drivers/input/misc/adxl34x-spi.c
index 91e44d4c66f7..f1094a8ccdd5 100644
--- a/drivers/input/misc/adxl34x-spi.c
+++ b/drivers/input/misc/adxl34x-spi.c
@@ -94,33 +94,10 @@ static void adxl34x_spi_remove(struct spi_device *spi)
 	adxl34x_remove(ac);
 }
 
-static int __maybe_unused adxl34x_spi_suspend(struct device *dev)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct adxl34x *ac = spi_get_drvdata(spi);
-
-	adxl34x_suspend(ac);
-
-	return 0;
-}
-
-static int __maybe_unused adxl34x_spi_resume(struct device *dev)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct adxl34x *ac = spi_get_drvdata(spi);
-
-	adxl34x_resume(ac);
-
-	return 0;
-}
-
-static SIMPLE_DEV_PM_OPS(adxl34x_spi_pm, adxl34x_spi_suspend,
-			 adxl34x_spi_resume);
-
 static struct spi_driver adxl34x_driver = {
 	.driver = {
 		.name = "adxl34x",
-		.pm = &adxl34x_spi_pm,
+		.pm = pm_sleep_ptr(&adxl34x_pm),
 	},
 	.probe   = adxl34x_spi_probe,
 	.remove  = adxl34x_spi_remove,
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
index a4af314392a9..eecca671b588 100644
--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -412,8 +412,10 @@ static void __adxl34x_enable(struct adxl34x *ac)
 	AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE);
 }
 
-void adxl34x_suspend(struct adxl34x *ac)
+static int adxl34x_suspend(struct device *dev)
 {
+	struct adxl34x *ac = dev_get_drvdata(dev);
+
 	mutex_lock(&ac->mutex);
 
 	if (!ac->suspended && !ac->disabled && ac->opened)
@@ -422,11 +424,14 @@ void adxl34x_suspend(struct adxl34x *ac)
 	ac->suspended = true;
 
 	mutex_unlock(&ac->mutex);
+
+	return 0;
 }
-EXPORT_SYMBOL_GPL(adxl34x_suspend);
 
-void adxl34x_resume(struct adxl34x *ac)
+static int adxl34x_resume(struct device *dev)
 {
+	struct adxl34x *ac = dev_get_drvdata(dev);
+
 	mutex_lock(&ac->mutex);
 
 	if (ac->suspended && !ac->disabled && ac->opened)
@@ -435,8 +440,9 @@ void adxl34x_resume(struct adxl34x *ac)
 	ac->suspended = false;
 
 	mutex_unlock(&ac->mutex);
+
+	return 0;
 }
-EXPORT_SYMBOL_GPL(adxl34x_resume);
 
 static ssize_t adxl34x_disable_show(struct device *dev,
 				    struct device_attribute *attr, char *buf)
@@ -906,6 +912,8 @@ void adxl34x_remove(struct adxl34x *ac)
 }
 EXPORT_SYMBOL_GPL(adxl34x_remove);
 
+EXPORT_GPL_SIMPLE_DEV_PM_OPS(adxl34x_pm, adxl34x_suspend, adxl34x_resume);
+
 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
 MODULE_DESCRIPTION("ADXL345/346 Three-Axis Digital Accelerometer Driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/input/misc/adxl34x.h b/drivers/input/misc/adxl34x.h
index febf85270fff..f9272a2e7a96 100644
--- a/drivers/input/misc/adxl34x.h
+++ b/drivers/input/misc/adxl34x.h
@@ -20,11 +20,11 @@ struct adxl34x_bus_ops {
 	int (*write)(struct device *, unsigned char, unsigned char);
 };
 
-void adxl34x_suspend(struct adxl34x *ac);
-void adxl34x_resume(struct adxl34x *ac);
 struct adxl34x *adxl34x_probe(struct device *dev, int irq,
 			      bool fifo_delay_default,
 			      const struct adxl34x_bus_ops *bops);
 void adxl34x_remove(struct adxl34x *ac);
 
+extern const struct dev_pm_ops adxl34x_pm;
+
 #endif
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 09/16] Input: tsc200x - use EXPORT_GPL_SIMPLE_DEV_PM_OPS()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (7 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 08/16] Input: adxl34x " Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 10/16] Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS() Jonathan Cameron
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_sleep_ptr()
and EXPORT_GPL_SIMPLE_DEV_PM_OPS() allows the compiler to see the
functions, thus suppressing the warning, but still allowing the unused
code to be removed. Thus also drop the __maybe_unused markings.
This function also removes the need for separate EXPORT_SYMBOL_GPL()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/touchscreen/tsc2004.c      | 2 +-
 drivers/input/touchscreen/tsc2005.c      | 2 +-
 drivers/input/touchscreen/tsc200x-core.c | 7 +++----
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2004.c b/drivers/input/touchscreen/tsc2004.c
index 575768b587bb..45f39eb20638 100644
--- a/drivers/input/touchscreen/tsc2004.c
+++ b/drivers/input/touchscreen/tsc2004.c
@@ -65,7 +65,7 @@ static struct i2c_driver tsc2004_driver = {
 	.driver = {
 		.name   = "tsc2004",
 		.of_match_table = of_match_ptr(tsc2004_of_match),
-		.pm     = &tsc200x_pm_ops,
+		.pm     = pm_sleep_ptr(&tsc200x_pm_ops),
 	},
 	.id_table       = tsc2004_idtable,
 	.probe_new      = tsc2004_probe,
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 555dfe98b3c4..b6dfbcfc8c19 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -81,7 +81,7 @@ static struct spi_driver tsc2005_driver = {
 	.driver	= {
 		.name	= "tsc2005",
 		.of_match_table = of_match_ptr(tsc2005_of_match),
-		.pm	= &tsc200x_pm_ops,
+		.pm	= pm_sleep_ptr(&tsc200x_pm_ops),
 	},
 	.probe	= tsc2005_probe,
 	.remove	= tsc2005_remove,
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index 72c7258b93a5..b799f26fcf8f 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -588,7 +588,7 @@ void tsc200x_remove(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(tsc200x_remove);
 
-static int __maybe_unused tsc200x_suspend(struct device *dev)
+static int tsc200x_suspend(struct device *dev)
 {
 	struct tsc200x *ts = dev_get_drvdata(dev);
 
@@ -604,7 +604,7 @@ static int __maybe_unused tsc200x_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused tsc200x_resume(struct device *dev)
+static int tsc200x_resume(struct device *dev)
 {
 	struct tsc200x *ts = dev_get_drvdata(dev);
 
@@ -620,8 +620,7 @@ static int __maybe_unused tsc200x_resume(struct device *dev)
 	return 0;
 }
 
-SIMPLE_DEV_PM_OPS(tsc200x_pm_ops, tsc200x_suspend, tsc200x_resume);
-EXPORT_SYMBOL_GPL(tsc200x_pm_ops);
+EXPORT_GPL_SIMPLE_DEV_PM_OPS(tsc200x_pm_ops, tsc200x_suspend, tsc200x_resume);
 
 MODULE_AUTHOR("Lauri Leukkunen <lauri.leukkunen@nokia.com>");
 MODULE_DESCRIPTION("TSC200x Touchscreen Driver Core");
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 10/16] Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (8 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 09/16] Input: tsc200x - use EXPORT_GPL_SIMPLE_DEV_PM_OPS() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 11/16] Input: cyttsp - use EXPORT_GPL_SIMPLE_DEV_PM_OPS() Jonathan Cameron
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and RUNTIME_PM_OPS() are deprecated as
they requires explicit protection against unused function warnings.
The new combination of pm_ptr() EXPORT_GPL_RUNTIME_DEV_PM_OPS()
allows the compiler to see the functions, thus suppressing the
warning, but still allowing the unused code to be
removed. Thus also drop the #ifdef guards.

Note that we are replacing an unconditional call to the suspend
and resume functions for sleep use cases with one via
pm_runtime_force_suspend() / pm_runtime_force_resume() that only
do anything to the device if we are not already in the appropriate
runtime suspended state.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

--

I 'think' this should be fine in that it can only reduce the number
of unnecessary suspends.  If anyone can test that would be great.
---
 drivers/input/touchscreen/cyttsp4_core.c | 9 ++-------
 drivers/input/touchscreen/cyttsp4_i2c.c  | 2 +-
 drivers/input/touchscreen/cyttsp4_spi.c  | 2 +-
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index dccbcb942fe5..0cd6f626adec 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -1744,7 +1744,6 @@ static void cyttsp4_free_si_ptrs(struct cyttsp4 *cd)
 	kfree(si->btn_rec_data);
 }
 
-#ifdef CONFIG_PM
 static int cyttsp4_core_sleep(struct cyttsp4 *cd)
 {
 	int rc;
@@ -1877,13 +1876,9 @@ static int cyttsp4_core_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-const struct dev_pm_ops cyttsp4_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume)
-	SET_RUNTIME_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume, NULL)
-};
-EXPORT_SYMBOL_GPL(cyttsp4_pm_ops);
+EXPORT_GPL_RUNTIME_DEV_PM_OPS(cyttsp4_pm_ops,
+			      cyttsp4_core_suspend, cyttsp4_core_resume, NULL);
 
 static int cyttsp4_mt_open(struct input_dev *input)
 {
diff --git a/drivers/input/touchscreen/cyttsp4_i2c.c b/drivers/input/touchscreen/cyttsp4_i2c.c
index c260bab0c62c..ec7a4779f3fb 100644
--- a/drivers/input/touchscreen/cyttsp4_i2c.c
+++ b/drivers/input/touchscreen/cyttsp4_i2c.c
@@ -58,7 +58,7 @@ MODULE_DEVICE_TABLE(i2c, cyttsp4_i2c_id);
 static struct i2c_driver cyttsp4_i2c_driver = {
 	.driver = {
 		.name	= CYTTSP4_I2C_NAME,
-		.pm	= &cyttsp4_pm_ops,
+		.pm	= pm_ptr(&cyttsp4_pm_ops),
 	},
 	.probe_new	= cyttsp4_i2c_probe,
 	.remove		= cyttsp4_i2c_remove,
diff --git a/drivers/input/touchscreen/cyttsp4_spi.c b/drivers/input/touchscreen/cyttsp4_spi.c
index 5d7db84f2749..944fbbe9113e 100644
--- a/drivers/input/touchscreen/cyttsp4_spi.c
+++ b/drivers/input/touchscreen/cyttsp4_spi.c
@@ -173,7 +173,7 @@ static void cyttsp4_spi_remove(struct spi_device *spi)
 static struct spi_driver cyttsp4_spi_driver = {
 	.driver = {
 		.name	= CYTTSP4_SPI_NAME,
-		.pm	= &cyttsp4_pm_ops,
+		.pm	= pm_ptr(&cyttsp4_pm_ops),
 	},
 	.probe  = cyttsp4_spi_probe,
 	.remove = cyttsp4_spi_remove,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 11/16] Input: cyttsp - use EXPORT_GPL_SIMPLE_DEV_PM_OPS()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (9 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 10/16] Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 12/16] Input: applespi - use pm_sleep_ptr() and SYSTEM_SLEEP_PM_OPS() Jonathan Cameron
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov
  Cc: jic23, Jonathan Cameron, Javier Martinez Canillas, Linus Walleij

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_sleep_ptr()
and EXPORT_GPL_SIMPLE_DEV_PMU_OPS() allows the compiler to see the
functions, thus suppressing the warning, but still allowing the unused
code to be removed. Thus also drop the __maybe_unused markings.
It also rolls in the EXPORT_SYMBOL() so that we only export it
if CONFIG_PM_SLEEP.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Javier Martinez Canillas <javier@dowhile0.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/input/touchscreen/cyttsp_core.c | 7 +++----
 drivers/input/touchscreen/cyttsp_i2c.c  | 2 +-
 drivers/input/touchscreen/cyttsp_spi.c  | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 1dbd849c9613..132ed5786e84 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -491,7 +491,7 @@ static int cyttsp_disable(struct cyttsp *ts)
 	return 0;
 }
 
-static int __maybe_unused cyttsp_suspend(struct device *dev)
+static int cyttsp_suspend(struct device *dev)
 {
 	struct cyttsp *ts = dev_get_drvdata(dev);
 	int retval = 0;
@@ -509,7 +509,7 @@ static int __maybe_unused cyttsp_suspend(struct device *dev)
 	return retval;
 }
 
-static int __maybe_unused cyttsp_resume(struct device *dev)
+static int cyttsp_resume(struct device *dev)
 {
 	struct cyttsp *ts = dev_get_drvdata(dev);
 
@@ -525,8 +525,7 @@ static int __maybe_unused cyttsp_resume(struct device *dev)
 	return 0;
 }
 
-SIMPLE_DEV_PM_OPS(cyttsp_pm_ops, cyttsp_suspend, cyttsp_resume);
-EXPORT_SYMBOL_GPL(cyttsp_pm_ops);
+EXPORT_GPL_SIMPLE_DEV_PM_OPS(cyttsp_pm_ops, cyttsp_suspend, cyttsp_resume);
 
 static int cyttsp_open(struct input_dev *dev)
 {
diff --git a/drivers/input/touchscreen/cyttsp_i2c.c b/drivers/input/touchscreen/cyttsp_i2c.c
index 0155a1626adf..3f91cb43ec82 100644
--- a/drivers/input/touchscreen/cyttsp_i2c.c
+++ b/drivers/input/touchscreen/cyttsp_i2c.c
@@ -63,7 +63,7 @@ MODULE_DEVICE_TABLE(of, cyttsp_of_i2c_match);
 static struct i2c_driver cyttsp_i2c_driver = {
 	.driver = {
 		.name	= CY_I2C_NAME,
-		.pm	= &cyttsp_pm_ops,
+		.pm	= pm_sleep_ptr(&cyttsp_pm_ops),
 		.of_match_table = cyttsp_of_i2c_match,
 	},
 	.probe_new	= cyttsp_i2c_probe,
diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c
index 30c6fbf86a86..ada17f2dadf3 100644
--- a/drivers/input/touchscreen/cyttsp_spi.c
+++ b/drivers/input/touchscreen/cyttsp_spi.c
@@ -172,7 +172,7 @@ MODULE_DEVICE_TABLE(of, cyttsp_of_spi_match);
 static struct spi_driver cyttsp_spi_driver = {
 	.driver = {
 		.name	= CY_SPI_NAME,
-		.pm	= &cyttsp_pm_ops,
+		.pm	= pm_sleep_ptr(&cyttsp_pm_ops),
 		.of_match_table = cyttsp_of_spi_match,
 	},
 	.probe  = cyttsp_spi_probe,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 12/16] Input: applespi - use pm_sleep_ptr() and SYSTEM_SLEEP_PM_OPS()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (10 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 11/16] Input: cyttsp - use EXPORT_GPL_SIMPLE_DEV_PM_OPS() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 13/16] Input: omap4-keyad - use pm_ptr() and RUNTIME_DEV_PM_OPS() Jonathan Cameron
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_sleep_ptr()
and SYSTEM_SLEEP_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

In this case we also have a .poweroff_late() callback. Whilst not
strictly necessary, to future proof against relaxation of the protection
of the main driver.pm = pm_sleep_ptr() protect this pointer with
pm_sleep_ptr() as would be done if the LATE_SYSTEM_SLEEP_PM_OPS()
macro were used to set it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/keyboard/applespi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c
index 91a9810f6980..cf25177b4830 100644
--- a/drivers/input/keyboard/applespi.c
+++ b/drivers/input/keyboard/applespi.c
@@ -1876,7 +1876,7 @@ static int applespi_poweroff_late(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused applespi_suspend(struct device *dev)
+static int applespi_suspend(struct device *dev)
 {
 	struct spi_device *spi = to_spi_device(dev);
 	struct applespi_data *applespi = spi_get_drvdata(spi);
@@ -1903,7 +1903,7 @@ static int __maybe_unused applespi_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused applespi_resume(struct device *dev)
+static int applespi_resume(struct device *dev)
 {
 	struct spi_device *spi = to_spi_device(dev);
 	struct applespi_data *applespi = spi_get_drvdata(spi);
@@ -1947,15 +1947,15 @@ static const struct acpi_device_id applespi_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, applespi_acpi_match);
 
 static const struct dev_pm_ops applespi_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(applespi_suspend, applespi_resume)
-	.poweroff_late	= applespi_poweroff_late,
+	SYSTEM_SLEEP_PM_OPS(applespi_suspend, applespi_resume)
+	.poweroff_late	= pm_sleep_ptr(applespi_poweroff_late),
 };
 
 static struct spi_driver applespi_driver = {
 	.driver		= {
 		.name			= "applespi",
 		.acpi_match_table	= applespi_acpi_match,
-		.pm			= &applespi_pm_ops,
+		.pm			= pm_sleep_ptr(&applespi_pm_ops),
 	},
 	.probe		= applespi_probe,
 	.remove		= applespi_remove,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 13/16] Input: omap4-keyad - use pm_ptr() and RUNTIME_DEV_PM_OPS()
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (11 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 12/16] Input: applespi - use pm_sleep_ptr() and SYSTEM_SLEEP_PM_OPS() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 14/16] Input: Use pm_sleep_ptr() to avoid need for ifdef CONFIG_PM_SLEEP Jonathan Cameron
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_RUNTIME_DEV_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_ptr()
and RUNTIME_DEV_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

Note that DEFINE_RUNTIME_DEV_PM_OPS() is not used because that adds
additional callbacks for suspend and resume and would need
testing.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/keyboard/omap4-keypad.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index ee9d04a3f0d5..4426120398b0 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -310,7 +310,7 @@ static int omap4_keypad_check_revision(struct device *dev,
  * Interrupt may not happen for key-up events. We must clear stuck
  * key-up events after the keyboard hardware has auto-idled.
  */
-static int __maybe_unused omap4_keypad_runtime_suspend(struct device *dev)
+static int omap4_keypad_runtime_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
@@ -328,7 +328,7 @@ static int __maybe_unused omap4_keypad_runtime_suspend(struct device *dev)
 }
 
 static const struct dev_pm_ops omap4_keypad_pm_ops = {
-	SET_RUNTIME_PM_OPS(omap4_keypad_runtime_suspend, NULL, NULL)
+	RUNTIME_PM_OPS(omap4_keypad_runtime_suspend, NULL, NULL)
 };
 
 static void omap4_disable_pm(void *d)
@@ -488,7 +488,7 @@ static struct platform_driver omap4_keypad_driver = {
 	.driver		= {
 		.name	= "omap4-keypad",
 		.of_match_table = omap_keypad_dt_match,
-		.pm = &omap4_keypad_pm_ops,
+		.pm = pm_ptr(&omap4_keypad_pm_ops),
 	},
 };
 module_platform_driver(omap4_keypad_driver);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 14/16] Input: Use pm_sleep_ptr() to avoid need for ifdef CONFIG_PM_SLEEP
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (12 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 13/16] Input: omap4-keyad - use pm_ptr() and RUNTIME_DEV_PM_OPS() Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 15/16] Input: cma3000 - use pm_sleep_ptr() to allow removal of ifdef CONFIG_PM guards Jonathan Cameron
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

As the new pm_sleep_ptr() macro lets the compiler see the code, but
then remove it if !CONFIG_PM_SLEEP it can be used to avoid the need
for #ifdef guards.  Use that in the input core to simplify the code
a little.  Note pm_sleep_ptr() has not been applied to each callback
in the ops structure because the pm_sleep_ptr() at the usage site
is sufficient.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/input.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index ca2e3dd7188b..9fdb22db2ca4 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -19,6 +19,7 @@
 #include <linux/proc_fs.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
+#include <linux/pm.h>
 #include <linux/poll.h>
 #include <linux/device.h>
 #include <linux/kstrtox.h>
@@ -1828,7 +1829,6 @@ static int input_uninhibit_device(struct input_dev *dev)
 	return ret;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int input_dev_suspend(struct device *dev)
 {
 	struct input_dev *input_dev = to_input_dev(dev);
@@ -1903,15 +1903,12 @@ static const struct dev_pm_ops input_dev_pm_ops = {
 	.poweroff	= input_dev_poweroff,
 	.restore	= input_dev_resume,
 };
-#endif /* CONFIG_PM */
 
 static const struct device_type input_dev_type = {
 	.groups		= input_dev_attr_groups,
 	.release	= input_dev_release,
 	.uevent		= input_dev_uevent,
-#ifdef CONFIG_PM_SLEEP
-	.pm		= &input_dev_pm_ops,
-#endif
+	.pm		= pm_sleep_ptr(&input_dev_pm_ops),
 };
 
 static char *input_devnode(const struct device *dev, umode_t *mode)
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 15/16] Input: cma3000 - use pm_sleep_ptr() to allow removal of ifdef CONFIG_PM guards
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (13 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 14/16] Input: Use pm_sleep_ptr() to avoid need for ifdef CONFIG_PM_SLEEP Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-14 17:16 ` [PATCH 16/16] Input: wistron_btns " Jonathan Cameron
  2023-01-27 22:50 ` [PATCH 00/16] Input: Switch to new PM macros set 3 Dmitry Torokhov
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

As the guards only apply to suspend and resume, #ifdef CONFIG_PM_SLEEP
would have been a tighter protection. As pm_sleep_ptr() lets the compiler
see the protected ops structure and callbacks but also lets the compiler
remove it as unused code if !CONFIG_PM_SLEEP this allows the #ifdef
guards to be removed, slightly simplifying the resulting code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

--
It seems likely that DEFINE_SIMPLE_DEV_PM_OPS() would work here but
I'd prefer not to make that change unless someone can confirm that the
extra callbacks registered will have no unwanted side effects in this
driver.
---
 drivers/input/misc/cma3000_d0x_i2c.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/input/misc/cma3000_d0x_i2c.c b/drivers/input/misc/cma3000_d0x_i2c.c
index 75442c1230b1..136eb3715870 100644
--- a/drivers/input/misc/cma3000_d0x_i2c.c
+++ b/drivers/input/misc/cma3000_d0x_i2c.c
@@ -64,7 +64,6 @@ static void cma3000_i2c_remove(struct i2c_client *client)
 	cma3000_exit(data);
 }
 
-#ifdef CONFIG_PM
 static int cma3000_i2c_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -89,7 +88,6 @@ static const struct dev_pm_ops cma3000_i2c_pm_ops = {
 	.suspend	= cma3000_i2c_suspend,
 	.resume		= cma3000_i2c_resume,
 };
-#endif
 
 static const struct i2c_device_id cma3000_i2c_id[] = {
 	{ "cma3000_d01", 0 },
@@ -104,9 +102,7 @@ static struct i2c_driver cma3000_i2c_driver = {
 	.id_table	= cma3000_i2c_id,
 	.driver = {
 		.name	= "cma3000_i2c_accl",
-#ifdef CONFIG_PM
-		.pm	= &cma3000_i2c_pm_ops,
-#endif
+		.pm	= pm_sleep_ptr(&cma3000_i2c_pm_ops),
 	},
 };
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 16/16] Input: wistron_btns -  use pm_sleep_ptr() to allow removal of ifdef CONFIG_PM guards
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (14 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 15/16] Input: cma3000 - use pm_sleep_ptr() to allow removal of ifdef CONFIG_PM guards Jonathan Cameron
@ 2023-01-14 17:16 ` Jonathan Cameron
  2023-01-27 22:50 ` [PATCH 00/16] Input: Switch to new PM macros set 3 Dmitry Torokhov
  16 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

As the guards only apply to suspend and resume, #ifdef CONFIG_PM_SLEEP
would have been a tighter protection. As pm_sleep_ptr() lets the compiler
see the protected ops structure and callbacks but also lets the compiler
remove it as unused code if !CONFIG_PM_SLEEP this allows the #ifdef
guards to be removed, slightly simplifying the resulting code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
--
It seems likely that DEFINE_SIMPLE_DEV_PM_OPS() would work here but
I'd prefer not to make that change unless someone can confirm that the
extra callbacks registered will have no unwanted side effects in this
driver.
---
 drivers/input/misc/wistron_btns.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 80dfd72a02d3..111cb70cde46 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -1295,7 +1295,6 @@ static int wistron_remove(struct platform_device *dev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int wistron_suspend(struct device *dev)
 {
 	if (have_wifi)
@@ -1330,14 +1329,11 @@ static const struct dev_pm_ops wistron_pm_ops = {
 	.poweroff	= wistron_suspend,
 	.restore	= wistron_resume,
 };
-#endif
 
 static struct platform_driver wistron_driver = {
 	.driver		= {
 		.name	= "wistron-bios",
-#ifdef CONFIG_PM
-		.pm	= &wistron_pm_ops,
-#endif
+		.pm	= pm_sleep_ptr(&wistron_pm_ops),
 	},
 	.probe		= wistron_probe,
 	.remove		= wistron_remove,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/16] Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
  2023-01-14 17:16 ` [PATCH 04/16] Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr() Jonathan Cameron
@ 2023-01-16 14:20   ` Caleb Connolly
  0 siblings, 0 replies; 19+ messages in thread
From: Caleb Connolly @ 2023-01-16 14:20 UTC (permalink / raw)
  To: Jonathan Cameron, linux-input, Dmitry Torokhov
  Cc: Jonathan Cameron, Andi Shyti



On 14/01/2023 17:16, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated as
> they require explicit protection against unused function warnings.
> The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/
> RUNTIME_PM_OPS() allows the compiler to see the functions,
> thus suppressing the warning, but still allowing the unused code to be
> removed. Thus also drop the __maybe_unused markings.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Tested-by: Caleb Connolly <caleb@connolly.tech> # oneplus-guacamole
> Cc: Caleb Connolly <caleb@connolly.tech>
> Cc: Andi Shyti <andi@etezian.org>
> ---
>  drivers/input/touchscreen/s6sy761.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
> index cc417c03aaca..371cf4848ad5 100644
> --- a/drivers/input/touchscreen/s6sy761.c
> +++ b/drivers/input/touchscreen/s6sy761.c
> @@ -479,7 +479,7 @@ static void s6sy761_remove(struct i2c_client *client)
>  	pm_runtime_disable(&client->dev);
>  }
>
> -static int __maybe_unused s6sy761_runtime_suspend(struct device *dev)
> +static int s6sy761_runtime_suspend(struct device *dev)
>  {
>  	struct s6sy761_data *sdata = dev_get_drvdata(dev);
>
> @@ -487,7 +487,7 @@ static int __maybe_unused s6sy761_runtime_suspend(struct device *dev)
>  				S6SY761_APPLICATION_MODE, S6SY761_APP_SLEEP);
>  }
>
> -static int __maybe_unused s6sy761_runtime_resume(struct device *dev)
> +static int s6sy761_runtime_resume(struct device *dev)
>  {
>  	struct s6sy761_data *sdata = dev_get_drvdata(dev);
>
> @@ -495,7 +495,7 @@ static int __maybe_unused s6sy761_runtime_resume(struct device *dev)
>  				S6SY761_APPLICATION_MODE, S6SY761_APP_NORMAL);
>  }
>
> -static int __maybe_unused s6sy761_suspend(struct device *dev)
> +static int s6sy761_suspend(struct device *dev)
>  {
>  	struct s6sy761_data *sdata = dev_get_drvdata(dev);
>
> @@ -504,7 +504,7 @@ static int __maybe_unused s6sy761_suspend(struct device *dev)
>  	return 0;
>  }
>
> -static int __maybe_unused s6sy761_resume(struct device *dev)
> +static int s6sy761_resume(struct device *dev)
>  {
>  	struct s6sy761_data *sdata = dev_get_drvdata(dev);
>
> @@ -514,9 +514,8 @@ static int __maybe_unused s6sy761_resume(struct device *dev)
>  }
>
>  static const struct dev_pm_ops s6sy761_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(s6sy761_suspend, s6sy761_resume)
> -	SET_RUNTIME_PM_OPS(s6sy761_runtime_suspend,
> -				s6sy761_runtime_resume, NULL)
> +	SYSTEM_SLEEP_PM_OPS(s6sy761_suspend, s6sy761_resume)
> +	RUNTIME_PM_OPS(s6sy761_runtime_suspend, s6sy761_runtime_resume, NULL)
>  };
>
>  #ifdef CONFIG_OF
> @@ -537,7 +536,7 @@ static struct i2c_driver s6sy761_driver = {
>  	.driver = {
>  		.name = S6SY761_DEV_NAME,
>  		.of_match_table = of_match_ptr(s6sy761_of_match),
> -		.pm = &s6sy761_pm_ops,
> +		.pm = pm_ptr(&s6sy761_pm_ops),
>  	},
>  	.probe_new = s6sy761_probe,
>  	.remove = s6sy761_remove,
> --
> 2.39.0
>

--
Kind Regards,
Caleb


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 00/16] Input: Switch to new PM macros set 3
  2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
                   ` (15 preceding siblings ...)
  2023-01-14 17:16 ` [PATCH 16/16] Input: wistron_btns " Jonathan Cameron
@ 2023-01-27 22:50 ` Dmitry Torokhov
  16 siblings, 0 replies; 19+ messages in thread
From: Dmitry Torokhov @ 2023-01-27 22:50 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-input, Jonathan Cameron, Hans de Goede, Caleb Connolly,
	Andi Shyti, Matthias Schiffer, Lyude Paul, Andrew Duggan,
	Michael Hennerich, Javier Martinez Canillas, Linus Walleij

On Sat, Jan 14, 2023 at 05:16:04PM +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Continuation of
> https://lore.kernel.org/all/20230102181842.718010-1-jic23@kernel.org/
> 
> This time we have most of the remaining drivers where the changes needed
> are more complex than the earlier straight conversions.
> 
> A separate series will deal with pm80x as the cleanup for that will
> extend to MFD and RTC trees and cannot easily be broken up due to
> some changes in exports.
> 
> There is a general mixture of cases in here:
> 1) More complex direct conversions - typically drivers with separate
>    sleep and runtime pm ops.
> 2) Cases where the callbacks or struct dev_pm_ops is exported to
>    multiple modules.
> 3) Refactors that avoid duplication of callbacks or exports.
> 4) A tweak to the core input handling to use the new macros - this
>    is different from the driver changes, but seemed sensible.
> 
> Note there are a few cases in here where I a much more minimal
> set of callbacks is provided than DEFINE_SIMPLE_DEV_PM_OPS() and
> friends would set. I don't know the history behind those so whilst
> they might well be fine converted to the generic macros, I've
> left them alone.

Applied the lot, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-01-27 22:51 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-14 17:16 [PATCH 00/16] Input: Switch to new PM macros set 3 Jonathan Cameron
2023-01-14 17:16 ` [PATCH 01/16] Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 02/16] Input: axp20x-pek - switch to SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 03/16] Input: samsung-keypad - switch to pm_ptr() and SYSTEM_SLEEP/RUNTIME_PM_OPS() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 04/16] Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr() Jonathan Cameron
2023-01-16 14:20   ` Caleb Connolly
2023-01-14 17:16 ` [PATCH 05/16] Input: rmi4 - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() " Jonathan Cameron
2023-01-14 17:16 ` [PATCH 06/16] Input: stmfts - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() " Jonathan Cameron
2023-01-14 17:16 ` [PATCH 07/16] Input: ad714x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 08/16] Input: adxl34x " Jonathan Cameron
2023-01-14 17:16 ` [PATCH 09/16] Input: tsc200x - use EXPORT_GPL_SIMPLE_DEV_PM_OPS() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 10/16] Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 11/16] Input: cyttsp - use EXPORT_GPL_SIMPLE_DEV_PM_OPS() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 12/16] Input: applespi - use pm_sleep_ptr() and SYSTEM_SLEEP_PM_OPS() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 13/16] Input: omap4-keyad - use pm_ptr() and RUNTIME_DEV_PM_OPS() Jonathan Cameron
2023-01-14 17:16 ` [PATCH 14/16] Input: Use pm_sleep_ptr() to avoid need for ifdef CONFIG_PM_SLEEP Jonathan Cameron
2023-01-14 17:16 ` [PATCH 15/16] Input: cma3000 - use pm_sleep_ptr() to allow removal of ifdef CONFIG_PM guards Jonathan Cameron
2023-01-14 17:16 ` [PATCH 16/16] Input: wistron_btns " Jonathan Cameron
2023-01-27 22:50 ` [PATCH 00/16] Input: Switch to new PM macros set 3 Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).