Skip to content

Commit

Permalink
[PATCH] swsusp: resume_store() retval fix
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Jan 6, 2006
1 parent 817c41d commit a576219
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions kernel/power/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,30 +363,28 @@ static ssize_t resume_show(struct subsystem * subsys, char *buf)
MINOR(swsusp_resume_device));
}

static ssize_t resume_store(struct subsystem * subsys, const char * buf, size_t n)
static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n)
{
int len;
char *p;
unsigned int maj, min;
int error = -EINVAL;
dev_t res;
int ret = -EINVAL;

p = memchr(buf, '\n', n);
len = p ? p - buf : n;
if (sscanf(buf, "%u:%u", &maj, &min) != 2)
goto out;

if (sscanf(buf, "%u:%u", &maj, &min) == 2) {
res = MKDEV(maj,min);
if (maj == MAJOR(res) && min == MINOR(res)) {
down(&pm_sem);
swsusp_resume_device = res;
up(&pm_sem);
printk("Attempting manual resume\n");
noresume = 0;
software_resume();
}
}
res = MKDEV(maj,min);
if (maj != MAJOR(res) || min != MINOR(res))
goto out;

return error >= 0 ? n : error;
down(&pm_sem);
swsusp_resume_device = res;
up(&pm_sem);
printk("Attempting manual resume\n");
noresume = 0;
software_resume();
ret = n;
out:
return ret;
}

power_attr(resume);
Expand Down

0 comments on commit a576219

Please sign in to comment.