All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8)
@ 2022-06-04 16:12 Jonathan Cameron
  2022-06-04 16:12 ` [RESEND PATCH 1/5] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:12 UTC (permalink / raw)
  To: linux-iio, Paul Cercueil, Lorenzo Bianconi; +Cc: Jonathan Cameron

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

Resend as the first part of this series went via Rafael's tree and is
now available in mainline.

Hence time to return to the remainder which didn't really get much review
the first time around as focus was on the more interesting new macros
in the first few patches.

Now we have NS specific EXPORT_NS[_GPL]_SIMPLE_DEV_PM_OPS() etc
we can move these drivers over to their own namespaces reducing polution
of the global namespace with exports that are only of interest
within multi module drivers.

All comments welcome,

Thanks,

Jonathan


Jonathan Cameron (5):
  iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc
  iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow
    compiler to remove dead code.
  iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace
  iio: imu: lsm6dsx: Use new pm_sleep_ptr() and
    EXPORT_SIMPLE_DEV_PM_OPS()
  iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace

 drivers/iio/accel/kxsd9-i2c.c                |  2 +-
 drivers/iio/accel/kxsd9-spi.c                |  2 +-
 drivers/iio/accel/kxsd9.c                    | 11 ++---------
 drivers/iio/humidity/hts221_core.c           | 12 +++++-------
 drivers/iio/humidity/hts221_i2c.c            |  3 ++-
 drivers/iio/humidity/hts221_spi.c            |  3 ++-
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 12 +++++-------
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  |  3 ++-
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c  |  3 ++-
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  |  3 ++-
 10 files changed, 24 insertions(+), 30 deletions(-)

-- 
2.36.1


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

* [RESEND PATCH 1/5] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-06-04 16:12 [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
@ 2022-06-04 16:12 ` Jonathan Cameron
  2022-06-04 16:12 ` [RESEND PATCH 2/5] iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code Jonathan Cameron
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:12 UTC (permalink / raw)
  To: linux-iio, Paul Cercueil, Lorenzo Bianconi; +Cc: Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM support is simpler and less error prone than the
use of #ifdef based config guards.

Removing instances of this approach from IIO also stops them being
copied into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220220181522.541718-5-jic23@kernel.org
---
 drivers/iio/accel/kxsd9-i2c.c |  2 +-
 drivers/iio/accel/kxsd9-spi.c |  2 +-
 drivers/iio/accel/kxsd9.c     | 11 ++---------
 3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
index c8dc52f11037..d57f264bd6c8 100644
--- a/drivers/iio/accel/kxsd9-i2c.c
+++ b/drivers/iio/accel/kxsd9-i2c.c
@@ -55,7 +55,7 @@ static struct i2c_driver kxsd9_i2c_driver = {
 	.driver = {
 		.name	= "kxsd9",
 		.of_match_table = kxsd9_of_match,
-		.pm = &kxsd9_dev_pm_ops,
+		.pm = pm_ptr(&kxsd9_dev_pm_ops),
 	},
 	.probe		= kxsd9_i2c_probe,
 	.remove		= kxsd9_i2c_remove,
diff --git a/drivers/iio/accel/kxsd9-spi.c b/drivers/iio/accel/kxsd9-spi.c
index b7b5af45429e..07f14a9f22c7 100644
--- a/drivers/iio/accel/kxsd9-spi.c
+++ b/drivers/iio/accel/kxsd9-spi.c
@@ -52,7 +52,7 @@ MODULE_DEVICE_TABLE(of, kxsd9_of_match);
 static struct spi_driver kxsd9_spi_driver = {
 	.driver = {
 		.name = "kxsd9",
-		.pm = &kxsd9_dev_pm_ops,
+		.pm = pm_ptr(&kxsd9_dev_pm_ops),
 		.of_match_table = kxsd9_of_match,
 	},
 	.probe = kxsd9_spi_probe,
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index 3975860331a6..ba99649fe195 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -492,7 +492,6 @@ void kxsd9_common_remove(struct device *dev)
 }
 EXPORT_SYMBOL_NS(kxsd9_common_remove, IIO_KXSD9);
 
-#ifdef CONFIG_PM
 static int kxsd9_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -508,15 +507,9 @@ static int kxsd9_runtime_resume(struct device *dev)
 
 	return kxsd9_power_up(st);
 }
-#endif /* CONFIG_PM */
 
-const struct dev_pm_ops kxsd9_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(kxsd9_runtime_suspend,
-			   kxsd9_runtime_resume, NULL)
-};
-EXPORT_SYMBOL_NS(kxsd9_dev_pm_ops, IIO_KXSD9);
+EXPORT_NS_RUNTIME_DEV_PM_OPS(kxsd9_dev_pm_ops, kxsd9_runtime_suspend,
+			     kxsd9_runtime_resume, NULL, IIO_KXSD9);
 
 MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>");
 MODULE_DESCRIPTION("Kionix KXSD9 driver");
-- 
2.36.1


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

* [RESEND PATCH 2/5] iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code.
  2022-06-04 16:12 [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
  2022-06-04 16:12 ` [RESEND PATCH 1/5] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-06-04 16:12 ` Jonathan Cameron
  2022-06-06  8:38   ` Lorenzo Bianconi
  2022-06-04 16:12 ` [RESEND PATCH 3/5] iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace Jonathan Cameron
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:12 UTC (permalink / raw)
  To: linux-iio, Paul Cercueil, Lorenzo Bianconi; +Cc: Jonathan Cameron

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

If CONFIG_PM_SLEEP is not defined using EXPORT_SIMPLE_DEV_PM_OPS()
in conjunction with pm_sleep_ptr() allows the compiler to remove
the unused code and data. This removes the need for __maybe_unused
markings etc.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20220220181522.541718-6-jic23@kernel.org
---
 drivers/iio/humidity/hts221_core.c | 9 +++------
 drivers/iio/humidity/hts221_i2c.c  | 2 +-
 drivers/iio/humidity/hts221_spi.c  | 2 +-
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index 6a39615b6961..da9c08432ef2 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -670,7 +670,7 @@ int hts221_probe(struct device *dev, int irq, const char *name,
 }
 EXPORT_SYMBOL(hts221_probe);
 
-static int __maybe_unused hts221_suspend(struct device *dev)
+static int hts221_suspend(struct device *dev)
 {
 	struct iio_dev *iio_dev = dev_get_drvdata(dev);
 	struct hts221_hw *hw = iio_priv(iio_dev);
@@ -680,7 +680,7 @@ static int __maybe_unused hts221_suspend(struct device *dev)
 				  FIELD_PREP(HTS221_ENABLE_MASK, false));
 }
 
-static int __maybe_unused hts221_resume(struct device *dev)
+static int hts221_resume(struct device *dev)
 {
 	struct iio_dev *iio_dev = dev_get_drvdata(dev);
 	struct hts221_hw *hw = iio_priv(iio_dev);
@@ -694,10 +694,7 @@ static int __maybe_unused hts221_resume(struct device *dev)
 	return err;
 }
 
-const struct dev_pm_ops hts221_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(hts221_suspend, hts221_resume)
-};
-EXPORT_SYMBOL(hts221_pm_ops);
+EXPORT_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume);
 
 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics hts221 sensor driver");
diff --git a/drivers/iio/humidity/hts221_i2c.c b/drivers/iio/humidity/hts221_i2c.c
index cab39c4756f8..933b05e4d972 100644
--- a/drivers/iio/humidity/hts221_i2c.c
+++ b/drivers/iio/humidity/hts221_i2c.c
@@ -62,7 +62,7 @@ MODULE_DEVICE_TABLE(i2c, hts221_i2c_id_table);
 static struct i2c_driver hts221_driver = {
 	.driver = {
 		.name = "hts221_i2c",
-		.pm = &hts221_pm_ops,
+		.pm = pm_sleep_ptr(&hts221_pm_ops),
 		.of_match_table = hts221_i2c_of_match,
 		.acpi_match_table = ACPI_PTR(hts221_acpi_match),
 	},
diff --git a/drivers/iio/humidity/hts221_spi.c b/drivers/iio/humidity/hts221_spi.c
index 729e86e433b1..888c5eab944c 100644
--- a/drivers/iio/humidity/hts221_spi.c
+++ b/drivers/iio/humidity/hts221_spi.c
@@ -55,7 +55,7 @@ MODULE_DEVICE_TABLE(spi, hts221_spi_id_table);
 static struct spi_driver hts221_driver = {
 	.driver = {
 		.name = "hts221_spi",
-		.pm = &hts221_pm_ops,
+		.pm = pm_sleep_ptr(&hts221_pm_ops),
 		.of_match_table = hts221_spi_of_match,
 	},
 	.probe = hts221_spi_probe,
-- 
2.36.1


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

* [RESEND PATCH 3/5] iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace
  2022-06-04 16:12 [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
  2022-06-04 16:12 ` [RESEND PATCH 1/5] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
  2022-06-04 16:12 ` [RESEND PATCH 2/5] iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code Jonathan Cameron
@ 2022-06-04 16:12 ` Jonathan Cameron
  2022-06-06  8:37   ` Lorenzo Bianconi
  2022-06-04 16:12 ` [RESEND PATCH 4/5] iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS() Jonathan Cameron
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:12 UTC (permalink / raw)
  To: linux-iio, Paul Cercueil, Lorenzo Bianconi; +Cc: Jonathan Cameron

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

