hwmon: Move to new PM macros reducing driver complexity
Subsystems (6)
cover hwmon: Move to new PM macros reducing driver complexity
From: Jonathan Cameron <[email protected]>
Recently a solution was added to avoiding the need to either guard pm functions with #ifdef magic, or mark the __maybe_unused.
https://lore.kernel.org/all/[email protected]/
This series switches hwmon over to the new macros that are intended to replace SIMPLE_DEV_PM_OPS and similar.
There are a few drivers in hwmon that might be able fine using DEFINE_SIMPLE_PM_OPS() but currently do not define as many of the callbacks as that macro does. As such I haven't touched them in this set.
This is part of general effort to get rid of examples of the older macros that might get copied in new drivers.
Jonathan Cameron (18):
hwmon: (abitguru) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (abitguru3) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (acpi_power_meter) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (adt7x10) Switch to EXPORT_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (gpio-fan) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (it87) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
hwmon: (lm90) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
hwmon: (ltc2947) Switch to EXPORT_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (max31722) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (max31730) witch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (max6639) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (nct6775) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (pwm-fan) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (tmp102) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (tmp103) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (tmp108) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr()
hwmon: (w83627ehf) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and
pm_sleep_ptr() hwmon: (ina3221) Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr()
drivers/hwmon/abituguru.c | 9 ++------- drivers/hwmon/abituguru3.c | 9 ++------- drivers/hwmon/acpi_power_meter.c | 9 +++------ drivers/hwmon/adt7310.c | 2 +- drivers/hwmon/adt7410.c | 2 +- drivers/hwmon/adt7x10.c | 7 +------ drivers/hwmon/adt7x10.h | 5 ----- drivers/hwmon/gpio-fan.c | 9 ++------- drivers/hwmon/ina3221.c | 13 +++++-------- drivers/hwmon/it87.c | 8 ++++---- drivers/hwmon/lm90.c | 8 ++++---- drivers/hwmon/ltc2947-core.c | 7 +++---- drivers/hwmon/ltc2947-i2c.c | 2 +- drivers/hwmon/ltc2947-spi.c | 2 +- drivers/hwmon/max31722.c | 8 ++++---- drivers/hwmon/max31730.c | 8 ++++---- drivers/hwmon/max6639.c | 6 ++---- drivers/hwmon/nct6775-platform.c | 8 ++++---- drivers/hwmon/pwm-fan.c | 6 ++---- drivers/hwmon/tmp102.c | 6 ++---- drivers/hwmon/tmp103.c | 8 ++++---- drivers/hwmon/tmp108.c | 8 ++++---- drivers/hwmon/w83627ehf.c | 8 ++++---- 23 files changed, 60 insertions(+), 98 deletions(-)
Signature · 1 line
2.37.2
PATCH 1/18 hwmon: (abitguru) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
From: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers.
--- drivers/hwmon/abituguru.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/hwmon/abituguru.c +2 -7
@@ -1504,7 +1504,6 @@ static struct abituguru_data *abituguru_update_device(struct device *dev)return NULL ; } -#ifdef CONFIG_PM_SLEEP static int abituguru_suspend (struct device *dev) {struct abituguru_data *data =dev_get_drvdata (dev);
@@ -1526,16 +1525,12 @@ static int abituguru_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(abituguru_pm, abituguru_suspend, abituguru_resume); -#define ABIT_UGURU_PM (&abituguru_pm) -#else -#define ABIT_UGURU_PM NULL -#endif /* CONFIG_PM */ +static DEFINE_SIMPLE_DEV_PM_OPS(abituguru_pm, abituguru_suspend, abituguru_resume);static struct platform_driver abituguru_driver = { .driver = { .name =ABIT_UGURU_NAME , - .pm =ABIT_UGURU_PM , + .pm =pm_sleep_ptr (&abituguru_pm), }, .probe = abituguru_probe, .remove = abituguru_remove,
Signature · 1 line
2.37.2
PATCH 2/18 hwmon: (abitguru3) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst achieving the same result.
--- drivers/hwmon/abituguru3.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/hwmon/abituguru3.c +2 -7
@@ -1127,7 +1127,6 @@ static struct abituguru3_data *abituguru3_update_device(struct device *dev)return NULL ; } -#ifdef CONFIG_PM_SLEEP static int abituguru3_suspend (struct device *dev) {struct abituguru3_data *data =dev_get_drvdata (dev);
@@ -1146,16 +1145,12 @@ static int abituguru3_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(abituguru3_pm, abituguru3_suspend, abituguru3_resume); -#define ABIT_UGURU3_PM (&abituguru3_pm) -#else -#define ABIT_UGURU3_PM NULL -#endif /* CONFIG_PM */ +static DEFINE_SIMPLE_DEV_PM_OPS(abituguru3_pm, abituguru3_suspend, abituguru3_resume);static struct platform_driver abituguru3_driver = { .driver = { .name =ABIT_UGURU3_NAME , - .pm =ABIT_UGURU3_PM + .pm =pm_sleep_ptr (&abituguru3_pm), }, .probe = abituguru3_probe, .remove = abituguru3_remove,
Signature · 1 line
2.37.2
PATCH 3/18 hwmon: (acpi_power_meter) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst achieving the same result.
--- drivers/hwmon/acpi_power_meter.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/hwmon/acpi_power_meter.c +3 -6
@@ -927,8 +927,6 @@ static int acpi_power_meter_remove(struct acpi_device *device)return 0 ; } -#ifdef CONFIG_PM_SLEEP -static int acpi_power_meter_resume (struct device *dev) {struct acpi_power_meter_resource *resource;
@@ -946,9 +944,8 @@ static int acpi_power_meter_resume(struct device *dev)return 0 ; } -#endif /* CONFIG_PM_SLEEP */ - -static SIMPLE_DEV_PM_OPS(acpi_power_meter_pm, NULL, acpi_power_meter_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(acpi_power_meter_pm, NULL, + acpi_power_meter_resume);static struct acpi_driver acpi_power_meter_driver = { .name ="power_meter" ,
@@ -959,7 +956,7 @@ static struct acpi_driver acpi_power_meter_driver = { .remove = acpi_power_meter_remove, .notify = acpi_power_meter_notify, }, - .drv.pm = &acpi_power_meter_pm, + .drv.pm = pm_sleep_ptr(&acpi_power_meter_pm), };/* Module init/exit routines */
Signature · 1 line
2.37.2
PATCH 4/18 hwmon: (adt7x10) Switch to EXPORT_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst achieving the same result.
--- drivers/hwmon/adt7310.c | 2 +- drivers/hwmon/adt7410.c | 2 +- drivers/hwmon/adt7x10.c | 7 +------ drivers/hwmon/adt7x10.h | 5 ----- 4 files changed, 3 insertions(+), 13 deletions(-)
drivers/hwmon/adt7310.c +1 -1
@@ -152,7 +152,7 @@ MODULE_DEVICE_TABLE(spi, adt7310_id);static struct spi_driver adt7310_driver = { .driver = { .name ="adt7310" , - .pm =ADT7X10_DEV_PM_OPS , + .pm =pm_sleep_ptr (&adt7x10_dev_pm_ops), }, .probe = adt7310_spi_probe, .id_table = adt7310_id,
drivers/hwmon/adt7410.c +1 -1
@@ -98,7 +98,7 @@ static struct i2c_driver adt7410_driver = { .class = I2C_CLASS_HWMON, .driver = { .name = "adt7410", - .pm = ADT7X10_DEV_PM_OPS, + .pm = pm_sleep_ptr(&adt7x10_dev_pm_ops), }, .probe_new = adt7410_i2c_probe, .id_table = adt7410_ids,
drivers/hwmon/adt7x10.c +1 -6
@@ -397,8 +397,6 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, }EXPORT_SYMBOL_GPL (adt7x10_probe); -#ifdef CONFIG_PM_SLEEP -static int adt7x10_suspend (struct device *dev) {struct adt7x10_data *data =dev_get_drvdata (dev);
@@ -414,10 +412,7 @@ static int adt7x10_resume(struct device *dev)return regmap_write (data->regmap,ADT7X10_CONFIG , data->config); } -SIMPLE_DEV_PM_OPS (adt7x10_dev_pm_ops, adt7x10_suspend, adt7x10_resume); -EXPORT_SYMBOL_GPL (adt7x10_dev_pm_ops); - -#endif /* CONFIG_PM_SLEEP */ +EXPORT_SIMPLE_DEV_PM_OPS (adt7x10_dev_pm_ops, adt7x10_suspend, adt7x10_resume);MODULE_AUTHOR ("Hartmut Knaack" );MODULE_DESCRIPTION ("ADT7410/ADT7420, ADT7310/ADT7320 common code" );
drivers/hwmon/adt7x10.h +0 -5
@@ -20,11 +20,6 @@ struct device;int adt7x10_probe (struct device *dev,const char *name,int irq,struct regmap *regmap); -#ifdef CONFIG_PM_SLEEP extern const struct dev_pm_ops adt7x10_dev_pm_ops; -#define ADT7X10_DEV_PM_OPS (&adt7x10_dev_pm_ops) -#else -#define ADT7X10_DEV_PM_OPS NULL -#endif #endif
Signature · 1 line
2.37.2
PATCH 5/18 hwmon: (gpio-fan) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst achieving the same result.
--- drivers/hwmon/gpio-fan.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/hwmon/gpio-fan.c +2 -7
@@ -557,7 +557,6 @@ static void gpio_fan_shutdown(struct platform_device *pdev)set_fan_speed (fan_data,0 ); } -#ifdef CONFIG_PM_SLEEP static int gpio_fan_suspend (struct device *dev) {struct gpio_fan_data *fan_data =dev_get_drvdata (dev);
@@ -580,18 +579,14 @@ static int gpio_fan_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume); -#define GPIO_FAN_PM (&gpio_fan_pm) -#else -#define GPIO_FAN_PM NULL -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);static struct platform_driver gpio_fan_driver = { .probe = gpio_fan_probe, .shutdown = gpio_fan_shutdown, .driver = { .name ="gpio-fan" , - .pm =GPIO_FAN_PM , + .pm =pm_sleep_ptr (&gpio_fan_pm), .of_match_table =of_match_ptr (of_gpio_fan_match), }, };
Signature · 1 line
2.37.2
Guenter Roeck
maintainerRe: [PATCH 05/18] hwmon: (gpio-fan) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst achieving the same result.
Signed-off-by Jonathan Cameron <[email protected]>Cc Linus Walleij <[email protected]>
This patch resulted in build errors.
Building m68k:allmodconfig ... failed
--------------
Error log:drivers/hwmon/gpio-fan.c: In function 'gpio_fan_suspend':drivers/hwmon/gpio-fan.c:565:27: error: 'struct gpio_fan_data' has no member named 'resume_speed'
There was an #ifdef CONFIG_PM_SLEEP in struct gpio_fan_data which had to be dropped. I took care of that.
Guenter
Quoted 37 lines
--- drivers/hwmon/gpio-fan.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)drivers/hwmon/gpio-fan.c +2
-7@@ -557,7 +557,6 @@ static void gpio_fan_shutdown(struct platform_device *pdev)set_fan_speed (fan_data,0 ); } -#ifdef CONFIG_PM_SLEEP static int gpio_fan_suspend (struct device *dev) {struct gpio_fan_data *fan_data =dev_get_drvdata (dev);@@ -580,18 +579,14 @@ static int gpio_fan_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume); -#define GPIO_FAN_PM (&gpio_fan_pm) -#else -#define GPIO_FAN_PM NULL -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);static struct platform_driver gpio_fan_driver = { .probe = gpio_fan_probe, .shutdown = gpio_fan_shutdown, .driver = { .name ="gpio-fan" , - .pm =GPIO_FAN_PM , + .pm =pm_sleep_ptr (&gpio_fan_pm), .of_match_table =of_match_ptr (of_gpio_fan_match), }, };
Re: [PATCH 05/18] hwmon: (gpio-fan) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
Quoted 12 lines · On Sun, 25 Sep 2022 11:49:54 -0700 Guenter Roeck <[email protected]> wrote:
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst achieving the same result.
Signed-off-by Jonathan Cameron <[email protected]>Cc Linus Walleij <[email protected]>This patch resulted in build errors.
Quoted 8 lines
Building m68k:allmodconfig ... failed
--------------
Error log:drivers/hwmon/gpio-fan.c: In function 'gpio_fan_suspend':drivers/hwmon/gpio-fan.c:565:27: error: 'structgpio_fan_data' has no member named 'resume_speed'There was an #ifdef
CONFIG_PM_SLEEPin structgpio_fan_datawhich had to be dropped. I took care of that.
Thanks! I clearly missed some tests I should have done. Sorry about that.
Jonathan
Quoted 40 lines
Guenter
Quoted 37 lines
--- drivers/hwmon/gpio-fan.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)drivers/hwmon/gpio-fan.c +2
-7@@ -557,7 +557,6 @@ static void gpio_fan_shutdown(struct platform_device *pdev)set_fan_speed (fan_data,0 ); } -#ifdef CONFIG_PM_SLEEP static int gpio_fan_suspend (struct device *dev) {struct gpio_fan_data *fan_data =dev_get_drvdata (dev);@@ -580,18 +579,14 @@ static int gpio_fan_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume); -#define GPIO_FAN_PM (&gpio_fan_pm) -#else -#define GPIO_FAN_PM NULL -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);static struct platform_driver gpio_fan_driver = { .probe = gpio_fan_probe, .shutdown = gpio_fan_shutdown, .driver = { .name ="gpio-fan" , - .pm =GPIO_FAN_PM , + .pm =pm_sleep_ptr (&gpio_fan_pm), .of_match_table =of_match_ptr (of_gpio_fan_match), }, };
PATCH 6/18 hwmon: (it87) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result.
--- drivers/hwmon/it87.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/it87.c +4 -4
@@ -3179,7 +3179,7 @@ static int it87_probe(struct platform_device *pdev)return PTR_ERR_OR_ZERO (hwmon_dev); } -static void __maybe_unused it87_resume_sio (struct platform_device *pdev) +static void it87_resume_sio (struct platform_device *pdev) {struct it87_data *data =dev_get_drvdata (&pdev->dev);int err;
@@ -3211,7 +3211,7 @@ static void __maybe_unused it87_resume_sio(struct platform_device *pdev)superio_exit (data->sioaddr); } -static int __maybe_unused it87_resume (struct device *dev) +static int it87_resume (struct device *dev) {struct platform_device *pdev =to_platform_device (dev);struct it87_data *data =dev_get_drvdata (dev);
@@ -3238,12 +3238,12 @@ static int __maybe_unused it87_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(it87_dev_pm_ops, NULL, it87_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(it87_dev_pm_ops, NULL, it87_resume);static struct platform_driver it87_driver = { .driver = { .name =DRVNAME , - .pm = &it87_dev_pm_ops, + .pm =pm_sleep_ptr (&it87_dev_pm_ops), }, .probe = it87_probe, };
Signature · 1 line
2.37.2
PATCH 7/18 hwmon: (lm90) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result.
--- drivers/hwmon/lm90.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/lm90.c +4 -4
@@ -2956,7 +2956,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type, } } -static int __maybe_unused lm90_suspend (struct device *dev) +static int lm90_suspend (struct device *dev) {struct lm90_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -2967,7 +2967,7 @@ static int __maybe_unused lm90_suspend(struct device *dev)return 0 ; } -static int __maybe_unused lm90_resume (struct device *dev) +static int lm90_resume (struct device *dev) {struct lm90_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -2978,14 +2978,14 @@ static int __maybe_unused lm90_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(lm90_pm_ops, lm90_suspend, lm90_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(lm90_pm_ops, lm90_suspend, lm90_resume);static struct i2c_driver lm90_driver = { .class =I2C_CLASS_HWMON , .driver = { .name ="lm90" , .of_match_table =of_match_ptr (lm90_of_match), - .pm = &lm90_pm_ops, + .pm =pm_sleep_ptr (&lm90_pm_ops), }, .probe_new = lm90_probe, .alert = lm90_alert,
Signature · 1 line
2.37.2
PATCH 8/18 hwmon: (ltc2947) Switch to EXPORT_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result. In this case it also lets the structure itself be removed.
--- drivers/hwmon/ltc2947-core.c | 7 +++---- drivers/hwmon/ltc2947-i2c.c | 2 +- drivers/hwmon/ltc2947-spi.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/hwmon/ltc2947-core.c +3 -4
@@ -1120,7 +1120,7 @@ int ltc2947_core_probe(struct regmap *map, const char *name) }EXPORT_SYMBOL_GPL (ltc2947_core_probe); -static int __maybe_unused ltc2947_resume (struct device *dev) +static int ltc2947_resume (struct device *dev) {struct ltc2947_data *st =dev_get_drvdata (dev);u32 ctrl =0 ;
@@ -1149,7 +1149,7 @@ static int __maybe_unused ltc2947_resume(struct device *dev) LTC2947_CONT_MODE_MASK, LTC2947_CONT_MODE(1)); } -static int __maybe_unused ltc2947_suspend (struct device *dev) +static int ltc2947_suspend (struct device *dev) {struct ltc2947_data *st =dev_get_drvdata (dev);
@@ -1157,8 +1157,7 @@ static int __maybe_unused ltc2947_suspend(struct device *dev) LTC2947_SHUTDOWN_MASK, 1); } -SIMPLE_DEV_PM_OPS (ltc2947_pm_ops, ltc2947_suspend, ltc2947_resume); -EXPORT_SYMBOL_GPL (ltc2947_pm_ops); +EXPORT_SIMPLE_DEV_PM_OPS (ltc2947_pm_ops, ltc2947_suspend, ltc2947_resume);const struct of_device_id ltc2947_of_match[] = { { .compatible ="adi,ltc2947" },
drivers/hwmon/ltc2947-i2c.c +1 -1
@@ -36,7 +36,7 @@ static struct i2c_driver ltc2947_driver = { .driver = { .name = "ltc2947", .of_match_table = ltc2947_of_match, - .pm = <c2947_pm_ops, + .pm = pm_sleep_ptr(<c2947_pm_ops), }, .probe_new = ltc2947_probe, .id_table = ltc2947_id,
drivers/hwmon/ltc2947-spi.c +1 -1
@@ -38,7 +38,7 @@ static struct spi_driver ltc2947_driver = { .driver = { .name = "ltc2947", .of_match_table = ltc2947_of_match, - .pm = <c2947_pm_ops, + .pm = pm_sleep_ptr(<c2947_pm_ops), }, .probe = ltc2947_probe, .id_table = ltc2947_id,
Signature · 1 line
2.37.2
PATCH 9/18 hwmon: (max31722) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result.
--- drivers/hwmon/max31722.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/max31722.c +4 -4
@@ -113,7 +113,7 @@ static void max31722_remove(struct spi_device *spi)dev_warn (&spi->dev,"Failed to put device in stand-by mode\n" ); } -static int __maybe_unused max31722_suspend (struct device *dev) +static int max31722_suspend (struct device *dev) {struct spi_device *spi_device =to_spi_device (dev);struct max31722_data *data =spi_get_drvdata (spi_device);
@@ -121,7 +121,7 @@ static int __maybe_unused max31722_suspend(struct device *dev)return max31722_set_mode (data,MAX31722_MODE_STANDBY ); } -static int __maybe_unused max31722_resume (struct device *dev) +static int max31722_resume (struct device *dev) {struct spi_device *spi_device =to_spi_device (dev);struct max31722_data *data =spi_get_drvdata (spi_device);
@@ -129,7 +129,7 @@ static int __maybe_unused max31722_resume(struct device *dev)return max31722_set_mode (data,MAX31722_MODE_CONTINUOUS ); } -static SIMPLE_DEV_PM_OPS(max31722_pm_ops, max31722_suspend, max31722_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(max31722_pm_ops, max31722_suspend, max31722_resume);static const struct spi_device_id max31722_spi_id[] = { {"max31722" ,0 },
@@ -141,7 +141,7 @@ MODULE_DEVICE_TABLE(spi, max31722_spi_id);static struct spi_driver max31722_driver = { .driver = { .name ="max31722" , - .pm = &max31722_pm_ops, + .pm =pm_sleep_ptr (&max31722_pm_ops), }, .probe = max31722_probe, .remove = max31722_remove,
Signature · 1 line
2.37.2
PATCH 10/18 hwmon: (max31730) witch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result.
--- drivers/hwmon/max31730.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/max31730.c +4 -4
@@ -404,28 +404,28 @@ static int max31730_detect(struct i2c_client *client,return 0 ; } -static int __maybe_unused max31730_suspend (struct device *dev) +static int max31730_suspend (struct device *dev) {struct max31730_data *data =dev_get_drvdata (dev);return max31730_write_config (data,MAX31730_STOP ,0 ); } -static int __maybe_unused max31730_resume (struct device *dev) +static int max31730_resume (struct device *dev) {struct max31730_data *data =dev_get_drvdata (dev);return max31730_write_config (data,0 ,MAX31730_STOP ); } -static SIMPLE_DEV_PM_OPS(max31730_pm_ops, max31730_suspend, max31730_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(max31730_pm_ops, max31730_suspend, max31730_resume);static struct i2c_driver max31730_driver = { .class =I2C_CLASS_HWMON , .driver = { .name ="max31730" , .of_match_table =of_match_ptr (max31730_of_match), - .pm = &max31730_pm_ops, + .pm =pm_sleep_ptr (&max31730_pm_ops), }, .probe_new = max31730_probe, .id_table = max31730_ids,
Signature · 1 line
2.37.2
PATCH 11/18 hwmon: (max6639) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of #ifdef guards whilst achieving the same result.
--- drivers/hwmon/max6639.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hwmon/max6639.c +2 -4
@@ -571,7 +571,6 @@ static int max6639_probe(struct i2c_client *client)return PTR_ERR_OR_ZERO (hwmon_dev); } -#ifdef CONFIG_PM_SLEEP static int max6639_suspend (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -609,7 +608,6 @@ static int max6639_resume(struct device *dev)return i2c_smbus_write_byte_data (client,MAX6639_REG_GCONFIG , ret & ~MAX6639_GCONFIG_STANDBY ); } -#endif /* CONFIG_PM_SLEEP */ static const struct i2c_device_id max6639_id[] = { {"max6639" ,0 },
@@ -618,13 +616,13 @@ static const struct i2c_device_id max6639_id[] = {MODULE_DEVICE_TABLE (i2c, max6639_id); -static SIMPLE_DEV_PM_OPS(max6639_pm_ops, max6639_suspend, max6639_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(max6639_pm_ops, max6639_suspend, max6639_resume);static struct i2c_driver max6639_driver = { .class =I2C_CLASS_HWMON , .driver = { .name ="max6639" , - .pm = &max6639_pm_ops, + .pm =pm_sleep_ptr (&max6639_pm_ops), }, .probe_new = max6639_probe, .id_table = max6639_id,
Signature · 1 line
2.37.2
PATCH 12/18 hwmon: (nct6775) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result.
--- drivers/hwmon/nct6775-platform.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/nct6775-platform.c +4 -4
@@ -355,7 +355,7 @@ static void nct6791_enable_io_mapping(struct nct6775_sio_data *sio_data) } } -static int __maybe_unused nct6775_suspend (struct device *dev) +static int nct6775_suspend (struct device *dev) {int err;u16 tmp;
@@ -386,7 +386,7 @@ static int __maybe_unused nct6775_suspend(struct device *dev)return err; } -static int __maybe_unused nct6775_resume (struct device *dev) +static int nct6775_resume (struct device *dev) {struct nct6775_data *data =dev_get_drvdata (dev);struct nct6775_sio_data *sio_data =dev_get_platdata (dev);
@@ -467,7 +467,7 @@ static int __maybe_unused nct6775_resume(struct device *dev)return err; } -static SIMPLE_DEV_PM_OPS(nct6775_dev_pm_ops, nct6775_suspend, nct6775_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(nct6775_dev_pm_ops, nct6775_suspend, nct6775_resume);static void nct6775_check_fan_inputs (struct nct6775_data *data,struct nct6775_sio_data *sio_data)
@@ -934,7 +934,7 @@ static int nct6775_platform_probe(struct platform_device *pdev)static struct platform_driver nct6775_driver = { .driver = { .name =DRVNAME , - .pm = &nct6775_dev_pm_ops, + .pm =pm_sleep_ptr (&nct6775_dev_pm_ops), }, .probe = nct6775_platform_probe, };
Signature · 1 line
2.37.2
PATCH 13/18 hwmon: (pwm-fan) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of #ifdef guards whilst achieving the same result.
--- drivers/hwmon/pwm-fan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hwmon/pwm-fan.c +2 -4
@@ -639,7 +639,6 @@ static void pwm_fan_shutdown(struct platform_device *pdev)pwm_fan_cleanup (ctx); } -#ifdef CONFIG_PM_SLEEP static int pwm_fan_suspend (struct device *dev) {struct pwm_fan_ctx *ctx =dev_get_drvdata (dev);
@@ -653,9 +652,8 @@ static int pwm_fan_resume(struct device *dev)return set_pwm (ctx, ctx->pwm_value); } -#endif -static SIMPLE_DEV_PM_OPS(pwm_fan_pm, pwm_fan_suspend, pwm_fan_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(pwm_fan_pm, pwm_fan_suspend, pwm_fan_resume);static const struct of_device_id of_pwm_fan_match[] = { { .compatible ="pwm-fan" , },
@@ -668,7 +666,7 @@ static struct platform_driver pwm_fan_driver = { .shutdown = pwm_fan_shutdown, .driver = { .name = "pwm-fan", - .pm = &pwm_fan_pm, + .pm = pm_sleep_ptr(&pwm_fan_pm), .of_match_table = of_pwm_fan_match, }, };
Signature · 1 line
2.37.2
PATCH 14/18 hwmon: (tmp102) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of #ifdef guards whilst achieving the same result.
--- drivers/hwmon/tmp102.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hwmon/tmp102.c +2 -4
@@ -260,7 +260,6 @@ static int tmp102_probe(struct i2c_client *client)return 0 ; } -#ifdef CONFIG_PM_SLEEP static int tmp102_suspend (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -283,9 +282,8 @@ static int tmp102_resume(struct device *dev)return err; } -#endif /* CONFIG_PM */ -static SIMPLE_DEV_PM_OPS(tmp102_dev_pm_ops, tmp102_suspend, tmp102_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(tmp102_dev_pm_ops, tmp102_suspend, tmp102_resume);static const struct i2c_device_id tmp102_id[] = { {"tmp102" ,0 },
@@ -302,7 +300,7 @@ MODULE_DEVICE_TABLE(of, tmp102_of_match);static struct i2c_driver tmp102_driver = { .driver.name =DRIVER_NAME , .driver.of_match_table =of_match_ptr (tmp102_of_match), - .driver.pm = &tmp102_dev_pm_ops, + .driver.pm =pm_sleep_ptr (&tmp102_dev_pm_ops), .probe_new = tmp102_probe, .id_table = tmp102_id, };
Signature · 1 line
2.37.2
PATCH 15/18 hwmon: (tmp103) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result.
--- drivers/hwmon/tmp103.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp103.c +4 -4
@@ -178,7 +178,7 @@ static int tmp103_probe(struct i2c_client *client)return PTR_ERR_OR_ZERO (hwmon_dev); } -static int __maybe_unused tmp103_suspend (struct device *dev) +static int tmp103_suspend (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);
@@ -186,7 +186,7 @@ static int __maybe_unused tmp103_suspend(struct device *dev) TMP103_CONF_SD_MASK, 0); } -static int __maybe_unused tmp103_resume (struct device *dev) +static int tmp103_resume (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);
@@ -194,7 +194,7 @@ static int __maybe_unused tmp103_resume(struct device *dev) TMP103_CONF_SD_MASK, TMP103_CONF_SD); } -static SIMPLE_DEV_PM_OPS(tmp103_dev_pm_ops, tmp103_suspend, tmp103_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(tmp103_dev_pm_ops, tmp103_suspend, tmp103_resume);static const struct i2c_device_id tmp103_id[] = { {"tmp103" ,0 },
@@ -212,7 +212,7 @@ static struct i2c_driver tmp103_driver = { .driver = { .name = "tmp103", .of_match_table = of_match_ptr(tmp103_of_match), - .pm = &tmp103_dev_pm_ops, + .pm = pm_sleep_ptr(&tmp103_dev_pm_ops), }, .probe_new = tmp103_probe, .id_table = tmp103_id,
Signature · 1 line
2.37.2
PATCH 16/18 hwmon: (tmp108) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result.
--- drivers/hwmon/tmp108.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp108.c +4 -4
@@ -390,7 +390,7 @@ static int tmp108_probe(struct i2c_client *client)return PTR_ERR_OR_ZERO (hwmon_dev); } -static int __maybe_unused tmp108_suspend (struct device *dev) +static int tmp108_suspend (struct device *dev) {struct tmp108 *tmp108 =dev_get_drvdata (dev);
@@ -398,7 +398,7 @@ static int __maybe_unused tmp108_suspend(struct device *dev) TMP108_CONF_MODE_MASK, TMP108_MODE_SHUTDOWN); } -static int __maybe_unused tmp108_resume (struct device *dev) +static int tmp108_resume (struct device *dev) {struct tmp108 *tmp108 =dev_get_drvdata (dev);int err;
@@ -410,7 +410,7 @@ static int __maybe_unused tmp108_resume(struct device *dev)return err; } -static SIMPLE_DEV_PM_OPS(tmp108_dev_pm_ops, tmp108_suspend, tmp108_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(tmp108_dev_pm_ops, tmp108_suspend, tmp108_resume);static const struct i2c_device_id tmp108_i2c_ids[] = { {"tmp108" ,0 },
@@ -429,7 +429,7 @@ MODULE_DEVICE_TABLE(of, tmp108_of_ids);static struct i2c_driver tmp108_driver = { .driver = { .name =DRIVER_NAME , - .pm = &tmp108_dev_pm_ops, + .pm =pm_sleep_ptr (&tmp108_dev_pm_ops), .of_match_table =of_match_ptr (tmp108_of_ids), }, .probe_new = tmp108_probe,
Signature · 1 line
2.37.2
PATCH 17/18 hwmon: (w83627ehf) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These newer PM macros allow the compiler to see what code it can remove if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings whilst achieving the same result.
--- drivers/hwmon/w83627ehf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/w83627ehf.c +4 -4
@@ -1944,7 +1944,7 @@ static int __init w83627ehf_probe(struct platform_device *pdev)return PTR_ERR_OR_ZERO (hwmon_dev); } -static int __maybe_unused w83627ehf_suspend (struct device *dev) +static int w83627ehf_suspend (struct device *dev) {struct w83627ehf_data *data =w83627ehf_update_device (dev);
@@ -1955,7 +1955,7 @@ static int __maybe_unused w83627ehf_suspend(struct device *dev)return 0 ; } -static int __maybe_unused w83627ehf_resume (struct device *dev) +static int w83627ehf_resume (struct device *dev) {struct w83627ehf_data *data =dev_get_drvdata (dev);int i;
@@ -2010,12 +2010,12 @@ static int __maybe_unused w83627ehf_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(w83627ehf_dev_pm_ops, w83627ehf_suspend, w83627ehf_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(w83627ehf_dev_pm_ops, w83627ehf_suspend, w83627ehf_resume);static struct platform_driver w83627ehf_driver = { .driver = { .name =DRVNAME , - .pm = &w83627ehf_dev_pm_ops, + .pm =pm_sleep_ptr (&w83627ehf_dev_pm_ops), }, };
Signature · 1 line
2.37.2
PATCH 18/18 hwmon: (ina3221) Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These new macros allow the compiler to see all the functions even if !CONFIG_PM* and remove the structures and functions if unused. This removes the need for __maybe_unused markings.
--- drivers/hwmon/ina3221.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/hwmon/ina3221.c +5 -8
@@ -930,7 +930,7 @@ static int ina3221_remove(struct i2c_client *client)return 0 ; } -static int __maybe_unused ina3221_suspend (struct device *dev) +static int ina3221_suspend (struct device *dev) {struct ina3221_data *ina =dev_get_drvdata (dev);int ret;
@@ -953,7 +953,7 @@ static int __maybe_unused ina3221_suspend(struct device *dev)return 0 ; } -static int __maybe_unused ina3221_resume (struct device *dev) +static int ina3221_resume (struct device *dev) {struct ina3221_data *ina =dev_get_drvdata (dev);int ret;
@@ -996,11 +996,8 @@ static int __maybe_unused ina3221_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops ina3221_pm = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) -SET_RUNTIME_PM_OPS (ina3221_suspend, ina3221_resume,NULL ) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(ina3221_pm, ina3221_suspend, ina3221_resume, + NULL);static const struct of_device_id ina3221_of_match_table[] = { { .compatible ="ti,ina3221" , },
@@ -1020,7 +1017,7 @@ static struct i2c_driver ina3221_i2c_driver = { .driver = { .name = INA3221_DRIVER_NAME, .of_match_table = ina3221_of_match_table, - .pm = &ina3221_pm, + .pm = pm_ptr(&ina3221_pm), }, .id_table = ina3221_ids, };
Signature · 1 line
2.37.2
Guenter Roeck
maintainerQuoted 9 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Recently a solution was added to avoiding the need to either guard pm functions with #ifdef magic, or mark the
__maybe_unused.
https://lore.kernel.org/all/[email protected]/This series switches hwmon over to the new macros that are intended to replace
SIMPLE_DEV_PM_OPSand similar.
Quoted 6 lines
There are a few drivers in hwmon that might be able fine using
DEFINE_SIMPLE_PM_OPS()but currently do not define as many of the callbacks as that macro does. As such I haven't touched them in this set.This is part of general effort to get rid of examples of the older macros that might get copied in new drivers.
Series applied to hwmon-next.
Thanks,
Guenter