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: 24666 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 76272202B2 for ; Fri, 14 Feb 2014 22:38:36 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id uq10sf4526983igb.1 for ; Fri, 14 Feb 2014 14:38:35 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=qMxQdtZgSb6QqHqfgKcSfBSWqDpEXXVnhcS0WYaM05I=; b=DUc347LtBL2s4gjoGWFFd1F7db5/Kq75YM/WTXDYltgoOS+w2gqIPwoU6RYpqPERou d8778Q1tQNB9b6vu9jb10eL6O/22d5ZHKRtH7vyMG0YSILNEYQD7GzPra4+gr4vxzpXx pdDzbhKSBkDoFfH9iPUchOfMOBJP5DPfKcK5YxAybCgX3Flp6Qsd0p73d5/kc2Nm4KIQ Aguuevpt+vdZcV6EBGaMWyCNA6Fu017LjP9MKJw+lHpqd47baI+m303hp+5TdjRydMLW tdL6I5mGB9CEley+M6dHuVuBXSTATQtsczNCgUzMt7ErozVFg/+mBKW/qAJEUVUwafDl BJPA== X-Gm-Message-State: ALoCoQkidquIA9h1/hUNP4uze9/NKZ/dhXLe3kueXYwicitVzL2kanqLPk5PLgCu06aI/ewvuRUt X-Received: by 10.43.14.137 with SMTP id pq9mr3881494icb.12.1392417515694; Fri, 14 Feb 2014 14:38:35 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.69 with SMTP id s63ls197209qgd.28.gmail; Fri, 14 Feb 2014 14:38:35 -0800 (PST) X-Received: by 10.52.164.39 with SMTP id yn7mr2644692vdb.25.1392417515571; Fri, 14 Feb 2014 14:38:35 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id y7si2425128vcf.36.2014.02.14.14.38.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Feb 2014 14:38:35 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ik5so9626654vcb.23 for ; Fri, 14 Feb 2014 14:38:35 -0800 (PST) X-Received: by 10.220.147.16 with SMTP id j16mr2888611vcv.28.1392417515468; Fri, 14 Feb 2014 14:38:35 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp143730vcz; Fri, 14 Feb 2014 14:38:34 -0800 (PST) X-Received: by 10.66.66.66 with SMTP id d2mr11877802pat.80.1392417514221; Fri, 14 Feb 2014 14:38:34 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si7267322pbg.33.2014.02.14.14.38.33; Fri, 14 Feb 2014 14:38:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752850AbaBNWic (ORCPT + 11 others); 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-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: list List-ID: X-Mailing-List: linux-pm@vger.kernel.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.220.178 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org 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 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);