Avoid unnecessary pollution of the global symbol namespace by
moving library functions in to a specific namespace and import
that into the drivers that make use of the functions.

For more info: https://lwn.net/Articles/760045/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20220220181522.541718-7-jic23@kernel.org
---
 drivers/iio/humidity/hts221_core.c | 5 +++--
 drivers/iio/humidity/hts221_i2c.c  | 1 +
 drivers/iio/humidity/hts221_spi.c  | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index da9c08432ef2..517158307d8c 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -668,7 +668,7 @@ int hts221_probe(struct device *dev, int irq, const char *name,
 
 	return devm_iio_device_register(hw->dev, iio_dev);
 }
-EXPORT_SYMBOL(hts221_probe);
+EXPORT_SYMBOL_NS(hts221_probe, IIO_HTS221);
 
 static int hts221_suspend(struct device *dev)
 {
@@ -694,7 +694,8 @@ static int hts221_resume(struct device *dev)
 	return err;
 }
 
-EXPORT_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume);
+EXPORT_NS_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume,
+			    IIO_HTS221);
 
 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics hts221 sensor driver");
diff --git a/drivers/iio/humidity/hts221_i2c.c b/drivers/iio/humidity/hts221_i2c.c
index 933b05e4d972..afbc611f7712 100644
--- a/drivers/iio/humidity/hts221_i2c.c
+++ b/drivers/iio/humidity/hts221_i2c.c
@@ -74,3 +74,4 @@ module_i2c_driver(hts221_driver);
 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics hts221 i2c driver");
 MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS(IIO_HTS221);
