Skip to contentSkip to conversation

PM: Add pm_ops_ptr() macro

PATCH In review Jingoo Han 3 participants 7 messages Apr 27, 2013 – Apr 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.

---
 include/linux/pm.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
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.

First, I'm not taking any more PM patches for v3.10 (that don't fix recent regressions).

Second, please add that macro along with a user.

Thanks,
Rafael

Quoted 20 lines
---
 include/linux/pm.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
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.
author
#2 lore raw

On Saturday, April 27, 2013 11:41 PM, Rafael J. Wysocki:

Quoted 6 lines · Jingoo Han
Quoted 4 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.

Quoted 6 lines
Quoted 1 line

First, I'm not taking any more PM patches for v3.10 (that don't fix recent regressions).

Second, please add that macro along with a user.

Hi Rafael,

This macro can be used as below:
This macro cannot affect the procedure of suspend/resume calls; thus, there is no side effect.
It just reduces the code size of each drivers. In this way, of_match_ptr() macro has been already used.

drivers/i2c/busses/i2c-s3c2410.c +1 -7
@@ -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),
        },
 };

Best regards,
Jingoo Han

Quoted 28 lines

Thanks,
Rafael

Quoted 10 lines
---
 include/linux/pm.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/pm.h +0 -0
index a224c7f..bd50d15 100644

include/linux/pm.h struct device; · line 64

Quoted 10 lines
include/linux/pm.h +2 -0
@@ -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 {

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

#3 lore raw
Quoted 14 lines · Jingoo Han

On Saturday, April 27, 2013 11:41 PM, Rafael J. Wysocki:

Quoted 6 lines · Jingoo Han
Quoted 4 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.

Quoted 6 lines
Quoted 1 line

First, I'm not taking any more PM patches for v3.10 (that don't fix recent regressions).

Second, please add that macro along with a user.

Quoted 7 lines

Hi Rafael,

This macro can be used as below:
This macro cannot affect the procedure of suspend/resume calls; thus, there is no side effect.
It just reduces the code size of each drivers. In this way, of_match_ptr() macro has been already used.

OK, so care to fold the below into your original patch?

Rafael

Quoted 69 lines
drivers/i2c/busses/i2c-s3c2410.c +1 -7
@@ -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),
        },
 };

Best regards,
Jingoo Han

Quoted 23 lines

Thanks,
Rafael

Quoted 18 lines
---
 include/linux/pm.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
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
 
Quoted 5 lines

include/linux/pm.h struct device; · line 64

Quoted 2 lines
include/linux/pm.h +0 -0
 typedef struct pm_message {

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author
#4 lore raw

On Monday, April 29, 2013 8:35 PM, Rafael J. Wysocki:

Quoted 17 lines · Jingoo Han
Quoted 16 lines

On Saturday, April 27, 2013 11:41 PM, Rafael J. Wysocki:

Quoted 6 lines · Jingoo Han
Quoted 4 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.

Quoted 6 lines
Quoted 1 line

First, I'm not taking any more PM patches for v3.10 (that don't fix recent regressions).

Second, please add that macro along with a user.

Hi Rafael,

Quoted 7 lines
Quoted 5 lines

This macro can be used as below:
This macro cannot affect the procedure of suspend/resume calls; thus, there is no side effect.
It just reduces the code size of each drivers. In this way, of_match_ptr() macro has been already used.

OK, so care to fold the below into your original patch?

OK, I will fold it into my original patch.
Then, I will send v2 patch, soon.
Thank you.

Best regards,
Jingoo Han

Quoted 76 lines

Rafael

Quoted 65 lines
drivers/i2c/busses/i2c-s3c2410.c +1 -7
@@ -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),
        },
 };

Best regards,
Jingoo Han

Quoted 23 lines

Thanks,
Rafael

Quoted 18 lines
---
 include/linux/pm.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
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
 
Quoted 5 lines

include/linux/pm.h struct device; · line 64

Quoted 2 lines
include/linux/pm.h +0 -0
 typedef struct pm_message {

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

#5 lore raw
In reply to Jingoo Han
Quoted 46 lines · Jingoo Han

On Saturday, April 27, 2013 11:41 PM, Rafael J. Wysocki:

Quoted 6 lines · Jingoo Han
Quoted 4 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.

Quoted 6 lines
Quoted 1 line

First, I'm not taking any more PM patches for v3.10 (that don't fix recent regressions).

Second, please add that macro along with a user.

Hi Rafael,

This macro can be used as below:
This macro cannot affect the procedure of suspend/resume calls; thus, there is no side effect.
It just reduces the code size of each drivers. In this way, of_match_ptr() macro has been already used.

drivers/i2c/busses/i2c-s3c2410.c +0 -6
@@ -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 = {

drivers/i2c/busses/i2c-s3c2410.c static struct platform_driver s3c24xx_i2c_driver = { · line 1240

Quoted 8 lines
drivers/i2c/busses/i2c-s3c2410.c +1 -1
@@ -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),
        },
 };

Won't that generate a warning about an unused s3c24xx_i2c_dev_pm_ops when CONFIG_PM is not enabled?

author
#6 lore raw
Quoted 45 lines · Lars-Peter Clausen
Quoted 44 lines · Jingoo Han

On Saturday, April 27, 2013 11:41 PM, Rafael J. Wysocki:

Quoted 6 lines · Jingoo Han
Quoted 4 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.

Quoted 6 lines
Quoted 1 line

First, I'm not taking any more PM patches for v3.10 (that don't fix recent regressions).

Second, please add that macro along with a user.

Hi Rafael,

This macro can be used as below:
This macro cannot affect the procedure of suspend/resume calls; thus, there is no side effect.
It just reduces the code size of each drivers. In this way, of_match_ptr() macro has been already used.

drivers/i2c/busses/i2c-s3c2410.c +0 -6
@@ -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 */
 
Quoted 13 lines

drivers/i2c/busses/i2c-s3c2410.c static struct platform_driver s3c24xx_i2c_driver = { · line 1240

Quoted 10 lines
drivers/i2c/busses/i2c-s3c2410.c +1 -1
 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),
        },
 };

Won't that generate a warning about an unused s3c24xx_i2c_dev_pm_ops when CONFIG_PM is not enabled?

No, there is no build warning, when CONFIG_PM is not enabled. In this way, of_match_ptr() macro has been already used without build warnings.

Best regards,
Jingoo Han