SH: cpuidle: remove pointless initialization
Subsystems (2)
PATCH 1/4 SH: cpuidle: remove pointless initialization
The driver is a global static variable automatically initialized to zero.
Removing the useless initialization in the init function.
--- arch/sh/kernel/cpu/shmobile/cpuidle.c | 6 ------ 1 file changed, 6 deletions(-)
arch/sh/kernel/cpu/shmobile/cpuidle.c +0 -6
@@ -64,12 +64,6 @@ void sh_mobile_setup_cpuidle(void)struct cpuidle_state *state;int i; - -for (i =0 ; i <CPUIDLE_STATE_MAX ; i++) { - drv->states[i].name[0 ] ='\0' ; - drv->states[i].desc[0 ] ='\0' ; - } - i =CPUIDLE_DRIVER_STATE_START ; state = &drv->states[i++];
Signature · 1 line
1.7.9.5
PATCH 2/4 SH: cpuidle: remove CPUIDLE_DRIVER_STATE_START usage
From: Daniel Lezcano <[email protected]>
The CPUIDLE_DRIVER_STATE_START constant is only set when the kernel compilation option CONFIG_ARCH_HAS_CPU_RELAX is set, but this is only relatated to x86, so it is always zero.
Remove the reference to this constant in the code.
--- arch/sh/kernel/cpu/shmobile/cpuidle.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/sh/kernel/cpu/shmobile/cpuidle.c +2 -4
@@ -62,9 +62,7 @@ void sh_mobile_setup_cpuidle(void)struct cpuidle_device *dev = &cpuidle_dev;struct cpuidle_driver *drv = &cpuidle_driver;struct cpuidle_state *state; -int i; - - i =CPUIDLE_DRIVER_STATE_START ; +int i =0 ; state = &drv->states[i++];snprintf (state->name,CPUIDLE_NAME_LEN ,"C1" );
@@ -76,7 +74,7 @@ void sh_mobile_setup_cpuidle(void) state->flags |=CPUIDLE_FLAG_TIME_VALID ; state->enter = cpuidle_sleep_enter; - drv->safe_state_index = i-1 ; + drv->safe_state_index =0 ;if (sh_mobile_sleep_supported &SUSP_SH_SF ) { state = &drv->states[i++];
Signature · 1 line
1.7.9.5
PATCH 3/4 SH: cpuidle: initialize the driver's states directly
In reply to Daniel LezcanoLike all the other drivers, let's initialize the structure a compile time instead of init time.
The states #1 and #2 are not enabled by default. The init function will check the features of the board in order to enable the state.
--- arch/sh/kernel/cpu/shmobile/cpuidle.c | 90 +++++++++++++++------------------ 1 file changed, 41 insertions(+), 49 deletions(-)
arch/sh/kernel/cpu/shmobile/cpuidle.c +41 -49
@@ -53,59 +53,51 @@ static int cpuidle_sleep_enter(struct cpuidle_device *dev,static struct cpuidle_device cpuidle_dev;static struct cpuidle_driver cpuidle_driver = { - .name ="sh_idle" , - .owner =THIS_MODULE , + .name ="sh_idle" , + .owner =THIS_MODULE , + .states = { + { + .exit_latency =1 , + .target_residency =1 *2 , + .power_usage =3 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .enter = cpuidle_sleep_enter, + .name ="C1" , + .desc ="SuperH Sleep Mode" , + }, + { + .exit_latency =100 , + .target_residency =1 *2 , + .power_usage =1 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .enter = cpuidle_sleep_enter, + .name ="C2" , + .desc ="SuperH Sleep Mode [SF]" , + .disabled = true, + }, + { + .exit_latency =2300 , + .target_residency =1 *2 , + .power_usage =1 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .enter = cpuidle_sleep_enter, + .name ="C3" , + .desc ="SuperH Mobile Standby Mode [SF]" , + .disabled = true, + }, + }, + .safe_state_index =0 , + .state_count =3 , };void sh_mobile_setup_cpuidle (void ) { -struct cpuidle_device *dev = &cpuidle_dev; -struct cpuidle_driver *drv = &cpuidle_driver; -struct cpuidle_state *state; -int i =0 ; +if (sh_mobile_sleep_supported &SUSP_SH_SF ) + cpuidle_driver.states[1 ].disabled = false; - state = &drv->states[i++]; -snprintf (state->name,CPUIDLE_NAME_LEN ,"C1" ); -strncpy (state->desc,"SuperH Sleep Mode" ,CPUIDLE_DESC_LEN ); - state->exit_latency =1 ; - state->target_residency =1 *2 ; - state->power_usage =3 ; - state->flags =0 ; - state->flags |=CPUIDLE_FLAG_TIME_VALID ; - state->enter = cpuidle_sleep_enter; +if (sh_mobile_sleep_supported &SUSP_SH_STANDBY ) + cpuidle_driver.states[2 ].disabled = false; - drv->safe_state_index =0 ; - -if (sh_mobile_sleep_supported &SUSP_SH_SF ) { - state = &drv->states[i++]; -snprintf (state->name,CPUIDLE_NAME_LEN ,"C2" ); -strncpy (state->desc,"SuperH Sleep Mode [SF]" , -CPUIDLE_DESC_LEN ); - state->exit_latency =100 ; - state->target_residency =1 *2 ; - state->power_usage =1 ; - state->flags =0 ; - state->flags |=CPUIDLE_FLAG_TIME_VALID ; - state->enter = cpuidle_sleep_enter; - } - -if (sh_mobile_sleep_supported &SUSP_SH_STANDBY ) { - state = &drv->states[i++]; -snprintf (state->name,CPUIDLE_NAME_LEN ,"C3" ); -strncpy (state->desc,"SuperH Mobile Standby Mode [SF]" , -CPUIDLE_DESC_LEN ); - state->exit_latency =2300 ; - state->target_residency =1 *2 ; - state->power_usage =1 ; - state->flags =0 ; - state->flags |=CPUIDLE_FLAG_TIME_VALID ; - state->enter = cpuidle_sleep_enter; - } - - drv->state_count = i; - dev->state_count = i; - -cpuidle_register_driver (&cpuidle_driver); - -cpuidle_register_device (dev); +if (!cpuidle_register_driver (&cpuidle_driver)) +cpuidle_register_device (&cpuidle_dev); }
Signature · 1 line
1.7.9.5
PATCH 4/4 SH: cpuidle: check error code at init
In reply to Daniel LezcanoRegistering the driver, or the device, can fail, let's check the return code and return the error code to the PM layer.
--- arch/sh/include/asm/suspend.h | 4 ++-- arch/sh/kernel/cpu/shmobile/cpuidle.c | 11 ++++++++--- arch/sh/kernel/cpu/shmobile/pm.c | 3 +-- 3 files changed, 11 insertions(+), 7 deletions(-)
arch/sh/include/asm/suspend.h +2 -2
@@ -14,9 +14,9 @@ struct swsusp_arch_regs {void sh_mobile_call_standby (unsigned long mode);#ifdef CONFIG_CPU_IDLE -void sh_mobile_setup_cpuidle (void ); +int sh_mobile_setup_cpuidle (void );#else -static inline void sh_mobile_setup_cpuidle (void ) {} +static inline int sh_mobile_setup_cpuidle (void ) {return 0 ; }#endif /* notifier chains for pre/post sleep hooks */
arch/sh/kernel/cpu/shmobile/cpuidle.c +8 -3
@@ -90,14 +90,19 @@ static struct cpuidle_driver cpuidle_driver = { .state_count = 3, }; -void sh_mobile_setup_cpuidle (void ) +int __init sh_mobile_setup_cpuidle (void ) { +int ret; +if (sh_mobile_sleep_supported &SUSP_SH_SF ) cpuidle_driver.states[1 ].disabled = false;if (sh_mobile_sleep_supported &SUSP_SH_STANDBY ) cpuidle_driver.states[2 ].disabled = false; -if (!cpuidle_register_driver (&cpuidle_driver)) -cpuidle_register_device (&cpuidle_dev); + ret =cpuidle_register_driver (&cpuidle_driver); +if (ret) +return ret; + +return cpuidle_register_device (&cpuidle_dev); }
arch/sh/kernel/cpu/shmobile/pm.c +1 -2
@@ -150,8 +150,7 @@ static const struct platform_suspend_ops sh_pm_ops = {static int __init sh_pm_init (void ) {suspend_set_ops (&sh_pm_ops); -sh_mobile_setup_cpuidle (); -return 0 ; +return sh_mobile_setup_cpuidle (); }late_initcall (sh_pm_init);
Signature · 1 line
1.7.9.5
Quoted 5 lines · Daniel Lezcano
The driver is a global static variable automatically initialized to zero.
Removing the useless initialization in the init function.
Signed-off-by Daniel Lezcano <[email protected]>
Hi Daniel,
All four patches in this series seem reasonable to me.
Please let me know if I should take them through my renesas tree.
Quoted 29 lines
--- arch/sh/kernel/cpu/shmobile/cpuidle.c | 6 ------ 1 file changed, 6 deletions(-)arch/sh/kernel/cpu/shmobile/cpuidle.c +0
-6@@ -64,12 +64,6 @@ void sh_mobile_setup_cpuidle(void)struct cpuidle_state *state;int i; - -for (i =0 ; i <CPUIDLE_STATE_MAX ; i++) { - drv->states[i].name[0 ] ='\0' ; - drv->states[i].desc[0 ] ='\0' ; - } - i =CPUIDLE_DRIVER_STATE_START ; state = &drv->states[i++];Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Simon Horman
Quoted 5 lines · Daniel Lezcano
The driver is a global static variable automatically initialized to zero.
Removing the useless initialization in the init function.
Signed-off-by Daniel Lezcano <[email protected]>
Quoted 7 lines
Hi Daniel,
All four patches in this series seem reasonable to me.
Acked-by Simon Horman <[email protected]>Please let me know if I should take them through my renesas tree.
If you are ok with that, is it possible to take them through the linux-pm tree ? So the cpuidle drivers are synced and I can continue the code consolidation ?
Thanks for the review.
-- Daniel
Quoted 5 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 12 lines · Daniel Lezcano
Quoted 11 lines · Simon Horman
Quoted 5 lines · Daniel Lezcano
The driver is a global static variable automatically initialized to zero.
Removing the useless initialization in the init function.
Signed-off-by Daniel Lezcano <[email protected]>Hi Daniel,
All four patches in this series seem reasonable to me.
Quoted 7 lines
Quoted 3 lines
Acked-by Simon Horman <[email protected]>Please let me know if I should take them through my renesas tree.
If you are ok with that, is it possible to take them through the linux-pm tree ? So the cpuidle drivers are synced and I can continue the code consolidation ?
Yes, I am ok with them going through the linux-pm tree.
Quoted 15 lines · Simon Horman
Quoted 14 lines · Daniel Lezcano
Quoted 13 lines · Simon Horman
Quoted 5 lines · Daniel Lezcano
The driver is a global static variable automatically initialized to zero.
Removing the useless initialization in the init function.
Signed-off-by Daniel Lezcano <[email protected]>Hi Daniel,
All four patches in this series seem reasonable to me.
Acked-by Simon Horman <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Please let me know if I should take them through my renesas tree.
If you are ok with that, is it possible to take them through the linux-pm tree ? So the cpuidle drivers are synced and I can continue the code consolidation ?
Yes, I am ok with them going through the linux-pm tree.
Thanks !
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 18 lines · Daniel Lezcano
Quoted 17 lines · Simon Horman
Quoted 16 lines · Daniel Lezcano
Quoted 14 lines · Simon Horman
Quoted 5 lines · Daniel Lezcano
The driver is a global static variable automatically initialized to zero.
Removing the useless initialization in the init function.
Signed-off-by Daniel Lezcano <[email protected]>Hi Daniel,
All four patches in this series seem reasonable to me.
Acked-by Simon Horman <[email protected]>Please let me know if I should take them through my renesas tree.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
If you are ok with that, is it possible to take them through the linux-pm tree ? So the cpuidle drivers are synced and I can continue the code consolidation ?
Yes, I am ok with them going through the linux-pm tree.
Thanks !
OK, applied.
Patch [3/4] had a merge conflict against the current Linus' tree, so I've fixed it up manually. Please check the linux-next branch for the result (will probably conflict with the shmobile tree in linux-next, but that's not a big deal).
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.