Skip to content

Commit 2ce9868

Browse files
spandruvadarafaeljw
authored andcommitted
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>
1 parent bc7115b commit 2ce9868

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

kernel/power/suspend_test.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#define TEST_SUSPEND_SECONDS 10
2323

2424
static unsigned long suspend_test_start_time;
25+
static u32 test_repeat_count_max = 1;
26+
static u32 test_repeat_count_current;
2527

2628
void suspend_test_start(void)
2729
{
@@ -74,6 +76,7 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
7476
int status;
7577

7678
/* this may fail if the RTC hasn't been initialized */
79+
repeat:
7780
status = rtc_read_time(rtc, &alm.time);
7881
if (status < 0) {
7982
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)
111114
if (status < 0)
112115
printk(err_suspend, status);
113116

117+
test_repeat_count_current++;
118+
if (test_repeat_count_current < test_repeat_count_max)
119+
goto repeat;
120+
114121
/* Some platforms can't detect that the alarm triggered the
115122
* wakeup, or (accordingly) disable it after it afterwards.
116123
* It's supposed to give oneshot behavior; cope.
@@ -144,16 +151,28 @@ static char warn_bad_state[] __initdata =
144151
static int __init setup_test_suspend(char *value)
145152
{
146153
int i;
154+
char *repeat;
155+
char *suspend_type;
147156

148-
/* "=mem" ==> "mem" */
157+
/* example : "=mem[,N]" ==> "mem[,N]" */
149158
value++;
159+
suspend_type = strsep(&value, ",");
160+
if (!suspend_type)
161+
return 0;
162+
163+
repeat = strsep(&value, ",");
164+
if (repeat) {
165+
if (kstrtou32(repeat, 0, &test_repeat_count_max))
166+
return 0;
167+
}
168+
150169
for (i = 0; pm_labels[i]; i++)
151-
if (!strcmp(pm_labels[i], value)) {
170+
if (!strcmp(pm_labels[i], suspend_type)) {
152171
test_state_label = pm_labels[i];
153172
return 0;
154173
}
155174

156-
printk(warn_bad_state, value);
175+
printk(warn_bad_state, suspend_type);
157176
return 0;
158177
}
159178
__setup("test_suspend", setup_test_suspend);

0 commit comments

Comments
 (0)