IIO: Where dev_pm_ops rework and namespaces meet (4-8)
Jonathan Cameron
maintainercover IIO: Where dev_pm_ops rework and namespaces meet (4-8)
From: Jonathan Cameron <[email protected]>
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(-)
Signature · 1 line
2.36.1
Jonathan Cameron
maintainerPATCH RESEND 1/5 iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc
From: Jonathan Cameron <[email protected]>
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.
--- 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(-)
drivers/iio/accel/kxsd9-i2c.c +1 -1
@@ -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,
drivers/iio/accel/kxsd9-spi.c +1 -1
@@ -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,
drivers/iio/accel/kxsd9.c +2 -9
@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("Kionix KXSD9 driver" );
Signature · 1 line
2.36.1
Jonathan Cameron
maintainerPATCH RESEND 2/5 iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- 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(-)
drivers/iio/humidity/hts221_core.c +3 -6
@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics hts221 sensor driver" );
drivers/iio/humidity/hts221_i2c.c +1 -1
@@ -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), },
drivers/iio/humidity/hts221_spi.c +1 -1
@@ -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,
Signature · 1 line
2.36.1
Re: [RESEND PATCH 2/5] iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code.
Quoted 10 lines
From: Jonathan Cameron <[email protected]>
If
CONFIG_PM_SLEEPis not defined usingEXPORT_SIMPLE_DEV_PM_OPS()in conjunction withpm_sleep_ptr()allows the compiler to remove the unused code and data. This removes the need for__maybe_unusedmarkings etc.Signed-off-by Jonathan Cameron <[email protected]>Cc Lorenzo Bianconi <[email protected]>
Quoted 69 lines
--- 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(-)drivers/iio/humidity/hts221_core.c +3
-6@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics hts221 sensor driver" );drivers/iio/humidity/hts221_i2c.c +1
-1@@ -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), },drivers/iio/humidity/hts221_spi.c +1
-1@@ -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,Signature · 1 line
2.36.1
Jonathan Cameron
maintainerPATCH RESEND 3/5 iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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/
--- 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(-)
drivers/iio/humidity/hts221_core.c +3 -2
@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics hts221 sensor driver" );
drivers/iio/humidity/hts221_i2c.c +1 -0
@@ -74,3 +74,4 @@ module_i2c_driver(hts221_driver);MODULE_AUTHOR ("Lorenzo Bianconi <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics hts221 i2c driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_HTS221 );
drivers/iio/humidity/hts221_spi.c +1 -0
@@ -66,3 +66,4 @@ module_spi_driver(hts221_driver);MODULE_AUTHOR ("Lorenzo Bianconi <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics hts221 spi driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_HTS221 );
Signature · 1 line
2.36.1
Re: [RESEND PATCH 3/5] iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace
Quoted 7 lines
From: Jonathan Cameron <[email protected]>
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/
Quoted 54 lines
Signed-off-by Jonathan Cameron <[email protected]>Cc Lorenzo Bianconi <[email protected]>--- 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(-)drivers/iio/humidity/hts221_core.c +3
-2@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics hts221 sensor driver" );drivers/iio/humidity/hts221_i2c.c +1
-0@@ -74,3 +74,4 @@ module_i2c_driver(hts221_driver);MODULE_AUTHOR ("Lorenzo Bianconi <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics hts221 i2c driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_HTS221 );drivers/iio/humidity/hts221_spi.c +1
-0@@ -66,3 +66,4 @@ module_spi_driver(hts221_driver);MODULE_AUTHOR ("Lorenzo Bianconi <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics hts221 spi driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_HTS221 );Signature · 1 line
2.36.1
Jonathan Cameron
maintainerPATCH RESEND 4/5 iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- 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(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +4 -6
@@ -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 <[email protected]>" );MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +1 -1
@@ -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,
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c +1 -1
@@ -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,
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +1 -1
@@ -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,
Signature · 1 line
2.36.1
Re: [RESEND PATCH 4/5] iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS()
Quoted 5 lines
From: Jonathan Cameron <[email protected]>
These new functions move the burden of removing unused code when
CONFIG_PM_SLEEPis not defined onto the compiler rather than requiring the use ofCONFIG_PMguards and similar.
Quoted 87 lines
Signed-off-by Jonathan Cameron <[email protected]>--- 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(-)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +4
-6@@ -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 <[email protected]>" );MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +1
-1@@ -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,drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c +1
-1@@ -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,drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +1
-1@@ -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,Signature · 1 line
2.36.1
Jonathan Cameron
maintainerPATCH RESEND 5/5 iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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/
--- 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(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +3 -3
@@ -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 <[email protected]>" );MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +1 -0
@@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi <[email protected]>");MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics st_lsm6dsx i2c driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_LSM6DSX );
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c +1 -0
@@ -54,3 +54,4 @@ module_i3c_driver(st_lsm6dsx_driver);MODULE_AUTHOR ("Vitor Soares <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics st_lsm6dsx i3c driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_LSM6DSX );
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +1 -0
@@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi <[email protected]>");MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics st_lsm6dsx spi driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_LSM6DSX );
Signature · 1 line
2.36.1
Re: [RESEND PATCH 5/5] iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace
Quoted 10 lines
From: Jonathan Cameron <[email protected]>
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/
Quoted 61 lines
--- 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(-)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +3
-3@@ -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 <[email protected]>" );MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +1
-0@@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi <[email protected]>");MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics st_lsm6dsx i2c driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_LSM6DSX );drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c +1
-0@@ -54,3 +54,4 @@ module_i3c_driver(st_lsm6dsx_driver);MODULE_AUTHOR ("Vitor Soares <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics st_lsm6dsx i3c driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_LSM6DSX );drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +1
-0@@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi <[email protected]>");MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics st_lsm6dsx spi driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_LSM6DSX );Signature · 1 line
2.36.1
Jonathan Cameron
maintainerQuoted 9 lines · On Sat, 4 Jun 2022 17:12:18 +0100 Jonathan Cameron <[email protected]> wrote:
From: Jonathan Cameron <[email protected]>
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
Quoted 36 lines
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 fromCONFIG_PMguards topm_ptr()etc
iio: humidity: hts221: UseEXPORT_SIMPLE_DEV_PM_OPS()to allow
compiler to remove dead code.
iio: humidity: hts221: Move symbol exports intoIIO_HTS221namespace
iio: imu: lsm6dsx: Use newpm_sleep_ptr()and
EXPORT_SIMPLE_DEV_PM_OPS()
iio: imu: lsm6dsx: Move exported symbols to theIIO_LSM6DSXnamespacedrivers/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(-)