aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2006-01-06 03:09:50 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:33:21 -0500
commita576219aca70e6700705a9836e098dbecd25fb56 (patch)
tree1388f5fceb79d42c019443a527b311cf6497e3bd
parent817c41d76e9eaf72044268b0e545a547abadc0bb (diff)
[PATCH] swsusp: resume_store() retval fix
- This function returns -EINVAL all the time. Fix. - Decruftify it a bit too. - Writing to it doesn't seem to do what it's suppoed to do. Cc: Pavel Machek <pavel@ucw.cz> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--kernel/power/disk.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 027322a564f4..4d944b281b28 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -363,30 +363,28 @@ static ssize_t resume_show(struct subsystem * subsys, char *buf)
363 MINOR(swsusp_resume_device)); 363 MINOR(swsusp_resume_device));
364} 364}
365 365
366static ssize_t resume_store(struct subsystem * subsys, const char * buf, size_t n) 366static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n)
367{ 367{
368 int len;
369 char *p;
370 unsigned int maj, min; 368 unsigned int maj, min;
371 int error = -EINVAL;
372 dev_t res; 369 dev_t res;
370 int ret = -EINVAL;
373 371
374 p = memchr(buf, '\n', n); 372 if (sscanf(buf, "%u:%u", &maj, &min) != 2)
375 len = p ? p - buf : n; 373 goto out;
376 374
377 if (sscanf(buf, "%u:%u", &maj, &min) == 2) { 375 res = MKDEV(maj,min);
378 res = MKDEV(maj,min); 376 if (maj != MAJOR(res) || min != MINOR(res))
379 if (maj == MAJOR(res) && min == MINOR(res)) { 377 goto out;
380 down(&pm_sem);
381 swsusp_resume_device = res;
382 up(&pm_sem);
383 printk("Attempting manual resume\n");
384 noresume = 0;
385 software_resume();
386 }
387 }
388 378
389 return error >= 0 ? n : error; 379 down(&pm_sem);
380 swsusp_resume_device = res;
381 up(&pm_sem);
382 printk("Attempting manual resume\n");
383 noresume = 0;
384 software_resume();
385 ret = n;
386out:
387 return ret;
390} 388}
391 389
392power_attr(resume); 390power_attr(resume);