Staging: ste_rmi4: Use SIMPLE_DEV_PM_OPS() macro
PATCH 1/1 Staging: ste_rmi4: Use SIMPLE_DEV_PM_OPS() macro
Macro SIMPLE_DEV_PM_OPS() can be used when same suspend and resume callbacks are used for suspend to RAM and hibernation. So, here use SIMPLE_DEV_PM_OPS to make code shorter and cleaner.
--- drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +3 -6
@@ -1112,12 +1112,11 @@ static int synaptics_rmi4_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops = { - .suspend = synaptics_rmi4_suspend, - .resume = synaptics_rmi4_resume, -};#endif +static SIMPLE_DEV_PM_OPS(synaptics_rmi4_dev_pm_ops, synaptics_rmi4_suspend, + synaptics_rmi4_resume); +static const struct i2c_device_id synaptics_rmi4_id_table[] = { {DRIVER_NAME ,0 }, { },
@@ -1128,9 +1127,7 @@ static struct i2c_driver synaptics_rmi4_driver = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, -#ifdef CONFIG_PM .pm = &synaptics_rmi4_dev_pm_ops, -#endif }, .probe = synaptics_rmi4_probe, .remove = synaptics_rmi4_remove,
Signature · 1 line
1.9.1
Quoted 31 lines · Vaishali Thakkar
Macro
SIMPLE_DEV_PM_OPS()can be used when same suspend and resume callbacks are used for suspend to RAM and hibernation. So, here useSIMPLE_DEV_PM_OPSto make code shorter and cleaner.Signed-off-by Vaishali Thakkar <[email protected]>--- drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +3
-4@@ -1112,12 +1112,11 @@ static int synaptics_rmi4_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops = { - .suspend = synaptics_rmi4_suspend, - .resume = synaptics_rmi4_resume, -};#endif +static SIMPLE_DEV_PM_OPS(synaptics_rmi4_dev_pm_ops, synaptics_rmi4_suspend, + synaptics_rmi4_resume); +static const struct i2c_device_id synaptics_rmi4_id_table[] = { {DRIVER_NAME ,0 }, { },
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c static struct i2c_driver synaptics_rmi4_driver = { · line 1133
Quoted 6 lines
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +0
-2@@ -1128,9 +1127,7 @@ static struct i2c_driver synaptics_rmi4_driver = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, -#ifdef CONFIG_PM .pm = &synaptics_rmi4_dev_pm_ops, -#endif
How does this work? I guess that before the pm field could sometimes be null, if power management is not supported. Not the field is not null. Are the fields for the functions now null if there is no power management, or are there just trivial definitions? (It's not a suggestion about changing the patch; I am just wondering).
julia
Quoted 13 lines
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +0
-1}, .probe = synaptics_rmi4_probe, .remove = synaptics_rmi4_remove, --1.9.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20150320071750.GA8322%40vaishali-Ideapad-Z570.
For more options, visit https://groups.google.com/d/optout.
Quoted 37 lines · Julia Lawall
Quoted 35 lines · Vaishali Thakkar
Macro
SIMPLE_DEV_PM_OPS()can be used when same suspend and resume callbacks are used for suspend to RAM and hibernation. So, here useSIMPLE_DEV_PM_OPSto make code shorter and cleaner.Signed-off-by Vaishali Thakkar <[email protected]>--- drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +3
-5@@ -1112,12 +1112,11 @@ static int synaptics_rmi4_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops = { - .suspend = synaptics_rmi4_suspend, - .resume = synaptics_rmi4_resume, -};#endif +static SIMPLE_DEV_PM_OPS(synaptics_rmi4_dev_pm_ops, synaptics_rmi4_suspend, + synaptics_rmi4_resume); +static const struct i2c_device_id synaptics_rmi4_id_table[] = { {DRIVER_NAME ,0 }, { },@@ -1128,9 +1127,7 @@ static struct i2c_driver synaptics_rmi4_driver = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, -#ifdef CONFIG_PM
Quoted 8 lines
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c static struct i2c_driver synaptics_rmi4_driver = { · line 1133
Quoted 2 lines
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +0
-1.pm = &synaptics_rmi4_dev_pm_ops, -#endif How does this work? I guess that before the pm field could sometimes be null, if power management is not supported. Not the field is not null. Are the fields for the functions now null if there is no power management, or are there just trivial definitions? (It's not a suggestion about changing the patch; I am just wondering).
Yes. I think members of synaptics_rmi4_dev_pm_ops can be null if there is no power management after this change.
As far as I understand, 'SIMPLE_DEV_PM_OPS' macro is defined as follows:
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
const struct dev_pm_ops name = { \
SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
}And then 'SET_SYSTEM_SLEEP_PM_OPS' like this:
#ifdef CONFIG_PM_SLEEP
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
.suspend = suspend_fn, \
.resume = resume_fn, \
.freeze = suspend_fn, \
.thaw = resume_fn, \
.poweroff = suspend_fn, \
.restore = resume_fn,#else
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) #endif
So, when CONFIG_PM is not enabled, we can simply remove these guards. And we can write like this:
static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops{ };
However, at first I was unsure about this change. But as this patch is not giving any kind of build error I guess this change should work.
Although this is my understanding. It may possible that I am wrong. Correct me if I am missing something.
Thank You.
Quoted 15 lines
julia
Quoted 13 lines
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +0
-1}, .probe = synaptics_rmi4_probe, .remove = synaptics_rmi4_remove, --1.9.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20150320071750.GA8322%40vaishali-Ideapad-Z570.
For more options, visit https://groups.google.com/d/optout.
Signature · 1 line
Vaishali
Quoted 76 lines · Vaishali Thakkar
Quoted 37 lines · Julia Lawall
Quoted 35 lines · Vaishali Thakkar
Macro
SIMPLE_DEV_PM_OPS()can be used when same suspend and resume callbacks are used for suspend to RAM and hibernation. So, here useSIMPLE_DEV_PM_OPSto make code shorter and cleaner.Signed-off-by Vaishali Thakkar <[email protected]>--- drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +3
-5@@ -1112,12 +1112,11 @@ static int synaptics_rmi4_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops = { - .suspend = synaptics_rmi4_suspend, - .resume = synaptics_rmi4_resume, -};#endif +static SIMPLE_DEV_PM_OPS(synaptics_rmi4_dev_pm_ops, synaptics_rmi4_suspend, + synaptics_rmi4_resume); +static const struct i2c_device_id synaptics_rmi4_id_table[] = { {DRIVER_NAME ,0 }, { },@@ -1128,9 +1127,7 @@ static struct i2c_driver synaptics_rmi4_driver = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, -#ifdef CONFIG_PM Quoted 8 lines
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c static struct i2c_driver synaptics_rmi4_driver = { · line 1133
Quoted 2 lines
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +0
-1.pm = &synaptics_rmi4_dev_pm_ops, -#endif How does this work? I guess that before the pm field could sometimes be null, if power management is not supported. Not the field is not null. Are the fields for the functions now null if there is no power management, or are there just trivial definitions? (It's not a suggestion about changing the patch; I am just wondering).
Yes. I think members of
synaptics_rmi4_dev_pm_opscan be null if there is no power management after this change.As far as I understand, '
SIMPLE_DEV_PM_OPS' macro is defined as follows:#define
SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn)\const struct dev_pm_ops name = { \ SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ }And then '
SET_SYSTEM_SLEEP_PM_OPS' like this:#ifdef
CONFIG_PM_SLEEP#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ .suspend = suspend_fn, \ .resume = resume_fn, \ .freeze = suspend_fn, \ .thaw = resume_fn, \ .poweroff = suspend_fn, \ .restore = resume_fn,#else
#defineSET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)#endifSo, when
CONFIG_PMis not enabled, we can simply remove these guards. And we can write like this:
static const structdev_pm_opssynaptics_rmi4_dev_pm_ops{ };
Quoted 7 lines
However, at first I was unsure about this change. But as this patch is not giving any kind of build error I guess this change should work.
Although this is my understanding. It may possible that I am wrong. Correct me if I am missing something.
Thank You.
Ah, I think I am missing something. May be I can use this macro when there is CONFIG_PM_SLEEP. But the way here CONFIG_PM is used it seems like it should be CONFIG_PM_SLEEP. Though I don't have knowledge about this particular driver. So, it would be good if you can enlighten me on this particular topic.
Thank You.
Quoted 20 lines
Quoted 15 lines
julia
Quoted 13 lines
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +0
-1}, .probe = synaptics_rmi4_probe, .remove = synaptics_rmi4_remove, --1.9.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20150320071750.GA8322%40vaishali-Ideapad-Z570.
For more options, visit https://groups.google.com/d/optout.--
Vaishali
Signature · 1 line
Vaishali
Quoted 41 lines
Quoted 41 lines
Quoted 5 lines
How does this work? I guess that before the pm field could sometimes be null, if power management is not supported. Not the field is not null. Are the fields for the functions now null if there is no power management, or are there just trivial definitions? (It's not a suggestion about changing the patch; I am just wondering).
Yes. I think members of
synaptics_rmi4_dev_pm_opscan be null if there is no power management after this change.As far as I understand, '
SIMPLE_DEV_PM_OPS' macro is defined as follows:#define
SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn)\const struct dev_pm_ops name = { \ SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ }And then '
SET_SYSTEM_SLEEP_PM_OPS' like this:#ifdef
CONFIG_PM_SLEEP#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ .suspend = suspend_fn, \ .resume = resume_fn, \ .freeze = suspend_fn, \ .thaw = resume_fn, \ .poweroff = suspend_fn, \ .restore = resume_fn,#else
#defineSET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)#endifSo, when
CONFIG_PMis not enabled, we can simply remove these guards. And we can write like this:
static const structdev_pm_opssynaptics_rmi4_dev_pm_ops{ };However, at first I was unsure about this change. But as this patch is not giving any kind of build error I guess this change should work.
Although this is my understanding. It may possible that I am wrong. Correct me if I am missing something.
Quoted 7 lines
Quoted 1 line
Thank You.
Ah, I think I am missing something. May be I can use this macro when there is
CONFIG_PM_SLEEP. But the way hereCONFIG_PMis used it seems like it should beCONFIG_PM_SLEEP. Though I don't have knowledge about this particular driver. So, it would be good if you can enlighten me on this particular topic.
Actually, I don't know. There is just the observation that a NULL value is turned into a & value, which cannot be NULL. So one could check on what the driver infrastructure does with a NULL value in the field, and what it now does with a non-NULL value in the field, but a NULL value in each of the substructures.
julia