diff --git a/drivers/iio/humidity/hts221_spi.c b/drivers/iio/humidity/hts221_spi.c
index 888c5eab944c..fc4adb68faf6 100644
--- a/drivers/iio/humidity/hts221_spi.c
+++ b/drivers/iio/humidity/hts221_spi.c
@@ -66,3 +66,4 @@ module_spi_driver(hts221_driver);
 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics hts221 spi driver");
 MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS(IIO_HTS221);
-- 
2.36.1


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

* [RESEND PATCH 4/5] iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS()
  2022-06-04 16:12 [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
                   ` (2 preceding siblings ...)
  2022-06-04 16:12 ` [RESEND PATCH 3/5] iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace Jonathan Cameron
@ 2022-06-04 16:12 ` Jonathan Cameron
  2022-06-06  8:37   ` Lorenzo Bianconi
  2022-06-04 16:12 ` [RESEND PATCH 5/5] iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace Jonathan Cameron
  2022-06-11 18:26 ` [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
  5 siblings, 1 reply; 11+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:12 UTC (permalink / raw)
  To: linux-iio, Paul Cercueil, Lorenzo Bianconi; +Cc: Jonathan Cameron

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

These new functions move the burden of removing unused code when
CONFIG_PM_SLEEP is not defined onto the compiler rather than requiring
the use of CONFIG_PM guards and similar.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220220181522.541718-8-jic23@kernel.org
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 10 ++++------
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  |  2 +-
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c  |  2 +-
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  |  2 +-
 4 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 910397716833..9e4aa5c1c8d6 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2291,7 +2291,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 }
 EXPORT_SYMBOL(st_lsm6dsx_probe);
 
-static int __maybe_unused st_lsm6dsx_suspend(struct device *dev)
+static int st_lsm6dsx_suspend(struct device *dev)
 {
 	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
 	struct st_lsm6dsx_sensor *sensor;
@@ -2330,7 +2330,7 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev)
 	return err;
 }
 
