@@ -319,25 +319,17 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
319319power_attr (pm_test );
320320#endif /* CONFIG_PM_SLEEP_DEBUG */
321321
322- static char * suspend_step_name (enum suspend_stat_step step )
323- {
324- switch (step ) {
325- case SUSPEND_FREEZE :
326- return "freeze" ;
327- case SUSPEND_PREPARE :
328- return "prepare" ;
329- case SUSPEND_SUSPEND :
330- return "suspend" ;
331- case SUSPEND_SUSPEND_NOIRQ :
332- return "suspend_noirq" ;
333- case SUSPEND_RESUME_NOIRQ :
334- return "resume_noirq" ;
335- case SUSPEND_RESUME :
336- return "resume" ;
337- default :
338- return "" ;
339- }
340- }
322+ static const char * const suspend_step_names [] = {
323+ [SUSPEND_WORKING ] = "" ,
324+ [SUSPEND_FREEZE ] = "freeze" ,
325+ [SUSPEND_PREPARE ] = "prepare" ,
326+ [SUSPEND_SUSPEND ] = "suspend" ,
327+ [SUSPEND_SUSPEND_LATE ] = "suspend_late" ,
328+ [SUSPEND_SUSPEND_NOIRQ ] = "suspend_noirq" ,
329+ [SUSPEND_RESUME_NOIRQ ] = "resume_noirq" ,
330+ [SUSPEND_RESUME_EARLY ] = "resume_early" ,
331+ [SUSPEND_RESUME ] = "resume" ,
332+ };
341333
342334#define suspend_attr (_name , format_str ) \
343335static ssize_t _name##_show(struct kobject *kobj, \
@@ -392,16 +384,14 @@ static struct kobj_attribute last_failed_errno = __ATTR_RO(last_failed_errno);
392384static ssize_t last_failed_step_show (struct kobject * kobj ,
393385 struct kobj_attribute * attr , char * buf )
394386{
395- int index ;
396387 enum suspend_stat_step step ;
397- char * last_failed_step = NULL ;
388+ int index ;
398389
399390 index = suspend_stats .last_failed_step + REC_FAILED_NUM - 1 ;
400391 index %= REC_FAILED_NUM ;
401392 step = suspend_stats .failed_steps [index ];
402- last_failed_step = suspend_step_name (step );
403393
404- return sprintf (buf , "%s\n" , last_failed_step );
394+ return sprintf (buf , "%s\n" , suspend_step_names [ step ] );
405395}
406396static struct kobj_attribute last_failed_step = __ATTR_RO (last_failed_step );
407397
@@ -473,30 +463,26 @@ static int suspend_stats_show(struct seq_file *s, void *unused)
473463 "failed_resume_noirq" ,
474464 suspend_stats .failed_resume_noirq );
475465 seq_printf (s , "failures:\n last_failed_dev:\t%-s\n" ,
476- suspend_stats .failed_devs [last_dev ]);
466+ suspend_stats .failed_devs [last_dev ]);
477467 for (i = 1 ; i < REC_FAILED_NUM ; i ++ ) {
478468 index = last_dev + REC_FAILED_NUM - i ;
479469 index %= REC_FAILED_NUM ;
480- seq_printf (s , "\t\t\t%-s\n" ,
481- suspend_stats .failed_devs [index ]);
470+ seq_printf (s , "\t\t\t%-s\n" , suspend_stats .failed_devs [index ]);
482471 }
483472 seq_printf (s , " last_failed_errno:\t%-d\n" ,
484473 suspend_stats .errno [last_errno ]);
485474 for (i = 1 ; i < REC_FAILED_NUM ; i ++ ) {
486475 index = last_errno + REC_FAILED_NUM - i ;
487476 index %= REC_FAILED_NUM ;
488- seq_printf (s , "\t\t\t%-d\n" ,
489- suspend_stats .errno [index ]);
477+ seq_printf (s , "\t\t\t%-d\n" , suspend_stats .errno [index ]);
490478 }
491479 seq_printf (s , " last_failed_step:\t%-s\n" ,
492- suspend_step_name (
493- suspend_stats .failed_steps [last_step ]));
480+ suspend_step_names [suspend_stats .failed_steps [last_step ]]);
494481 for (i = 1 ; i < REC_FAILED_NUM ; i ++ ) {
495482 index = last_step + REC_FAILED_NUM - i ;
496483 index %= REC_FAILED_NUM ;
497484 seq_printf (s , "\t\t\t%-s\n" ,
498- suspend_step_name (
499- suspend_stats .failed_steps [index ]));
485+ suspend_step_names [suspend_stats .failed_steps [index ]]);
500486 }
501487
502488 return 0 ;
0 commit comments