PM / hwmon: Convert platform hwmon drivers to PM handling based on struct dev_pm_ops
Subsystems (4)
cover PM / hwmon: Convert platform hwmon drivers to PM handling based on struct dev_pm_ops
Hi all,
As per
http://marc.info/?l=linux-kernel&m=133996733422413&w=4
the following patches convert the platform TPM drivers to the PM handling based on struct dev_pm_ops:
[1/4] abituguru: Use struct dev_pm_ops for power management. [2/4] abituguru3: Use struct dev_pm_ops for power management. [3/4] gpio-fan: Use struct dev_pm_ops for power management. [4/4] exynos4_tmu: Use struct dev_pm_ops for power management.
Thanks,
Rafael
PATCH 1/4 hwmon / abituguru: Use struct dev_pm_ops for power management
From: Rafael J. Wysocki <[email protected]>
Make the Abit uGuru driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
--- drivers/hwmon/abituguru.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/hwmon/abituguru.c +13 -8
@@ -1514,9 +1514,11 @@ LEAVE_UPDATE: }#ifdef CONFIG_PM -static int abituguru_suspend (struct platform_device *pdev,pm_message_t state) +static int abituguru_suspend (struct device *dev) { -struct abituguru_data *data =platform_get_drvdata (pdev); +struct abituguru_data *data; + + data =platform_get_drvdata (to_platform_device (dev));/* * make sure all communications with the uguru are done and no new * ones are started
@@ -1525,29 +1527,32 @@ static int abituguru_suspend(struct platreturn 0 ; } -static int abituguru_resume (struct platform_device *pdev) +static int abituguru_resume (struct device *dev) { -struct abituguru_data *data =platform_get_drvdata (pdev); +struct abituguru_data *data; + + data =platform_get_drvdata (to_platform_device (dev));/* See if the uGuru is still ready */ if (inb_p (data->addr +ABIT_UGURU_DATA ) !=ABIT_UGURU_STATUS_INPUT ) data->uguru_ready =0 ;mutex_unlock (&data->update_lock);return 0 ; } + +static SIMPLE_DEV_PM_OPS(abituguru_pm, abituguru_suspend, abituguru_resume); +#define ABIT_UGURU_PM (&abituguru_pm)#else -#define abituguru_suspend NULL -#define abituguru_resume NULL +#define ABIT_UGURU_PM NULL#endif /* CONFIG_PM */ static struct platform_driver abituguru_driver = { .driver = { .owner =THIS_MODULE , .name =ABIT_UGURU_NAME , + .pm =ABIT_UGURU_PM , }, .probe = abituguru_probe, .remove =__devexit_p (abituguru_remove), - .suspend = abituguru_suspend, - .resume = abituguru_resume, };static int __init abituguru_detect (void )
PATCH 1/4 hwmon / abituguru: Use struct dev_pm_ops for power management
From: Rafael J. Wysocki <[email protected]>
Subject: hwmon / abituguru: Use struct dev_pm_ops for power management
Make the Abit uGuru driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
---
dev_get_drvdata() may be used directly instead of being wrapped in platform_get_drvdata(to_platform_device()).
--- drivers/hwmon/abituguru.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/hwmon/abituguru.c +9 -8
@@ -1514,9 +1514,9 @@ LEAVE_UPDATE: }#ifdef CONFIG_PM -static int abituguru_suspend (struct platform_device *pdev,pm_message_t state) +static int abituguru_suspend (struct device *dev) { -struct abituguru_data *data =platform_get_drvdata (pdev); +struct abituguru_data *data =dev_get_drvdata (dev);/* * make sure all communications with the uguru are done and no new * ones are started
@@ -1525,29 +1525,30 @@ static int abituguru_suspend(struct platreturn 0 ; } -static int abituguru_resume (struct platform_device *pdev) +static int abituguru_resume (struct device *dev) { -struct abituguru_data *data =platform_get_drvdata (pdev); +struct abituguru_data *data =dev_get_drvdata (dev);/* See if the uGuru is still ready */ if (inb_p (data->addr +ABIT_UGURU_DATA ) !=ABIT_UGURU_STATUS_INPUT ) data->uguru_ready =0 ;mutex_unlock (&data->update_lock);return 0 ; } + +static SIMPLE_DEV_PM_OPS(abituguru_pm, abituguru_suspend, abituguru_resume); +#define ABIT_UGURU_PM (&abituguru_pm)#else -#define abituguru_suspend NULL -#define abituguru_resume NULL +#define ABIT_UGURU_PM NULL#endif /* CONFIG_PM */ static struct platform_driver abituguru_driver = { .driver = { .owner =THIS_MODULE , .name =ABIT_UGURU_NAME , + .pm =ABIT_UGURU_PM , }, .probe = abituguru_probe, .remove =__devexit_p (abituguru_remove), - .suspend = abituguru_suspend, - .resume = abituguru_resume, };static int __init abituguru_detect (void )
Re: [PATCH 1/4][update] hwmon / abituguru: Use struct dev_pm_ops for power management
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Subject: hwmon / abituguru: Use structdev_pm_opsfor power managementMake the Abit uGuru driver define its PM callbacks through a struct
dev_pm_opsobject rather than by using legacy PM hooks in structplatform_driver.Signed-off-by Rafael J. Wysocki <[email protected]>
Applied to -next.
Thanks,
Guenter
PATCH 2/4 hwmon / abituguru3: Use struct dev_pm_ops for power management
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make the Abit uGuru rev. 3 driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
--- drivers/hwmon/abituguru3.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/hwmon/abituguru3.c +13 -8
@@ -1142,9 +1142,11 @@ LEAVE_UPDATE: }#ifdef CONFIG_PM -static int abituguru3_suspend (struct platform_device *pdev,pm_message_t state) +static int abituguru3_suspend (struct device *dev) { -struct abituguru3_data *data =platform_get_drvdata (pdev); +struct abituguru3_data *data; + + data =platform_get_drvdata (to_platform_device (dev));/* * make sure all communications with the uguru3 are done and no new * ones are started
@@ -1153,26 +1155,29 @@ static int abituguru3_suspend(struct plareturn 0 ; } -static int abituguru3_resume (struct platform_device *pdev) +static int abituguru3_resume (struct device *dev) { -struct abituguru3_data *data =platform_get_drvdata (pdev); +struct abituguru3_data *data; + + data =platform_get_drvdata (to_platform_device (dev));mutex_unlock (&data->update_lock);return 0 ; } + +static SIMPLE_DEV_PM_OPS(abituguru3_pm, abituguru3_suspend, abituguru3_resume); +#define ABIT_UGURU3_PM (&abituguru3_pm)#else -#define abituguru3_suspend NULL -#define abituguru3_resume NULL +#define ABIT_UGURU3_PM NULL#endif /* CONFIG_PM */ static struct platform_driver abituguru3_driver = { .driver = { .owner =THIS_MODULE , .name =ABIT_UGURU3_NAME , + .pm =ABIT_UGURU3_PM }, .probe = abituguru3_probe, .remove =__devexit_p (abituguru3_remove), - .suspend = abituguru3_suspend, - .resume = abituguru3_resume };static int __init abituguru3_dmi_detect (void )
PATCH 2/4 hwmon / abituguru3: Use struct dev_pm_ops for power management
From: Rafael J. Wysocki <[email protected]>
Make the Abit uGuru rev. 3 driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
---
dev_get_drvdata() may be used directly instead of being wrapped in platform_get_drvdata(to_platform_device()).
--- drivers/hwmon/abituguru3.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/hwmon/abituguru3.c +9 -8
@@ -1142,9 +1142,9 @@ LEAVE_UPDATE: }#ifdef CONFIG_PM -static int abituguru3_suspend (struct platform_device *pdev,pm_message_t state) +static int abituguru3_suspend (struct device *dev) { -struct abituguru3_data *data =platform_get_drvdata (pdev); +struct abituguru3_data *data =dev_get_drvdata (dev);/* * make sure all communications with the uguru3 are done and no new * ones are started
@@ -1153,26 +1153,27 @@ static int abituguru3_suspend(struct plareturn 0 ; } -static int abituguru3_resume (struct platform_device *pdev) +static int abituguru3_resume (struct device *dev) { -struct abituguru3_data *data =platform_get_drvdata (pdev); +struct abituguru3_data *data =dev_get_drvdata (dev);mutex_unlock (&data->update_lock);return 0 ; } + +static SIMPLE_DEV_PM_OPS(abituguru3_pm, abituguru3_suspend, abituguru3_resume); +#define ABIT_UGURU3_PM (&abituguru3_pm)#else -#define abituguru3_suspend NULL -#define abituguru3_resume NULL +#define ABIT_UGURU3_PM NULL#endif /* CONFIG_PM */ static struct platform_driver abituguru3_driver = { .driver = { .owner =THIS_MODULE , .name =ABIT_UGURU3_NAME , + .pm =ABIT_UGURU3_PM }, .probe = abituguru3_probe, .remove =__devexit_p (abituguru3_remove), - .suspend = abituguru3_suspend, - .resume = abituguru3_resume };static int __init abituguru3_dmi_detect (void )
Re: [PATCH 2/4][update] hwmon / abituguru3: Use struct dev_pm_ops for power management
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Make the Abit uGuru rev. 3 driver define its PM callbacks through a struct
dev_pm_opsobject rather than by using legacy PM hooks in structplatform_driver.Signed-off-by Rafael J. Wysocki <[email protected]>---
Applied to -next.
Thanks,
Guenter
PATCH 3/4 hwmon / gpio-fan: Use struct dev_pm_ops for power management
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make the gpio-fan driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
--- drivers/hwmon/gpio-fan.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/hwmon/gpio-fan.c +11 -8
@@ -503,10 +503,11 @@ static int __devexit gpio_fan_remove(str }#ifdef CONFIG_PM -static int gpio_fan_suspend (struct platform_device *pdev,pm_message_t state) +static int gpio_fan_suspend (struct device *dev) { -struct gpio_fan_data *fan_data =platform_get_drvdata (pdev); +struct gpio_fan_data *fan_data; + fan_data =platform_get_drvdata (to_platform_device (dev));if (fan_data->ctrl) { fan_data->resume_speed = fan_data->speed_index;set_fan_speed (fan_data,0 );
@@ -515,27 +516,29 @@ static int gpio_fan_suspend(struct platfreturn 0 ; } -static int gpio_fan_resume (struct platform_device *pdev) +static int gpio_fan_resume (struct device *dev) { -struct gpio_fan_data *fan_data =platform_get_drvdata (pdev); +struct gpio_fan_data *fan_data; + fan_data =platform_get_drvdata (to_platform_device (dev));if (fan_data->ctrl)set_fan_speed (fan_data, fan_data->resume_speed);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_suspend NULL -#define gpio_fan_resume NULL +#define GPIO_FAN_PM NULL#endif static struct platform_driver gpio_fan_driver = { .probe = gpio_fan_probe, .remove =__devexit_p (gpio_fan_remove), - .suspend = gpio_fan_suspend, - .resume = gpio_fan_resume, .driver = { .name ="gpio-fan" , + .pm =GPIO_FAN_PM , }, };
PATCH 3/4 hwmon / gpio-fan: Use struct dev_pm_ops for power management
From: Rafael J. Wysocki <[email protected]>
Make the gpio-fan driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
---
dev_get_drvdata() may be used directly instead of being wrapped in platform_get_drvdata(to_platform_device()).
--- drivers/hwmon/gpio-fan.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/hwmon/gpio-fan.c +9 -8
@@ -503,9 +503,9 @@ static int __devexit gpio_fan_remove(str }#ifdef CONFIG_PM -static int gpio_fan_suspend (struct platform_device *pdev,pm_message_t state) +static int gpio_fan_suspend (struct device *dev) { -struct gpio_fan_data *fan_data =platform_get_drvdata (pdev); +struct gpio_fan_data *fan_data =dev_get_drvdata (dev);if (fan_data->ctrl) { fan_data->resume_speed = fan_data->speed_index;
@@ -515,27 +515,28 @@ static int gpio_fan_suspend(struct platfreturn 0 ; } -static int gpio_fan_resume (struct platform_device *pdev) +static int gpio_fan_resume (struct device *dev) { -struct gpio_fan_data *fan_data =platform_get_drvdata (pdev); +struct gpio_fan_data *fan_data =dev_get_drvdata (dev);if (fan_data->ctrl)set_fan_speed (fan_data, fan_data->resume_speed);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_suspend NULL -#define gpio_fan_resume NULL +#define GPIO_FAN_PM NULL#endif static struct platform_driver gpio_fan_driver = { .probe = gpio_fan_probe, .remove =__devexit_p (gpio_fan_remove), - .suspend = gpio_fan_suspend, - .resume = gpio_fan_resume, .driver = { .name ="gpio-fan" , + .pm =GPIO_FAN_PM , }, };
Re: [PATCH 3/4][update] hwmon / gpio-fan: Use struct dev_pm_ops for power management
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Make the gpio-fan driver define its PM callbacks through a struct
dev_pm_opsobject rather than by using legacy PM hooks in structplatform_driver.Signed-off-by Rafael J. Wysocki <[email protected]>
Applied to -next.
Thanks,
Guenter
PATCH 4/4 hwmon / exynos4_tmu: Use struct dev_pm_ops for power management
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make the Exynos4 TMU driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
--- drivers/hwmon/exynos4_tmu.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/hwmon/exynos4_tmu.c +10 -7
@@ -476,34 +476,37 @@ static int __devexit exynos4_tmu_remove( }#ifdef CONFIG_PM -static int exynos4_tmu_suspend (struct platform_device *pdev,pm_message_t state) +static int exynos4_tmu_suspend (struct device *dev) { -exynos4_tmu_control (pdev, false); +exynos4_tmu_control (to_platform_device (dev), false);return 0 ; } -static int exynos4_tmu_resume (struct platform_device *pdev) +static int exynos4_tmu_resume (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev); +exynos4_tmu_initialize (pdev);exynos4_tmu_control (pdev, true);return 0 ; } + +static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm, exynos4_tmu_suspend, exynos4_tmu_resume); +#define EXYNOS4_TMU_PM (&exynos4_tmu_pm)#else -#define exynos4_tmu_suspend NULL -#define exynos4_tmu_resume NULL +#define EXYNOS4_TMU_PM NULL#endif static struct platform_driver exynos4_tmu_driver = { .driver = { .name ="exynos4-tmu" , .owner =THIS_MODULE , + .pm =EXYNOS4_TMU_PM , }, .probe = exynos4_tmu_probe, .remove =__devexit_p (exynos4_tmu_remove), - .suspend = exynos4_tmu_suspend, - .resume = exynos4_tmu_resume, };module_platform_driver (exynos4_tmu_driver);
Guenter Roeck
maintainerRe: [PATCH 4/4] hwmon / exynos4_tmu: Use struct dev_pm_ops for power management
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Make the Exynos4 TMU driver define its PM callbacks through a struct
dev_pm_opsobject rather than by using legacy PM hooks in structplatform_driver.Signed-off-by Rafael J. Wysocki <[email protected]>
Please fix:
WARNING: line over 80 characters
#313: FILE: drivers/hwmon/exynos4_tmu.c:496:
+static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm, exynos4_tmu_suspend, exynos4_tmu_resume);
Guenter
PATCH 4/4 hwmon / exynos4_tmu: Use struct dev_pm_ops for power management
From: Rafael J. Wysocki <[email protected]>
Make the Exynos4 TMU driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
--- drivers/hwmon/exynos4_tmu.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/hwmon/exynos4_tmu.c +11 -7
@@ -476,34 +476,38 @@ static int __devexit exynos4_tmu_remove( }#ifdef CONFIG_PM -static int exynos4_tmu_suspend (struct platform_device *pdev,pm_message_t state) +static int exynos4_tmu_suspend (struct device *dev) { -exynos4_tmu_control (pdev, false); +exynos4_tmu_control (to_platform_device (dev), false);return 0 ; } -static int exynos4_tmu_resume (struct platform_device *pdev) +static int exynos4_tmu_resume (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev); +exynos4_tmu_initialize (pdev);exynos4_tmu_control (pdev, true);return 0 ; } + +static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm, + exynos4_tmu_suspend, exynos4_tmu_resume); +#define EXYNOS4_TMU_PM (&exynos4_tmu_pm)#else -#define exynos4_tmu_suspend NULL -#define exynos4_tmu_resume NULL +#define EXYNOS4_TMU_PM NULL#endif static struct platform_driver exynos4_tmu_driver = { .driver = { .name ="exynos4-tmu" , .owner =THIS_MODULE , + .pm =EXYNOS4_TMU_PM , }, .probe = exynos4_tmu_probe, .remove =__devexit_p (exynos4_tmu_remove), - .suspend = exynos4_tmu_suspend, - .resume = exynos4_tmu_resume, };module_platform_driver (exynos4_tmu_driver);
Guenter Roeck
maintainerRe: [PATCH 4/4][update] hwmon / exynos4_tmu: Use struct dev_pm_ops for power management
Quoted 2 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Hi Rafael,
Quoted 34 lines
Make the Exynos4 TMU driver define its PM callbacks through a struct
dev_pm_opsobject rather than by using legacy PM hooks in structplatform_driver.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/hwmon/exynos4_tmu.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)Index:
linux/drivers/hwmon/exynos4_tmu.c=================================> ---linux.orig/drivers/hwmon/exynos4_tmu.c+++linux/drivers/hwmon/exynos4_tmu.cdrivers/hwmon/exynos4_tmu.c +5
-3@@ -476,34 +476,38 @@ static int __devexit exynos4_tmu_remove( }#ifdef CONFIG_PM -static int exynos4_tmu_suspend (struct platform_device *pdev,pm_message_t state) +static int exynos4_tmu_suspend (struct device *dev) { -exynos4_tmu_control (pdev, false); +exynos4_tmu_control (to_platform_device (dev), false);return 0 ; } -static int exynos4_tmu_resume (struct platform_device *pdev) +static int exynos4_tmu_resume (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev); +exynos4_tmu_initialize (pdev);exynos4_tmu_control (pdev, true);return 0 ;
drivers/hwmon/exynos4_tmu.c static int __devexit exynos4_tmu_remove( · line 501
Quoted 10 lines
drivers/hwmon/exynos4_tmu.c +5
-2} + +static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm, + exynos4_tmu_suspend, exynos4_tmu_resume); +#define EXYNOS4_TMU_PM (&exynos4_tmu_pm)#else -#define exynos4_tmu_suspend NULL -#define exynos4_tmu_resume NULL +#define EXYNOS4_TMU_PM NULL#endif
Actually, looking into other drivers, the common approach seems to be to declare
static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm,
exynos4_tmu_suspend, exynos4_tmu_resume);
outside the #ifdef code and then just assign
.pm = &exynos4_tmu_pm;
unconditionally.
That seems to be a much simpler solution. Any special reason for not implementing it this way ? Same question applies to the other patches in the series.
Thanks,
Guenter
Quoted 5 lines
drivers/hwmon/exynos4_tmu.c +0
-0static struct platform_driver exynos4_tmu_driver = { .driver = { .name ="exynos4-tmu" , .owner =THIS_MODULE ,
drivers/hwmon/exynos4_tmu.c static int __devexit exynos4_tmu_remove(
Quoted 10 lines
drivers/hwmon/exynos4_tmu.c +1
-2+ .pm = EXYNOS4_TMU_PM, }, .probe = exynos4_tmu_probe, .remove = __devexit_p(exynos4_tmu_remove), - .suspend = exynos4_tmu_suspend, - .resume = exynos4_tmu_resume, };module_platform_driver (exynos4_tmu_driver);
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [PATCH 4/4][update] hwmon / exynos4_tmu: Use struct dev_pm_ops for power management
Quoted 58 lines · Guenter Roeck
Quoted 2 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Hi Rafael,
Quoted 35 lines
Make the Exynos4 TMU driver define its PM callbacks through a struct
dev_pm_opsobject rather than by using legacy PM hooks in structplatform_driver.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/hwmon/exynos4_tmu.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)Index:
linux/drivers/hwmon/exynos4_tmu.c
===================================================================drivers/hwmon/exynos4_tmu.c +5
-3@@ -476,34 +476,38 @@ static int __devexit exynos4_tmu_remove( }#ifdef CONFIG_PM -static int exynos4_tmu_suspend (struct platform_device *pdev,pm_message_t state) +static int exynos4_tmu_suspend (struct device *dev) { -exynos4_tmu_control (pdev, false); +exynos4_tmu_control (to_platform_device (dev), false);return 0 ; } -static int exynos4_tmu_resume (struct platform_device *pdev) +static int exynos4_tmu_resume (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev); +exynos4_tmu_initialize (pdev);exynos4_tmu_control (pdev, true);return 0 ;drivers/hwmon/exynos4_tmu.c static int __devexit exynos4_tmu_remove( · line 501
Quoted 10 lines
drivers/hwmon/exynos4_tmu.c +5
-2} + +static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm, + exynos4_tmu_suspend, exynos4_tmu_resume); +#define EXYNOS4_TMU_PM (&exynos4_tmu_pm)#else -#define exynos4_tmu_suspend NULL -#define exynos4_tmu_resume NULL +#define EXYNOS4_TMU_PM NULL#endif Actually, looking into other drivers, the common approach seems to be to declare
static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm,
exynos4_tmu_suspend, exynos4_tmu_resume);outside the #ifdef code and then just assign
Quoted 7 lines
.pm = &exynos4_tmu_pm;unconditionally.
That seems to be a much simpler solution. Any special reason for not implementing it this way ? Same question applies to the other patches in the series.
In fact, there are two ways. One of them is what you said, the other is to put SIMPLE_DEV_PM_OPS() under the #ifdef like I did. I'm not sure which one is prevalent, but what I did has the advatnage that the kernel data will be slightly smaller if CONFIG_PM is unset.
Thanks,
Rafael
Guenter Roeck
maintainerRe: [PATCH 4/4][update] hwmon / exynos4_tmu: Use struct dev_pm_ops for power management
Quoted 63 lines · Rafael J. Wysocki
Quoted 62 lines · Guenter Roeck
Quoted 2 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Hi Rafael,
Quoted 35 lines
Make the Exynos4 TMU driver define its PM callbacks through a struct
dev_pm_opsobject rather than by using legacy PM hooks in structplatform_driver.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/hwmon/exynos4_tmu.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)Index:
linux/drivers/hwmon/exynos4_tmu.c
===================================================================drivers/hwmon/exynos4_tmu.c +5
-3@@ -476,34 +476,38 @@ static int __devexit exynos4_tmu_remove( }#ifdef CONFIG_PM -static int exynos4_tmu_suspend (struct platform_device *pdev,pm_message_t state) +static int exynos4_tmu_suspend (struct device *dev) { -exynos4_tmu_control (pdev, false); +exynos4_tmu_control (to_platform_device (dev), false);return 0 ; } -static int exynos4_tmu_resume (struct platform_device *pdev) +static int exynos4_tmu_resume (struct device *dev) { +struct platform_device *pdev =to_platform_device (dev); +exynos4_tmu_initialize (pdev);exynos4_tmu_control (pdev, true);return 0 ;drivers/hwmon/exynos4_tmu.c static int __devexit exynos4_tmu_remove( · line 501
Quoted 10 lines
drivers/hwmon/exynos4_tmu.c +5
-2} + +static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm, + exynos4_tmu_suspend, exynos4_tmu_resume); +#define EXYNOS4_TMU_PM (&exynos4_tmu_pm)#else -#define exynos4_tmu_suspend NULL -#define exynos4_tmu_resume NULL +#define EXYNOS4_TMU_PM NULL#endif Actually, looking into other drivers, the common approach seems to be to declare
static SIMPLE_DEV_PM_OPS(exynos4_tmu_pm,
exynos4_tmu_suspend, exynos4_tmu_resume);outside the #ifdef code and then just assign
.pm = &exynos4_tmu_pm;unconditionally.
Quoted 9 lines
Quoted 3 lines
That seems to be a much simpler solution. Any special reason for not implementing it this way ? Same question applies to the other patches in the series.
In fact, there are two ways. One of them is what you said, the other is to put
SIMPLE_DEV_PM_OPS()under the #ifdef like I did. I'm not sure which one is prevalent, but what I did has the advatnage that the kernel data will be slightly smaller ifCONFIG_PMis unset.
Ok, make sense. Applied to -next.
Thanks,
Guenter