Skip to contentSkip to conversation

Trivial cleanup and refactor dev_pm_ops handling.

PATCH In review Jonathan Cameron 2 participants 6 messages Aug 7, 2022 – Aug 13, 2022 IIO

lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

cover Trivial cleanup and refactor dev_pm_ops handling.

From: Jonathan Cameron <[email protected]>

This driver was taking an unusual approach to handling the optionality of structures / callbacks depending on CONFIG_PM. Bring it inline with other similar drivers.

Part of continuing to move IIO over to the new PM macros that don't require such complex handling.

Jonathan Cameron (2):
iio: magn: hmc5843: Drop excessive indentation of assignments of

    hmc5843_driver

iio: magn: hmc5843: Move struct dev_pm_ops out of header

 drivers/iio/magnetometer/hmc5843.h      | 13 +------------
 drivers/iio/magnetometer/hmc5843_core.c |  8 ++++----
 drivers/iio/magnetometer/hmc5843_i2c.c  |  2 +-
 drivers/iio/magnetometer/hmc5843_spi.c  | 14 +++++++-------
 4 files changed, 13 insertions(+), 24 deletions(-)
Signature · 1 line
2.37.1
author maintainer
#1 lore raw

PATCH 1/2 iio: magn: hmc5843: Drop excessive indentation of assignments of hmc5843_driver

From: Jonathan Cameron <[email protected]>

This formatting is odd, so fix it to be more standard.

---
 drivers/iio/magnetometer/hmc5843_spi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/magnetometer/hmc5843_spi.c +7 -7
index 8403f09aba39..310027a53342 100644
@@ -86,13 +86,13 @@ static const struct spi_device_id hmc5843_id[] = {
 MODULE_DEVICE_TABLE(spi, hmc5843_id);
 
 static struct spi_driver hmc5843_driver = {
-		.driver = {
-				.name = "hmc5843",
-				.pm = HMC5843_PM_OPS,
-		},
-		.id_table = hmc5843_id,
-		.probe = hmc5843_spi_probe,
-		.remove = hmc5843_spi_remove,
+	.driver = {
+		.name = "hmc5843",
+		.pm = HMC5843_PM_OPS,
+	},
+	.id_table = hmc5843_id,
+	.probe = hmc5843_spi_probe,
+	.remove = hmc5843_spi_remove,
 };
 
 module_spi_driver(hmc5843_driver);
Signature · 1 line
2.37.1
author maintainer
#2 lore raw

PATCH 2/2 iio: magn: hmc5843: Move struct dev_pm_ops out of header

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Having this structure defined static in the header lead to unnecessary duplication and required additional symbol exports. Use the EXPORT_NS_SIMPLE_DEV_PM_OPS() to clean this up in the same fashion as many other drivers do this.

---
 drivers/iio/magnetometer/hmc5843.h      | 13 +------------
 drivers/iio/magnetometer/hmc5843_core.c |  8 ++++----
 drivers/iio/magnetometer/hmc5843_i2c.c  |  2 +-
 drivers/iio/magnetometer/hmc5843_spi.c  |  2 +-
 4 files changed, 7 insertions(+), 18 deletions(-)
drivers/iio/magnetometer/hmc5843.h +1 -12
index 9120c8bbf3dd..60fbb5431c88 100644
@@ -52,16 +52,5 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
 			 enum hmc5843_ids id, const char *name);
 void hmc5843_common_remove(struct device *dev);
 
-int hmc5843_common_suspend(struct device *dev);
-int hmc5843_common_resume(struct device *dev);
-
-#ifdef CONFIG_PM_SLEEP
-static __maybe_unused SIMPLE_DEV_PM_OPS(hmc5843_pm_ops,
-					hmc5843_common_suspend,
-					hmc5843_common_resume);
-#define HMC5843_PM_OPS (&hmc5843_pm_ops)
-#else
-#define HMC5843_PM_OPS NULL
-#endif
-
+extern const struct dev_pm_ops hmc5843_pm_ops;
 #endif /* HMC5843_CORE_H */
drivers/iio/magnetometer/hmc5843_core.c +4 -4
index 4a63b2da9df0..c5521d61da29 100644
@@ -603,19 +603,19 @@ static const struct iio_info hmc5843_info = {
 
 static const unsigned long hmc5843_scan_masks[] = {0x7, 0};
 
-int hmc5843_common_suspend(struct device *dev)
+static int hmc5843_common_suspend(struct device *dev)
 {
 	return hmc5843_set_mode(iio_priv(dev_get_drvdata(dev)),
 				HMC5843_MODE_SLEEP);
 }
-EXPORT_SYMBOL_NS(hmc5843_common_suspend, IIO_HMC5843);
 
-int hmc5843_common_resume(struct device *dev)
+static int hmc5843_common_resume(struct device *dev)
 {
 	return hmc5843_set_mode(iio_priv(dev_get_drvdata(dev)),
 		HMC5843_MODE_CONVERSION_CONTINUOUS);
 }
-EXPORT_SYMBOL_NS(hmc5843_common_resume, IIO_HMC5843);
+EXPORT_NS_SIMPLE_DEV_PM_OPS(hmc5843_pm_ops, hmc5843_common_suspend,
+			    hmc5843_common_resume, IIO_HMC5843);
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
 			 enum hmc5843_ids id, const char *name)
