From patchwork Fri Feb 14 22:19:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Capella X-Patchwork-Id: 3654861 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 808369F334 for ; Fri, 14 Feb 2014 22:38:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98A32201BB for ; Fri, 14 Feb 2014 22:38:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 766FD20131 for ; Fri, 14 Feb 2014 22:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752850AbaBNWic (ORCPT ); Fri, 14 Feb 2014 17:38:32 -0500 Received: from mail-pb0-f41.google.com ([209.85.160.41]:60063 "EHLO mail-pb0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752282AbaBNWic (ORCPT ); Fri, 14 Feb 2014 17:38:32 -0500 Received: by mail-pb0-f41.google.com with SMTP id up15so12989308pbc.28 for ; Fri, 14 Feb 2014 14:38: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:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vPpL4sjGTnP7A5h+fKzDgVhh5BrRZ/JxckA8ztM8HH8=; b=VgOQ5XIUiY/q0Hdt+yYhcWdP0k7a/O68Ual6BqK5VZaE1g0U3Ksn1JIHSZIQTm8NVb fGr5p5Ut0bf5ZIVYnkI/yxeqaGDQp1cp4qhU1ZE0IC3TJGnoQ/toJPgl4N430zbR1OjK nFTfExbtGe57g3Po/fz3p5HKhA2XmDevDsKXrBadxKqBXkUABA0ZoTg9Mijret689neL RWt3ZrprYSSPoHCerQ6h0xll2ENjzf5/EGF39uNh2uLrybIaAQZiUNF5VuWGDVp7rKsg F51cWC3YiG30a3pjeczIID6EQYP5BilgZbjw9iVU2o6wXwRQp5nD9wIz/ZpJYJ45XFJI ij9g== X-Gm-Message-State: ALoCoQm2IkWE8pnO7TkCbeovMpjdBFcyi1rRletNoxfEhoAkLZybr9Cz66GfJuj9lr5AO2aVOExt X-Received: by 10.69.0.39 with SMTP id av7mr12012708pbd.4.1392417511577; Fri, 14 Feb 2014 14:38:31 -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 ac7sm50750510pad.12.2014.02.14.14.38.29 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 14 Feb 2014 14:38:30 -0800 (PST) From: Sebastian Capella To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org Cc: Sebastian Capella , Len Brown , Pavel Machek , "Rafael J. Wysocki" Subject: [PATCH v9] PM / Hibernate: use name_to_dev_t to parse resume Date: Fri, 14 Feb 2014 14:19:55 -0800 Message-Id: <1392416395-26032-2-git-send-email-sebastian.capella@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392416395-26032-1-git-send-email-sebastian.capella@linaro.org> References: <1392416395-26032-1-git-send-email-sebastian.capella@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Len Brown Cc: Pavel Machek Cc: "Rafael J. Wysocki" --- kernel/power/hibernate.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 0121dab..a5f702a 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -972,16 +972,20 @@ 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; + int len = n; + char *name; - if (sscanf(buf, "%u:%u", &maj, &min) != 2) - goto out; + if (len && buf[len-1] == '\n') + len--; + name = kstrndup(buf, len, GFP_KERNEL); + if (!name) + return -ENOMEM; - res = MKDEV(maj,min); - if (maj != MAJOR(res) || min != MINOR(res)) - goto out; + res = name_to_dev_t(name); + kfree(name); + if (!res) + return -EINVAL; lock_system_sleep(); swsusp_resume_device = res; @@ -989,9 +993,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, printk(KERN_INFO "PM: Starting manual resume from disk\n"); noresume = 0; software_resume(); - ret = n; - out: - return ret; + return n; } power_attr(resume);