hwmon: tmp103: use SIMPLE_DEV_PM_OPS helper macro
PATCH 1/1 hwmon: tmp103: use SIMPLE_DEV_PM_OPS helper macro
Replace ifdefs with SIMPLE_DEV_PM_OPS helper macro.
--- drivers/hwmon/tmp103.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/hwmon/tmp103.c +4 -13
@@ -150,8 +150,7 @@ static int tmp103_probe(struct i2c_client *client,return PTR_ERR_OR_ZERO (hwmon_dev); } -#ifdef CONFIG_PM -static int tmp103_suspend (struct device *dev) +static int __maybe_unused tmp103_suspend (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);
@@ -159,7 +158,7 @@ static int tmp103_suspend(struct device *dev) TMP103_CONF_SD_MASK, 0); } -static int tmp103_resume (struct device *dev) +static int __maybe_unused tmp103_resume (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);
@@ -167,15 +166,7 @@ static int tmp103_resume(struct device *dev) TMP103_CONF_SD_MASK, TMP103_CONF_SD); } -static const struct dev_pm_ops tmp103_dev_pm_ops = { - .suspend = tmp103_suspend, - .resume = tmp103_resume, -}; - -#define TMP103_DEV_PM_OPS (&tmp103_dev_pm_ops) -#else -#define TMP103_DEV_PM_OPS NULL -#endif /* CONFIG_PM */ +static SIMPLE_DEV_PM_OPS(tmp103_dev_pm_ops, tmp103_suspend, tmp103_resume);static const struct i2c_device_id tmp103_id[] = { {"tmp103" ,0 },
@@ -193,7 +184,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 = &tmp103_dev_pm_ops, }, .probe = tmp103_probe, .id_table = tmp103_id,
Signature · 1 line
2.7.4
Guenter Roeck
maintainerHi Rahul,
Quoted 3 lines · Rahul Bedarkar
Replace ifdefs with
SIMPLE_DEV_PM_OPShelper macro.Signed-off-by Rahul Bedarkar <[email protected]>
Thanks a lot for your patch.
While I in general prefer code that avoids #ifdef, I have seen patches which do the opposite when handling PM code. It appears that it is unsettled if __maybe_unused or #ifdef should be used in such situations. Until that is the case, I won't accept patches changing one into another unless they are from the driver author or Acked by the driver author.
Thanks,
Guenter
Quoted 54 lines
--- drivers/hwmon/tmp103.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)drivers/hwmon/tmp103.c +4
-13@@ -150,8 +150,7 @@ static int tmp103_probe(struct i2c_client *client,return PTR_ERR_OR_ZERO (hwmon_dev); } -#ifdef CONFIG_PM -static int tmp103_suspend (struct device *dev) +static int __maybe_unused tmp103_suspend (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);@@ -159,7 +158,7 @@ static int tmp103_suspend(struct device *dev) TMP103_CONF_SD_MASK, 0); } -static int tmp103_resume (struct device *dev) +static int __maybe_unused tmp103_resume (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);@@ -167,15 +166,7 @@ static int tmp103_resume(struct device *dev) TMP103_CONF_SD_MASK, TMP103_CONF_SD); } -static const struct dev_pm_ops tmp103_dev_pm_ops = { - .suspend = tmp103_suspend, - .resume = tmp103_resume, -}; - -#define TMP103_DEV_PM_OPS (&tmp103_dev_pm_ops) -#else -#define TMP103_DEV_PM_OPS NULL -#endif /* CONFIG_PM */ +static SIMPLE_DEV_PM_OPS(tmp103_dev_pm_ops, tmp103_suspend, tmp103_resume);static const struct i2c_device_id tmp103_id[] = { {"tmp103" ,0 },@@ -193,7 +184,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 = &tmp103_dev_pm_ops, }, .probe = tmp103_probe, .id_table = tmp103_id,
Heiko Schocher
Acked-byHello Guenter, Rahul,
Am 23.04.2017 um 17:43 schrieb Guenter Roeck:
Quoted 7 lines
Hi Rahul,
Quoted 3 lines · Rahul Bedarkar
Replace ifdefs with
SIMPLE_DEV_PM_OPShelper macro.Signed-off-by Rahul Bedarkar <[email protected]>
Quoted 7 lines
Thanks a lot for your patch.
While I in general prefer code that avoids #ifdef, I have seen patches which do the opposite when handling PM code. It appears that it is unsettled if
__maybe_unusedor #ifdef should be used in such situations. Until that is the case, I won't accept patches changing one into another unless they are from the driver author or Acked by the driver author.
Hmm.. I like this patch too, but have also no idea, what is preffered.
Looking into drivers/hwmon
pollux:linux hs [master] $ grep -lr __maybe_unused drivers/hwmon/ drivers/hwmon/tmp108.cdrivers/hwmon/nct6775.cdrivers/hwmon/hwmon-vid.cdrivers/hwmon/max31722.c
Ok, there are hwmon drivers, which use this version already ...
pollux:linux hs [master] $ grep -lr CONFIG_PM drivers/hwmon/ drivers/hwmon/max6639.cdrivers/hwmon/jc42.cdrivers/hwmon/fam15h_power.c drivers/hwmon/tmp102.cdrivers/hwmon/gpio-fan.cdrivers/hwmon/pwm-fan.cdrivers/hwmon/tmp103.c drivers/hwmon/pmbus/Makefiledrivers/hwmon/lm75.cdrivers/hwmon/nct6683.cdrivers/hwmon/adt7x10.hdrivers/hwmon/w83627hf.c drivers/hwmon/abituguru3.cdrivers/hwmon/Makefile drivers/hwmon/acpi_power_meter.c drivers/hwmon/adt7x10.cdrivers/hwmon/abituguru.c drivers/hwmon/w83627ehf.c
May this conversion should be done in a patch, which touches more devices?
Nevertheless, I like this approach, so:
bye,
Heiko
Quoted 59 lines
Thanks,
GuenterQuoted 54 lines
--- drivers/hwmon/tmp103.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)drivers/hwmon/tmp103.c +4
-13@@ -150,8 +150,7 @@ static int tmp103_probe(struct i2c_client *client,return PTR_ERR_OR_ZERO (hwmon_dev); } -#ifdef CONFIG_PM -static int tmp103_suspend (struct device *dev) +static int __maybe_unused tmp103_suspend (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);@@ -159,7 +158,7 @@ static int tmp103_suspend(struct device *dev) TMP103_CONF_SD_MASK, 0); } -static int tmp103_resume (struct device *dev) +static int __maybe_unused tmp103_resume (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);@@ -167,15 +166,7 @@ static int tmp103_resume(struct device *dev) TMP103_CONF_SD_MASK, TMP103_CONF_SD); } -static const struct dev_pm_ops tmp103_dev_pm_ops = { - .suspend = tmp103_suspend, - .resume = tmp103_resume, -}; - -#define TMP103_DEV_PM_OPS (&tmp103_dev_pm_ops) -#else -#define TMP103_DEV_PM_OPS NULL -#endif /* CONFIG_PM */ +static SIMPLE_DEV_PM_OPS(tmp103_dev_pm_ops, tmp103_suspend, tmp103_resume);static const struct i2c_device_id tmp103_id[] = { {"tmp103" ,0 },@@ -193,7 +184,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 = &tmp103_dev_pm_ops, }, .probe = tmp103_probe, .id_table = tmp103_id,
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Hello Guenter, Heiko,
Quoted 6 lines · Heiko Schocher
Hello Guenter, Rahul,
Hmm.. I like this patch too, but have also no idea, what is preffered.
Looking into
drivers/hwmon
Quoted 7 lines
pollux:linux hs [master] $ grep -lr
__maybe_unuseddrivers/hwmon/drivers/hwmon/tmp108.cdrivers/hwmon/nct6775.cdrivers/hwmon/hwmon-vid.cdrivers/hwmon/max31722.cOk, there are hwmon drivers, which use this version already ...
Yes, some hwmon drivers already use this approach. Some drivers in other sub systems also using it from start or moving towards this approach.
Quoted 21 lines
pollux:linux hs [master] $ grep -lr
CONFIG_PMdrivers/hwmon/drivers/hwmon/max6639.cdrivers/hwmon/jc42.cdrivers/hwmon/fam15h_power.cdrivers/hwmon/tmp102.cdrivers/hwmon/gpio-fan.cdrivers/hwmon/pwm-fan.cdrivers/hwmon/tmp103.cdrivers/hwmon/pmbus/Makefiledrivers/hwmon/lm75.cdrivers/hwmon/nct6683.cdrivers/hwmon/adt7x10.hdrivers/hwmon/w83627hf.cdrivers/hwmon/abituguru3.cdrivers/hwmon/Makefiledrivers/hwmon/acpi_power_meter.cdrivers/hwmon/adt7x10.cdrivers/hwmon/abituguru.cdrivers/hwmon/w83627ehf.c
Quoted 2 lines
May this conversion should be done in a patch, which touches more devices?
I'm happy send patches converting remaining drivers once this is settled or accepted.
Thanks for your reviews.
Regards,
Rahul
Guenter Roeck
maintainerQuoted 15 lines · Rahul Bedarkar
Hello Guenter, Heiko,
Quoted 12 lines · Heiko Schocher
Hello Guenter, Rahul,
Hmm.. I like this patch too, but have also no idea, what is preffered.
Looking into
drivers/hwmonpollux:linux hs [master] $ grep -lr
__maybe_unuseddrivers/hwmon/drivers/hwmon/tmp108.cdrivers/hwmon/nct6775.cdrivers/hwmon/hwmon-vid.cdrivers/hwmon/max31722.c
Quoted 6 lines
Quoted 1 line
Ok, there are hwmon drivers, which use this version already ...
Yes, some hwmon drivers already use this approach. Some drivers in other sub systems also using it from start or moving towards this approach.
Yes, but as I mentioned it is unsettled if one or the other approach is preferred, which makes me a bit wary. I'll be open to accepting patches for jc42 and nct6883 since I am the author of those drivers.
Thanks,
Guenter
Quoted 31 lines
Quoted 21 lines
pollux:linux hs [master] $ grep -lr
CONFIG_PMdrivers/hwmon/drivers/hwmon/max6639.cdrivers/hwmon/jc42.cdrivers/hwmon/fam15h_power.cdrivers/hwmon/tmp102.cdrivers/hwmon/gpio-fan.cdrivers/hwmon/pwm-fan.cdrivers/hwmon/tmp103.cdrivers/hwmon/pmbus/Makefiledrivers/hwmon/lm75.cdrivers/hwmon/nct6683.cdrivers/hwmon/adt7x10.hdrivers/hwmon/w83627hf.cdrivers/hwmon/abituguru3.cdrivers/hwmon/Makefiledrivers/hwmon/acpi_power_meter.cdrivers/hwmon/adt7x10.cdrivers/hwmon/abituguru.cdrivers/hwmon/w83627ehf.cQuoted 2 lines
May this conversion should be done in a patch, which touches more devices?
I'm happy send patches converting remaining drivers once this is settled or accepted.
Thanks for your reviews.
Regards,
Rahul
Quoted 50 lines · Heiko Schocher
Hello Guenter, Rahul,
Am 23.04.2017 um 17:43 schrieb Guenter Roeck:
Quoted 7 lines
Hi Rahul,
Quoted 3 lines · Rahul Bedarkar
Replace ifdefs with
SIMPLE_DEV_PM_OPShelper macro.Signed-off-by Rahul Bedarkar <[email protected]>Quoted 7 lines
Thanks a lot for your patch.
While I in general prefer code that avoids #ifdef, I have seen patches which do the opposite when handling PM code. It appears that it is unsettled if
__maybe_unusedor #ifdef should be used in such situations. Until that is the case, I won't accept patches changing one into another unless they are from the driver author or Acked by the driver author.Hmm.. I like this patch too, but have also no idea, what is preffered.
Looking into
drivers/hwmonpollux:linux hs [master] $ grep -lr
__maybe_unuseddrivers/hwmon/drivers/hwmon/tmp108.cdrivers/hwmon/nct6775.cdrivers/hwmon/hwmon-vid.cdrivers/hwmon/max31722.cOk, there are hwmon drivers, which use this version already ...
pollux:linux hs [master] $ grep -lr
CONFIG_PMdrivers/hwmon/drivers/hwmon/max6639.cdrivers/hwmon/jc42.cdrivers/hwmon/fam15h_power.cdrivers/hwmon/tmp102.cdrivers/hwmon/gpio-fan.cdrivers/hwmon/pwm-fan.cdrivers/hwmon/tmp103.cdrivers/hwmon/pmbus/Makefiledrivers/hwmon/lm75.cdrivers/hwmon/nct6683.cdrivers/hwmon/adt7x10.hdrivers/hwmon/w83627hf.cdrivers/hwmon/abituguru3.cdrivers/hwmon/Makefiledrivers/hwmon/acpi_power_meter.cdrivers/hwmon/adt7x10.cdrivers/hwmon/abituguru.cdrivers/hwmon/w83627ehf.c
Quoted 7 lines
May this conversion should be done in a patch, which touches more devices?
Nevertheless, I like this approach, so:
Acked-by Heiko Schocher <[email protected]>
Thanks, applied to hwmon-next.
Guenter
Quoted 70 lines
bye,
HeikoQuoted 59 lines
Thanks,
GuenterQuoted 54 lines
---
drivers/hwmon/tmp103.c| 17 ++++-------------1 file changed, 4 insertions(+), 13 deletions(-)drivers/hwmon/tmp103.c +4
-13@@ -150,8 +150,7 @@ static int tmp103_probe(struct i2c_client *client,return PTR_ERR_OR_ZERO (hwmon_dev); } -#ifdef CONFIG_PM -static int tmp103_suspend (struct device *dev) +static int __maybe_unused tmp103_suspend (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);@@ -159,7 +158,7 @@ static int tmp103_suspend(struct device *dev) TMP103_CONF_SD_MASK, 0); } -static int tmp103_resume (struct device *dev) +static int __maybe_unused tmp103_resume (struct device *dev) {struct regmap *regmap =dev_get_drvdata (dev);@@ -167,15 +166,7 @@ static int tmp103_resume(struct device *dev) TMP103_CONF_SD_MASK, TMP103_CONF_SD); } -static const struct dev_pm_ops tmp103_dev_pm_ops = { - .suspend = tmp103_suspend, - .resume = tmp103_resume, -}; - -#define TMP103_DEV_PM_OPS (&tmp103_dev_pm_ops) -#else -#define TMP103_DEV_PM_OPS NULL -#endif /* CONFIG_PM */ +static SIMPLE_DEV_PM_OPS(tmp103_dev_pm_ops, tmp103_suspend, tmp103_resume);static const struct i2c_device_id tmp103_id[] = { {"tmp103" ,0 },@@ -193,7 +184,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 = &tmp103_dev_pm_ops, }, .probe = tmp103_probe, .id_table = tmp103_id,Signature · 6 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany -- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html