From patchwork Fri Jan 31 00:54:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Capella X-Patchwork-Id: 23943 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EFAA9202B2 for ; Fri, 31 Jan 2014 00:54:31 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id j5sf8311490qaq.10 for ; Thu, 30 Jan 2014 16:54:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=cxBrh69R6UCKnGtEGU227iGM+Z916ITMZJiHqKWa3lQ=; b=cwIqIK5w+FjfADLWIU+1rr9QYhRZ06CsQFE6KV94lLUGGVsi7h/tcTx5OW+EM5AHk9 BQ7t50BWo02DfYb3Pj8ZenURxeOkdnZNMAndIliBWh3FNUjFhSVWc6CmmbU0O2tQYdXP E4idR/+ioYhXhfJuYd2iNOL9ntqNqFA9HlTz9quMPULerdxxcms/yFo3IJHHtaUTkFYc bv9TaYGAVJl76D4zRoihZ5Zna7/rGdSKUzIr5FdzWP4x18rtbYGUSkK9L2miGlIeGIxm oBf+gtCLMl4OpoZhbduPM9IXAW8oLvj4xr1GXTIY8J5jPVzCQHn9xm6TiuIBHILZY4lq 4Mfw== X-Gm-Message-State: ALoCoQlqKcbuCOs7sngO0tvVrIxLydnHgPL5d0FBQU/+XMdu/BBHwbqtO/QVtp5JXylMX5TEeJ3Q X-Received: by 10.236.36.39 with SMTP id v27mr6348307yha.5.1391129671109; Thu, 30 Jan 2014 16:54:31 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.135 with SMTP id r7ls878835qgr.25.gmail; Thu, 30 Jan 2014 16:54:31 -0800 (PST) X-Received: by 10.220.174.200 with SMTP id u8mr14434439vcz.6.1391129671049; Thu, 30 Jan 2014 16:54:31 -0800 (PST) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id n17si2765804vcq.60.2014.01.30.16.54.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 16:54:30 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.52; Received: by mail-vb0-f52.google.com with SMTP id p14so2459306vbm.25 for ; Thu, 30 Jan 2014 16:54:30 -0800 (PST) X-Received: by 10.52.110.201 with SMTP id ic9mr12074305vdb.22.1391129670783; Thu, 30 Jan 2014 16:54:30 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp57666vcz; Thu, 30 Jan 2014 16:54:30 -0800 (PST) X-Received: by 10.67.22.3 with SMTP id ho3mr10173582pad.128.1391129668591; Thu, 30 Jan 2014 16:54:28 -0800 (PST) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id i8si8386435pav.219.2014.01.30.16.54.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 16:54:28 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of sebastian.capella@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id um1so3832966pbc.33 for ; Thu, 30 Jan 2014 16:54:28 -0800 (PST) X-Received: by 10.68.66.33 with SMTP id c1mr17806398pbt.118.1391129668142; Thu, 30 Jan 2014 16:54:28 -0800 (PST) Received: from localhost (cpe-76-93-135-111.san.res.rr.com. [76.93.135.111]) by mx.google.com with ESMTPSA id e6sm21635868pbg.4.2014.01.30.16.54.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 30 Jan 2014 16:54:27 -0800 (PST) From: Sebastian Capella To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org, patches@linaro.org Cc: Sebastian Capella , Len Brown , "Rafael J. Wysocki" Subject: [PATCH v6 2/2] PM / Hibernate: use name_to_dev_t to parse resume Date: Thu, 30 Jan 2014 16:54:14 -0800 Message-Id: <1391129654-12854-3-git-send-email-sebastian.capella@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391129654-12854-1-git-send-email-sebastian.capella@linaro.org> References: <1391129654-12854-1-git-send-email-sebastian.capella@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sebastian.capella@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use the name_to_dev_t call to parse the device name echo'd to to /sys/power/resume. This imitates the method used in hibernate.c in software_resume, and allows the resume partition to be specified using other equivalent device formats as well. By allowing /sys/debug/resume to accept the same syntax as the resume=device parameter, we can parse the resume=device in the init script and use the resume device directly from the kernel command line. Signed-off-by: Sebastian Capella Acked-by: Pavel Machek Cc: Len Brown Cc: "Rafael J. Wysocki" --- kernel/power/hibernate.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 0121dab..49d7a37 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -972,26 +972,27 @@ static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { - unsigned int maj, min; dev_t res; - int ret = -EINVAL; + char *name = kstrimdup(buf, GFP_KERNEL); - if (sscanf(buf, "%u:%u", &maj, &min) != 2) - goto out; + if (name == NULL) + return -ENOMEM; - res = MKDEV(maj,min); - if (maj != MAJOR(res) || min != MINOR(res)) - goto out; + res = name_to_dev_t(name); - lock_system_sleep(); - swsusp_resume_device = res; - unlock_system_sleep(); - printk(KERN_INFO "PM: Starting manual resume from disk\n"); - noresume = 0; - software_resume(); - ret = n; - out: - return ret; + if (res != 0) { + lock_system_sleep(); + swsusp_resume_device = res; + unlock_system_sleep(); + printk(KERN_INFO "PM: Starting manual resume from disk\n"); + noresume = 0; + software_resume(); + } else { + n = -EINVAL; + } + + kfree(name); + return n; } power_attr(resume);