PM: Constify returned PM event name
Subsystems (4)
PATCH 1/3 PM: Constify returned PM event name
The pm_verb() returns a pointer to string from .rodata so it should be marked as const.
Signed-off-by Krzysztof Kozlowski <[email protected]>
--- drivers/base/power/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/main.c +1 -1
@@ -62,7 +62,7 @@ static pm_message_t pm_transition;static int async_error; -static char *pm_verb (int event) +static const char *pm_verb (int event) {switch (event) {case PM_EVENT_SUSPEND :
Signature · 1 line
2.9.3
PATCH 2/3 PM: Constify info string used in messages
The 'info' string appearing in many places points to a .rodata string so it should be passes as pointer to const.
Signed-off-by Krzysztof Kozlowski <[email protected]>
--- drivers/base/power/main.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/base/power/main.c +15 -13
@@ -208,7 +208,8 @@ static ktime_t initcall_debug_start(struct device *dev) }static void initcall_debug_report (struct device *dev,ktime_t calltime, -int error,pm_message_t state,char *info) +int error,pm_message_t state, +const char *info) {ktime_t rettime;s64 nsecs;
@@ -403,21 +404,22 @@ static pm_callback_t pm_noirq_op(const struct dev_pm_ops *ops, pm_message_t statreturn NULL ; } -static void pm_dev_dbg (struct device *dev,pm_message_t state,char *info) +static void pm_dev_dbg (struct device *dev,pm_message_t state,const char *info) {dev_dbg (dev,"%s%s%s\n" , info,pm_verb (state.event), ((state.event &PM_EVENT_SLEEP ) &&device_may_wakeup (dev)) ?", may wakeup" :"" ); } -static void pm_dev_err (struct device *dev,pm_message_t state,char *info, +static void pm_dev_err (struct device *dev,pm_message_t state,const char *info,int error) {printk (KERN_ERR "PM: Device %s failed to %s%s: error %d\n" ,dev_name (dev),pm_verb (state.event), info, error); } -static void dpm_show_time (ktime_t starttime,pm_message_t state,char *info) +static void dpm_show_time (ktime_t starttime,pm_message_t state, +const char *info) {ktime_t calltime;u64 usecs64;
@@ -435,7 +437,7 @@ static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info) }static int dpm_run_callback (pm_callback_t cb,struct device *dev, -pm_message_t state,char *info) +pm_message_t state,const char *info) {ktime_t calltime;int error;
@@ -535,7 +537,7 @@ static void dpm_watchdog_clear(struct dpm_watchdog *wd)static int device_resume_noirq (struct device *dev,pm_message_t state,bool async) {pm_callback_t callback =NULL ; -char *info =NULL ; +const char *info =NULL ;int error =0 ;TRACE_DEVICE (dev);
@@ -665,7 +667,7 @@ void dpm_resume_noirq(pm_message_t state)static int device_resume_early (struct device *dev,pm_message_t state,bool async) {pm_callback_t callback =NULL ; -char *info =NULL ; +const char *info =NULL ;int error =0 ;TRACE_DEVICE (dev);
@@ -793,7 +795,7 @@ EXPORT_SYMBOL_GPL(dpm_resume_start);static int device_resume (struct device *dev,pm_message_t state,bool async) {pm_callback_t callback =NULL ; -char *info =NULL ; +const char *info =NULL ;int error =0 ;DECLARE_DPM_WATCHDOG_ON_STACK (wd);
@@ -955,7 +957,7 @@ void dpm_resume(pm_message_t state)static void device_complete (struct device *dev,pm_message_t state) {void (*callback)(struct device *) =NULL ; -char *info =NULL ; +const char *info =NULL ;if (dev->power.syscore)return ;
@@ -1080,7 +1082,7 @@ static pm_message_t resume_event(pm_message_t sleep_state)static int __device_suspend_noirq (struct device *dev,pm_message_t state,bool async) {pm_callback_t callback =NULL ; -char *info =NULL ; +const char *info =NULL ;int error =0 ;TRACE_DEVICE (dev);
@@ -1225,7 +1227,7 @@ int dpm_suspend_noirq(pm_message_t state)static int __device_suspend_late (struct device *dev,pm_message_t state,bool async) {pm_callback_t callback =NULL ; -char *info =NULL ; +const char *info =NULL ;int error =0 ;TRACE_DEVICE (dev);
@@ -1384,7 +1386,7 @@ EXPORT_SYMBOL_GPL(dpm_suspend_end);*/ static int legacy_suspend (struct device *dev,pm_message_t state,int (*cb)(struct device *dev,pm_message_t state), -char *info) +const char *info) {int error;ktime_t calltime;
@@ -1426,7 +1428,7 @@ static void dpm_clear_suppliers_direct_complete(struct device *dev)static int __device_suspend (struct device *dev,pm_message_t state,bool async) {pm_callback_t callback =NULL ; -char *info =NULL ; +const char *info =NULL ;int error =0 ;DECLARE_DPM_WATCHDOG_ON_STACK (wd);
Signature · 1 line
2.9.3
PATCH 3/3 PM / sysfs: Constify attribute groups
In reply to Krzysztof KozlowskiLocal instances of struct attribute_group are not modified so they can be made const to increase code safeness.
Signed-off-by Krzysztof Kozlowski <[email protected]>
--- drivers/base/power/sysfs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/base/power/sysfs.c +6 -6
@@ -607,7 +607,7 @@ static struct attribute *power_attrs[] = {#endif /* CONFIG_PM_ADVANCED_DEBUG */ NULL, }; -static struct attribute_group pm_attr_group = { +static const struct attribute_group pm_attr_group = { .name = power_group_name, .attrs = power_attrs, };
@@ -629,7 +629,7 @@ static struct attribute *wakeup_attrs[] = {#endif NULL, }; -static struct attribute_group pm_wakeup_attr_group = { +static const struct attribute_group pm_wakeup_attr_group = { .name = power_group_name, .attrs = wakeup_attrs, };
@@ -644,7 +644,7 @@ static struct attribute *runtime_attrs[] = { &dev_attr_autosuspend_delay_ms.attr, NULL, }; -static struct attribute_group pm_runtime_attr_group = { +static const struct attribute_group pm_runtime_attr_group = { .name = power_group_name, .attrs = runtime_attrs, };
@@ -653,7 +653,7 @@ static struct attribute *pm_qos_resume_latency_attrs[] = { &dev_attr_pm_qos_resume_latency_us.attr, NULL, }; -static struct attribute_group pm_qos_resume_latency_attr_group = { +static const struct attribute_group pm_qos_resume_latency_attr_group = { .name = power_group_name, .attrs = pm_qos_resume_latency_attrs, };
@@ -662,7 +662,7 @@ static struct attribute *pm_qos_latency_tolerance_attrs[] = { &dev_attr_pm_qos_latency_tolerance_us.attr, NULL, }; -static struct attribute_group pm_qos_latency_tolerance_attr_group = { +static const struct attribute_group pm_qos_latency_tolerance_attr_group = { .name = power_group_name, .attrs = pm_qos_latency_tolerance_attrs, };
@@ -672,7 +672,7 @@ static struct attribute *pm_qos_flags_attrs[] = { &dev_attr_pm_qos_remote_wakeup.attr, NULL, }; -static struct attribute_group pm_qos_flags_attr_group = { +static const struct attribute_group pm_qos_flags_attr_group = { .name = power_group_name, .attrs = pm_qos_flags_attrs, };
Signature · 1 line
2.9.3