-static int __maybe_unused st_lsm6dsx_resume(struct device *dev)
+static int st_lsm6dsx_resume(struct device *dev)
 {
 	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
 	struct st_lsm6dsx_sensor *sensor;
@@ -2366,10 +2366,8 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev)
 	return err;
 }
 
-const struct dev_pm_ops st_lsm6dsx_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(st_lsm6dsx_suspend, st_lsm6dsx_resume)
-};
-EXPORT_SYMBOL(st_lsm6dsx_pm_ops);
+EXPORT_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend,
+			 st_lsm6dsx_resume);
 
 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
index 715fbdc8190e..5bd565b93a8c 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
@@ -134,7 +134,7 @@ MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
 static struct i2c_driver st_lsm6dsx_driver = {
 	.driver = {
 		.name = "st_lsm6dsx_i2c",
-		.pm = &st_lsm6dsx_pm_ops,
+		.pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops),
 		.of_match_table = st_lsm6dsx_i2c_of_match,
 	},
 	.probe = st_lsm6dsx_i2c_probe,
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
index 35556cd04284..4df186499802 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
@@ -44,7 +44,7 @@ static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev)
 static struct i3c_driver st_lsm6dsx_driver = {
 	.driver = {
 		.name = "st_lsm6dsx_i3c",
-		.pm = &st_lsm6dsx_pm_ops,
+		.pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops),
 	},
 	.probe = st_lsm6dsx_i3c_probe,
 	.id_table = st_lsm6dsx_i3c_ids,
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
index f5767cf76c1d..3a206fd4d92c 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
@@ -134,7 +134,7 @@ MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
 static struct spi_driver st_lsm6dsx_driver = {
 	.driver = {
 		.name = "st_lsm6dsx_spi",
-		.pm = &st_lsm6dsx_pm_ops,
+		.pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops),
 		.of_match_table = st_lsm6dsx_spi_of_match,
 	},
 	.probe = st_lsm6dsx_spi_probe,
-- 
2.36.1


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

