Skip to contentSkip to conversation

PM: Add pm_ops_ptr() macro

PATCH In review Jingoo Han 4 participants 5 messages Apr 30, 2013 – May 30, 2013

Subsystems (5)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/1 PM: Add pm_ops_ptr() macro

Add pm_ops_ptr() macro that allows the .pm entry in the driver structures to be assigned without having an #define xxx NULL for the case that PM is not enabled.

---
 drivers/i2c/busses/i2c-s3c2410.c |    8 +-------
 include/linux/pm.h               |    2 ++
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-s3c2410.c +1 -7
index 6e8ee92..e7b6639 100644
@@ -1218,7 +1218,6 @@ static int s3c24xx_i2c_resume(struct device *dev)
 }
 #endif
 
-#ifdef CONFIG_PM
 static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #ifdef CONFIG_PM_SLEEP
 	.suspend_noirq = s3c24xx_i2c_suspend_noirq,
@@ -1226,11 +1225,6 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #endif
 };
 
-#define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
-#else
-#define S3C24XX_DEV_PM_OPS NULL
-#endif
-
 /* device driver for platform bus bits */
 
 static struct platform_driver s3c24xx_i2c_driver = {
@@ -1240,7 +1234,7 @@ static struct platform_driver s3c24xx_i2c_driver = {
 	.driver		= {
 		.owner	= THIS_MODULE,
 		.name	= "s3c-i2c",
-		.pm	= S3C24XX_DEV_PM_OPS,
+		.pm	= pm_ops_ptr(&s3c24xx_i2c_dev_pm_ops),
 		.of_match_table = of_match_ptr(s3c24xx_i2c_match),
 	},
 };
include/linux/pm.h +2 -0
index a224c7f..bd50d15 100644
@@ -55,8 +55,10 @@ struct device;
 
 #ifdef CONFIG_PM
 extern const char power_group_name[];		/* = "power" */
+#define pm_ops_ptr(_ptr)	(_ptr)
 #else
 #define power_group_name	NULL
+#define pm_ops_ptr(_ptr)	NULL
 #endif
 
 typedef struct pm_message {
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 5 lines · Jingoo Han

Add pm_ops_ptr() macro that allows the .pm entry in the driver structures to be assigned without having an #define xxx NULL for the case that PM is not enabled.

I've queued this up as v3.11 material.

Thanks,
Rafael

Quoted 54 lines
---
 drivers/i2c/busses/i2c-s3c2410.c |    8 +-------
 include/linux/pm.h               |    2 ++
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-s3c2410.c +1 -7
index 6e8ee92..e7b6639 100644
@@ -1218,7 +1218,6 @@ static int s3c24xx_i2c_resume(struct device *dev)
 }
 #endif
 
-#ifdef CONFIG_PM
 static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #ifdef CONFIG_PM_SLEEP
 	.suspend_noirq = s3c24xx_i2c_suspend_noirq,
@@ -1226,11 +1225,6 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #endif
 };
 
-#define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
-#else
-#define S3C24XX_DEV_PM_OPS NULL
-#endif
-
 /* device driver for platform bus bits */
 
 static struct platform_driver s3c24xx_i2c_driver = {
@@ -1240,7 +1234,7 @@ static struct platform_driver s3c24xx_i2c_driver = {
 	.driver		= {
 		.owner	= THIS_MODULE,
 		.name	= "s3c-i2c",
-		.pm	= S3C24XX_DEV_PM_OPS,
+		.pm	= pm_ops_ptr(&s3c24xx_i2c_dev_pm_ops),
 		.of_match_table = of_match_ptr(s3c24xx_i2c_match),
 	},
 };
include/linux/pm.h +2 -0
index a224c7f..bd50d15 100644
@@ -55,8 +55,10 @@ struct device;
 
 #ifdef CONFIG_PM
 extern const char power_group_name[];		/* = "power" */
+#define pm_ops_ptr(_ptr)	(_ptr)
 #else
 #define power_group_name	NULL
+#define pm_ops_ptr(_ptr)	NULL
 #endif
 
 typedef struct pm_message {
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#2 lore raw

Hi!

Quoted 22 lines
Quoted 5 lines

Add pm_ops_ptr() macro that allows the .pm entry in the driver structures to be assigned without having an #define xxx NULL for the case that PM is not enabled.

I've queued this up as v3.11 material.

Quoted 14 lines
drivers/i2c/busses/i2c-s3c2410.c +0 -1
@@ -1218,7 +1218,6 @@ static int s3c24xx_i2c_resume(struct device *dev)
 }
 #endif
 
-#ifdef CONFIG_PM
 static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #ifdef CONFIG_PM_SLEEP
 	.suspend_noirq = s3c24xx_i2c_suspend_noirq,
@@ -1226,11 +1225,6 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #endif
 };
 