drivers/iio/magnetometer/hmc5843_i2c.c +1 -1
index 8d2ff8fc204d..825a881d37fb 100644
@@ -93,7 +93,7 @@ MODULE_DEVICE_TABLE(of, hmc5843_of_match);
 static struct i2c_driver hmc5843_driver = {
 	.driver = {
 		.name	= "hmc5843",
-		.pm	= HMC5843_PM_OPS,
+		.pm	= pm_sleep_ptr(&hmc5843_pm_ops),
 		.of_match_table = hmc5843_of_match,
 	},
 	.id_table	= hmc5843_id,
drivers/iio/magnetometer/hmc5843_spi.c +1 -1
index 310027a53342..c42d2e2a6a6c 100644
@@ -88,7 +88,7 @@ MODULE_DEVICE_TABLE(spi, hmc5843_id);
 static struct spi_driver hmc5843_driver = {
 	.driver = {
 		.name = "hmc5843",
-		.pm = HMC5843_PM_OPS,
+		.pm = pm_sleep_ptr(&hmc5843_pm_ops),
 	},
 	.id_table = hmc5843_id,
 	.probe = hmc5843_spi_probe,
Signature · 1 line
2.37.1
author maintainer
#3 lore raw

Re: [PATCH 0/2] iio: magn: hmc5843: Trivial cleanup and refactor dev_pm_ops handling.

In reply to Jonathan Cameron
Quoted 8 lines · On Sun, 7 Aug 2022 19:45:32 +0100 Jonathan Cameron <[email protected]> wrote:

From: Jonathan Cameron <[email protected]>

This driver was taking an unusual approach to handling the optionality of structures / callbacks depending on CONFIG_PM. Bring it inline with other similar drivers.

Part of continuing to move IIO over to the new PM macros that don't require such complex handling.

Obviously setting a bad example here. Should have include iio: magn: hmc5843 as prefix for this cover letter. Sorry about that!

Quoted 12 lines

Jonathan Cameron (2):
iio: magn: hmc5843: Drop excessive indentation of assignments of

    hmc5843_driver

iio: magn: hmc5843: Move struct dev_pm_ops out of header

 drivers/iio/magnetometer/hmc5843.h      | 13 +------------
 drivers/iio/magnetometer/hmc5843_core.c |  8 ++++----
 drivers/iio/magnetometer/hmc5843_i2c.c  |  2 +-
 drivers/iio/magnetometer/hmc5843_spi.c  | 14 +++++++-------
 4 files changed, 13 insertions(+), 24 deletions(-)
Reviewed-by on the v1 series
#4 lore raw
In reply to Jonathan Cameron
Quoted 9 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

This driver was taking an unusual approach to handling the optionality of structures / callbacks depending on CONFIG_PM. Bring it inline with other similar drivers.

Part of continuing to move IIO over to the new PM macros that don't require such complex handling.

Quoted 14 lines

Jonathan Cameron (2):
iio: magn: hmc5843: Drop excessive indentation of assignments of

    hmc5843_driver

iio: magn: hmc5843: Move struct dev_pm_ops out of header

 drivers/iio/magnetometer/hmc5843.h      | 13 +------------
 drivers/iio/magnetometer/hmc5843_core.c |  8 ++++----
 drivers/iio/magnetometer/hmc5843_i2c.c  |  2 +-
 drivers/iio/magnetometer/hmc5843_spi.c  | 14 +++++++-------
 4 files changed, 13 insertions(+), 24 deletions(-)

--
2.37.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer Applied
#5 lore raw
Quoted 4 lines · On Mon, 8 Aug 2022 11:22:00 +0200 Andy Shevchenko <[email protected]>…
Quoted 3 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Quoted 8 lines
Quoted 6 lines

This driver was taking an unusual approach to handling the optionality of structures / callbacks depending on CONFIG_PM. Bring it inline with other similar drivers.

Part of continuing to move IIO over to the new PM macros that don't require such complex handling.

Thanks,

Applied

Quoted 17 lines
Quoted 15 lines

Jonathan Cameron (2):
iio: magn: hmc5843: Drop excessive indentation of assignments of

    hmc5843_driver

iio: magn: hmc5843: Move struct dev_pm_ops out of header

 drivers/iio/magnetometer/hmc5843.h      | 13 +------------
 drivers/iio/magnetometer/hmc5843_core.c |  8 ++++----
 drivers/iio/magnetometer/hmc5843_i2c.c  |  2 +-
 drivers/iio/magnetometer/hmc5843_spi.c  | 14 +++++++-------
 4 files changed, 13 insertions(+), 24 deletions(-)

--
2.37.1