* [RESEND PATCH 5/5] iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace
  2022-06-04 16:12 [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
                   ` (3 preceding siblings ...)
  2022-06-04 16:12 ` [RESEND PATCH 4/5] iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS() Jonathan Cameron
@ 2022-06-04 16:12 ` Jonathan Cameron
  2022-06-06  8:35   ` Lorenzo Bianconi
  2022-06-11 18:26 ` [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
  5 siblings, 1 reply; 11+ messages in thread
From: Jonathan Cameron @ 2022-06-04 16:12 UTC (permalink / raw)
  To: linux-iio, Paul Cercueil, Lorenzo Bianconi; +Cc: Jonathan Cameron

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

Avoid unnecessary pollution of the global symbol namespace by
moving library functions in to a specific namespace and import
that into the drivers that make use of the functions.

For more info: https://lwn.net/Articles/760045/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220220181522.541718-9-jic23@kernel.org
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 +++---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  | 1 +
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c  | 1 +
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  | 1 +
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 9e4aa5c1c8d6..6b268f1c5fc3 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2289,7 +2289,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 
 	return 0;
 }
-EXPORT_SYMBOL(st_lsm6dsx_probe);
+EXPORT_SYMBOL_NS(st_lsm6dsx_probe, IIO_LSM6DSX);
 
 static int st_lsm6dsx_suspend(struct device *dev)
 {
@@ -2366,8 +2366,8 @@ static int st_lsm6dsx_resume(struct device *dev)
 	return err;
 }
 
-EXPORT_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend,
-			 st_lsm6dsx_resume);
+EXPORT_NS_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend,
+			    st_lsm6dsx_resume, IIO_LSM6DSX);
 
 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
index 5bd565b93a8c..2ea34c0d3a8c 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
@@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx i2c driver");
 MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS(IIO_LSM6DSX);
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
index 4df186499802..3b0c8b19c448 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
@@ -54,3 +54,4 @@ module_i3c_driver(st_lsm6dsx_driver);
 MODULE_AUTHOR("Vitor Soares <vitor.soares@synopsys.com>");
 MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx i3c driver");
 MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS(IIO_LSM6DSX);
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
index 3a206fd4d92c..6a8883f022a8 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
@@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx spi driver");
 MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS(IIO_LSM6DSX);
-- 
2.36.1


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

* Re: [RESEND PATCH 5/5] iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace
  2022-06-04 16:12 ` [RESEND PATCH 5/5] iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace Jonathan Cameron
@ 2022-06-06  8:35   ` Lorenzo Bianconi
  0 siblings, 0 replies; 11+ messages in thread
From: Lorenzo Bianconi @ 2022-06-06  8:35 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Paul Cercueil, Jonathan Cameron

[-- Attachment #1: Type: text/plain, Size: 3345 bytes --]

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Avoid unnecessary pollution of the global symbol namespace by
> moving library functions in to a specific namespace and import
> that into the drivers that make use of the functions.
> 
> For more info: https://lwn.net/Articles/760045/
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Link: https://lore.kernel.org/r/20220220181522.541718-9-jic23@kernel.org

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 +++---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  | 1 +
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c  | 1 +
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  | 1 +
>  4 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 9e4aa5c1c8d6..6b268f1c5fc3 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2289,7 +2289,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  
>  	return 0;
>  }
> -EXPORT_SYMBOL(st_lsm6dsx_probe);
> +EXPORT_SYMBOL_NS(st_lsm6dsx_probe, IIO_LSM6DSX);
>  
>  static int st_lsm6dsx_suspend(struct device *dev)
>  {
> @@ -2366,8 +2366,8 @@ static int st_lsm6dsx_resume(struct device *dev)
>  	return err;
>  }
>  
> -EXPORT_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend,
> -			 st_lsm6dsx_resume);
> +EXPORT_NS_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend,
> +			    st_lsm6dsx_resume, IIO_LSM6DSX);
>  
>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> index 5bd565b93a8c..2ea34c0d3a8c 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> @@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx i2c driver");
>  MODULE_LICENSE("GPL v2");
> +MODULE_IMPORT_NS(IIO_LSM6DSX);
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> index 4df186499802..3b0c8b19c448 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> @@ -54,3 +54,4 @@ module_i3c_driver(st_lsm6dsx_driver);
>  MODULE_AUTHOR("Vitor Soares <vitor.soares@synopsys.com>");
>  MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx i3c driver");
>  MODULE_LICENSE("GPL v2");
> +MODULE_IMPORT_NS(IIO_LSM6DSX);
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> index 3a206fd4d92c..6a8883f022a8 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> @@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx spi driver");
>  MODULE_LICENSE("GPL v2");
> +MODULE_IMPORT_NS(IIO_LSM6DSX);
> -- 
> 2.36.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [RESEND PATCH 4/5] iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS()
  2022-06-04 16:12 ` [RESEND PATCH 4/5] iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS() Jonathan Cameron
@ 2022-06-06  8:37   ` Lorenzo Bianconi
  0 siblings, 0 replies; 11+ messages in thread
From: Lorenzo Bianconi @ 2022-06-06  8:37 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Paul Cercueil, Jonathan Cameron

[-- Attachment #1: Type: text/plain, Size: 4016 bytes --]

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> These new functions move the burden of removing unused code when
> CONFIG_PM_SLEEP is not defined onto the compiler rather than requiring
> the use of CONFIG_PM guards and similar.

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Link: https://lore.kernel.org/r/20220220181522.541718-8-jic23@kernel.org
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 10 ++++------
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  |  2 +-
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c  |  2 +-
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  |  2 +-
>  4 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 910397716833..9e4aa5c1c8d6 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2291,7 +2291,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  }
>  EXPORT_SYMBOL(st_lsm6dsx_probe);
>  
> -static int __maybe_unused st_lsm6dsx_suspend(struct device *dev)
> +static int st_lsm6dsx_suspend(struct device *dev)
>  {
>  	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
>  	struct st_lsm6dsx_sensor *sensor;
> @@ -2330,7 +2330,7 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev)
>  	return err;
>  }
>  
> -static int __maybe_unused st_lsm6dsx_resume(struct device *dev)
> +static int st_lsm6dsx_resume(struct device *dev)
>  {
>  	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
>  	struct st_lsm6dsx_sensor *sensor;
> @@ -2366,10 +2366,8 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev)
>  	return err;
>  }
>  
> -const struct dev_pm_ops st_lsm6dsx_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(st_lsm6dsx_suspend, st_lsm6dsx_resume)
> -};
> -EXPORT_SYMBOL(st_lsm6dsx_pm_ops);
> +EXPORT_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend,
> +			 st_lsm6dsx_resume);
>  
>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> index 715fbdc8190e..5bd565b93a8c 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> @@ -134,7 +134,7 @@ MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
>  static struct i2c_driver st_lsm6dsx_driver = {
>  	.driver = {
>  		.name = "st_lsm6dsx_i2c",
> -		.pm = &st_lsm6dsx_pm_ops,
> +		.pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops),
>  		.of_match_table = st_lsm6dsx_i2c_of_match,
>  	},
>  	.probe = st_lsm6dsx_i2c_probe,
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> index 35556cd04284..4df186499802 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> @@ -44,7 +44,7 @@ static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev)
>  static struct i3c_driver st_lsm6dsx_driver = {
>  	.driver = {
>  		.name = "st_lsm6dsx_i3c",
> -		.pm = &st_lsm6dsx_pm_ops,
> +		.pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops),
>  	},
>  	.probe = st_lsm6dsx_i3c_probe,
>  	.id_table = st_lsm6dsx_i3c_ids,
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> index f5767cf76c1d..3a206fd4d92c 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> @@ -134,7 +134,7 @@ MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
>  static struct spi_driver st_lsm6dsx_driver = {
>  	.driver = {
>  		.name = "st_lsm6dsx_spi",
> -		.pm = &st_lsm6dsx_pm_ops,
> +		.pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops),
>  		.of_match_table = st_lsm6dsx_spi_of_match,
>  	},
>  	.probe = st_lsm6dsx_spi_probe,
> -- 
> 2.36.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [RESEND PATCH 3/5] iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace
  2022-06-04 16:12 ` [RESEND PATCH 3/5] iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace Jonathan Cameron
@ 2022-06-06  8:37   ` Lorenzo Bianconi
  0 siblings, 0 replies; 11+ messages in thread
From: Lorenzo Bianconi @ 2022-06-06  8:37 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Paul Cercueil, Jonathan Cameron

[-- Attachment #1: Type: text/plain, Size: 2622 bytes --]

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Avoid unnecessary pollution of the global symbol namespace by
> moving library functions in to a specific namespace and import
> that into the drivers that make use of the functions.
> 
> For more info: https://lwn.net/Articles/760045/

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Lorenzo Bianconi <lorenzo@kernel.org>
> Link: https://lore.kernel.org/r/20220220181522.541718-7-jic23@kernel.org
> ---
>  drivers/iio/humidity/hts221_core.c | 5 +++--
>  drivers/iio/humidity/hts221_i2c.c  | 1 +
>  drivers/iio/humidity/hts221_spi.c  | 1 +
>  3 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index da9c08432ef2..517158307d8c 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -668,7 +668,7 @@ int hts221_probe(struct device *dev, int irq, const char *name,
>  
>  	return devm_iio_device_register(hw->dev, iio_dev);
>  }
> -EXPORT_SYMBOL(hts221_probe);
> +EXPORT_SYMBOL_NS(hts221_probe, IIO_HTS221);
>  
>  static int hts221_suspend(struct device *dev)
>  {
> @@ -694,7 +694,8 @@ static int hts221_resume(struct device *dev)
>  	return err;
>  }
>  
> -EXPORT_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume);
> +EXPORT_NS_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume,
> +			    IIO_HTS221);
>  
>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics hts221 sensor driver");
> diff --git a/drivers/iio/humidity/hts221_i2c.c b/drivers/iio/humidity/hts221_i2c.c
> index 933b05e4d972..afbc611f7712 100644
> --- a/drivers/iio/humidity/hts221_i2c.c
> +++ b/drivers/iio/humidity/hts221_i2c.c
> @@ -74,3 +74,4 @@ module_i2c_driver(hts221_driver);
>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics hts221 i2c driver");
>  MODULE_LICENSE("GPL v2");
> +MODULE_IMPORT_NS(IIO_HTS221);
> diff --git a/drivers/iio/humidity/hts221_spi.c b/drivers/iio/humidity/hts221_spi.c
> index 888c5eab944c..fc4adb68faf6 100644
> --- a/drivers/iio/humidity/hts221_spi.c
> +++ b/drivers/iio/humidity/hts221_spi.c
> @@ -66,3 +66,4 @@ module_spi_driver(hts221_driver);
>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics hts221 spi driver");
>  MODULE_LICENSE("GPL v2");
> +MODULE_IMPORT_NS(IIO_HTS221);
> -- 
> 2.36.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [RESEND PATCH 2/5] iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code.
  2022-06-04 16:12 ` [RESEND PATCH 2/5] iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code Jonathan Cameron
@ 2022-06-06  8:38   ` Lorenzo Bianconi
  0 siblings, 0 replies; 11+ messages in thread
From: Lorenzo Bianconi @ 2022-06-06  8:38 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Paul Cercueil, Jonathan Cameron

[-- Attachment #1: Type: text/plain, Size: 3248 bytes --]

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> If CONFIG_PM_SLEEP is not defined using EXPORT_SIMPLE_DEV_PM_OPS()
> in conjunction with pm_sleep_ptr() allows the compiler to remove
> the unused code and data. This removes the need for __maybe_unused
> markings etc.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Lorenzo Bianconi <lorenzo@kernel.org>
> Link: https://lore.kernel.org/r/20220220181522.541718-6-jic23@kernel.org

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/iio/humidity/hts221_core.c | 9 +++------
>  drivers/iio/humidity/hts221_i2c.c  | 2 +-
>  drivers/iio/humidity/hts221_spi.c  | 2 +-
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index 6a39615b6961..da9c08432ef2 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -670,7 +670,7 @@ int hts221_probe(struct device *dev, int irq, const char *name,
>  }
>  EXPORT_SYMBOL(hts221_probe);
>  
> -static int __maybe_unused hts221_suspend(struct device *dev)
> +static int hts221_suspend(struct device *dev)
>  {
>  	struct iio_dev *iio_dev = dev_get_drvdata(dev);
>  	struct hts221_hw *hw = iio_priv(iio_dev);
> @@ -680,7 +680,7 @@ static int __maybe_unused hts221_suspend(struct device *dev)
>  				  FIELD_PREP(HTS221_ENABLE_MASK, false));
>  }
>  
> -static int __maybe_unused hts221_resume(struct device *dev)
> +static int hts221_resume(struct device *dev)
>  {
>  	struct iio_dev *iio_dev = dev_get_drvdata(dev);
>  	struct hts221_hw *hw = iio_priv(iio_dev);
> @@ -694,10 +694,7 @@ static int __maybe_unused hts221_resume(struct device *dev)
>  	return err;
>  }
>  
> -const struct dev_pm_ops hts221_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(hts221_suspend, hts221_resume)
> -};
> -EXPORT_SYMBOL(hts221_pm_ops);
> +EXPORT_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume);
>  
>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics hts221 sensor driver");
> diff --git a/drivers/iio/humidity/hts221_i2c.c b/drivers/iio/humidity/hts221_i2c.c
> index cab39c4756f8..933b05e4d972 100644
> --- a/drivers/iio/humidity/hts221_i2c.c
> +++ b/drivers/iio/humidity/hts221_i2c.c
> @@ -62,7 +62,7 @@ MODULE_DEVICE_TABLE(i2c, hts221_i2c_id_table);
>  static struct i2c_driver hts221_driver = {
>  	.driver = {
>  		.name = "hts221_i2c",
> -		.pm = &hts221_pm_ops,
> +		.pm = pm_sleep_ptr(&hts221_pm_ops),
>  		.of_match_table = hts221_i2c_of_match,
>  		.acpi_match_table = ACPI_PTR(hts221_acpi_match),
>  	},
> diff --git a/drivers/iio/humidity/hts221_spi.c b/drivers/iio/humidity/hts221_spi.c
> index 729e86e433b1..888c5eab944c 100644
> --- a/drivers/iio/humidity/hts221_spi.c
> +++ b/drivers/iio/humidity/hts221_spi.c
> @@ -55,7 +55,7 @@ MODULE_DEVICE_TABLE(spi, hts221_spi_id_table);
>  static struct spi_driver hts221_driver = {
>  	.driver = {
>  		.name = "hts221_spi",
> -		.pm = &hts221_pm_ops,
> +		.pm = pm_sleep_ptr(&hts221_pm_ops),
>  		.of_match_table = hts221_spi_of_match,
>  	},
>  	.probe = hts221_spi_probe,
> -- 
> 2.36.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8)
  2022-06-04 16:12 [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
                   ` (4 preceding siblings ...)
  2022-06-04 16:12 ` [RESEND PATCH 5/5] iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace Jonathan Cameron
@ 2022-06-11 18:26 ` Jonathan Cameron
  5 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2022-06-11 18:26 UTC (permalink / raw)
  To: linux-iio, Paul Cercueil, Lorenzo Bianconi; +Cc: Jonathan Cameron

On Sat,  4 Jun 2022 17:12:18 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Resend as the first part of this series went via Rafael's tree and is
> now available in mainline.
> 
> Hence time to return to the remainder which didn't really get much review
> the first time around as focus was on the more interesting new macros
> in the first few patches.
> 

4 out of 5 ain't bad. (remaining one is my driver so hard to lean on
anyone else to review :)