Quoted 6 lines

drivers/i2c/busses/i2c-s3c2410.c static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = { · line 1228

Quoted 6 lines
drivers/i2c/busses/i2c-s3c2410.c +0 -5
-#define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
-#else
-#define S3C24XX_DEV_PM_OPS NULL
-#endif
-
 /* device driver for platform bus bits */

Will not this enlarge .data by sizeof(struct dev_pm_ops)?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw
Quoted 24 lines · Pavel Machek

Hi!

Quoted 22 lines
Quoted 5 lines

Add pm_ops_ptr() macro that allows the .pm entry in the driver structures to be assigned without having an #define xxx NULL for the case that PM is not enabled.

I've queued this up as v3.11 material.

Quoted 14 lines
drivers/i2c/busses/i2c-s3c2410.c +0 -1
@@ -1218,7 +1218,6 @@ static int s3c24xx_i2c_resume(struct device *dev)
 }
 #endif
 
-#ifdef CONFIG_PM
 static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #ifdef CONFIG_PM_SLEEP
 	.suspend_noirq = s3c24xx_i2c_suspend_noirq,
@@ -1226,11 +1225,6 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #endif
 };
 
Quoted 8 lines
Quoted 6 lines

drivers/i2c/busses/i2c-s3c2410.c static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = { · line 1228

Quoted 6 lines
drivers/i2c/busses/i2c-s3c2410.c +0 -5
-#define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
-#else
-#define S3C24XX_DEV_PM_OPS NULL
-#endif
-
 /* device driver for platform bus bits */

Will not this enlarge .data by sizeof(struct dev_pm_ops)?

Same question here. Is it the preferred way now to use this new macro although having the cost of having an empty dev_pm_ops?

#4 lore raw
Quoted 34 lines · Wolfram Sang
Quoted 24 lines · Pavel Machek

Hi!

Quoted 22 lines
Quoted 5 lines

Add pm_ops_ptr() macro that allows the .pm entry in the driver structures to be assigned without having an #define xxx NULL for the case that PM is not enabled.

I've queued this up as v3.11 material.

Quoted 14 lines
drivers/i2c/busses/i2c-s3c2410.c +0 -1
@@ -1218,7 +1218,6 @@ static int s3c24xx_i2c_resume(struct device *dev)
 }
 #endif
 
-#ifdef CONFIG_PM
 static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #ifdef CONFIG_PM_SLEEP
 	.suspend_noirq = s3c24xx_i2c_suspend_noirq,
@@ -1226,11 +1225,6 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 #endif
 };
 
Quoted 8 lines
Quoted 6 lines

drivers/i2c/busses/i2c-s3c2410.c static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = { · line 1228

Quoted 6 lines
drivers/i2c/busses/i2c-s3c2410.c +0 -5
-#define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
-#else
-#define S3C24XX_DEV_PM_OPS NULL
-#endif
-
 /* device driver for platform bus bits */

Will not this enlarge .data by sizeof(struct dev_pm_ops)?

Quoted 2 lines

Same question here. Is it the preferred way now to use this new macro although having the cost of having an empty dev_pm_ops?

No, it isn't, but if someone wants to use it, I don't really care that much.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.