PM / sleep: Enhance test_suspend option with repeat capability

Enhanced test_suspend boot paramter to repeat tests multiple times,
by adding optional repeat count. The new boot param syntax:
test_suspend="mem|freeze|standby[,N]"

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Srinivas Pandruvada 2014-09-02 11:54:40 -07:00 committed by Rafael J. Wysocki
parent bc7115b144
commit 2ce986892f
1 changed files with 22 additions and 3 deletions

View File

@ -22,6 +22,8 @@
#define TEST_SUSPEND_SECONDS 10 #define TEST_SUSPEND_SECONDS 10
static unsigned long suspend_test_start_time; static unsigned long suspend_test_start_time;
static u32 test_repeat_count_max = 1;
static u32 test_repeat_count_current;
void suspend_test_start(void) void suspend_test_start(void)
{ {
@ -74,6 +76,7 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
int status; int status;
/* this may fail if the RTC hasn't been initialized */ /* this may fail if the RTC hasn't been initialized */
repeat:
status = rtc_read_time(rtc, &alm.time); status = rtc_read_time(rtc, &alm.time);
if (status < 0) { if (status < 0) {
printk(err_readtime, dev_name(&rtc->dev), status); printk(err_readtime, dev_name(&rtc->dev), status);
@ -111,6 +114,10 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
if (status < 0) if (status < 0)
printk(err_suspend, status); printk(err_suspend, status);
test_repeat_count_current++;
if (test_repeat_count_current < test_repeat_count_max)
goto repeat;
/* Some platforms can't detect that the alarm triggered the /* Some platforms can't detect that the alarm triggered the
* wakeup, or (accordingly) disable it after it afterwards. * wakeup, or (accordingly) disable it after it afterwards.
* It's supposed to give oneshot behavior; cope. * It's supposed to give oneshot behavior; cope.
@ -144,16 +151,28 @@ static char warn_bad_state[] __initdata =
static int __init setup_test_suspend(char *value) static int __init setup_test_suspend(char *value)
{ {
int i; int i;
char *repeat;
char *suspend_type;
/* "=mem" ==> "mem" */ /* example : "=mem[,N]" ==> "mem[,N]" */
value++; value++;
suspend_type = strsep(&value, ",");
if (!suspend_type)
return 0;
repeat = strsep(&value, ",");
if (repeat) {
if (kstrtou32(repeat, 0, &test_repeat_count_max))
return 0;
}
for (i = 0; pm_labels[i]; i++) for (i = 0; pm_labels[i]; i++)
if (!strcmp(pm_labels[i], value)) { if (!strcmp(pm_labels[i], suspend_type)) {
test_state_label = pm_labels[i]; test_state_label = pm_labels[i];
return 0; return 0;
} }
printk(warn_bad_state, value); printk(warn_bad_state, suspend_type);
return 0; return 0;
} }
__setup("test_suspend", setup_test_suspend); __setup("test_suspend", setup_test_suspend);