Applied to the togreg branch of iio.git and pushed out as testing for
all the normal reasons.

Thanks,

Jonathan

> Now we have NS specific EXPORT_NS[_GPL]_SIMPLE_DEV_PM_OPS() etc
> we can move these drivers over to their own namespaces reducing polution
> of the global namespace with exports that are only of interest
> within multi module drivers.
> 
> All comments welcome,



> 
> Thanks,
> 
> Jonathan
> 
> 
> Jonathan Cameron (5):
>   iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc
>   iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow
>     compiler to remove dead code.
>   iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace
>   iio: imu: lsm6dsx: Use new pm_sleep_ptr() and
>     EXPORT_SIMPLE_DEV_PM_OPS()
>   iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace
> 
>  drivers/iio/accel/kxsd9-i2c.c                |  2 +-
>  drivers/iio/accel/kxsd9-spi.c                |  2 +-
>  drivers/iio/accel/kxsd9.c                    | 11 ++---------
>  drivers/iio/humidity/hts221_core.c           | 12 +++++-------
>  drivers/iio/humidity/hts221_i2c.c            |  3 ++-
>  drivers/iio/humidity/hts221_spi.c            |  3 ++-
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 12 +++++-------
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  |  3 ++-
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c  |  3 ++-
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  |  3 ++-
>  10 files changed, 24 insertions(+), 30 deletions(-)
> 


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

end of thread, other threads:[~2022-06-11 18:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-04 16:12 [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron
2022-06-04 16:12 ` [RESEND PATCH 1/5] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-06-04 16:12 ` [RESEND PATCH 2/5] iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code Jonathan Cameron
2022-06-06  8:38   ` Lorenzo Bianconi
2022-06-04 16:12 ` [RESEND PATCH 3/5] iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace Jonathan Cameron
2022-06-06  8:37   ` Lorenzo Bianconi
2022-06-04 16:12 ` [RESEND PATCH 4/5] iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS() Jonathan Cameron
2022-06-06  8:37   ` Lorenzo Bianconi
2022-06-04 16:12 ` [RESEND PATCH 5/5] iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace Jonathan Cameron
2022-06-06  8:35   ` Lorenzo Bianconi
2022-06-11 18:26 ` [RESEND PATCH 0/5] IIO: Where dev_pm_ops rework and namespaces meet (4-8) Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.