From patchwork Thu Jan 30 21:11:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Capella X-Patchwork-Id: 23936 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8A2D920341 for ; Thu, 30 Jan 2014 21:12:26 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id ar20sf12835263iec.5 for ; Thu, 30 Jan 2014 13:12:25 -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=R1bD2T792ioNxxZv1h9JCErNdTqo8QW+je5K5Kfrq9n3R3Pse9KV/cLwbkAkK7QHBN avbwTq/aH1cuFInTSoD0P/7ivxp2L+C3H7PIzMMrGm0bNrcquASvhJYn9RuTWSkVsNOG 0oO1BxJVACPzflCHBifxEETwjkcOkzcHUOZnXZe1I+BbDBVRUr6qfbpKQaBOPbwmpsXh +GqoegtfqKAKcmw4NOTGkQJl4Kwf9QDvpnQw4QXJgWS9EiXy88HTFf53kkjeaa6VOL2/ bHx4j4/3rO/iXD+ThT0uORGwGd8v5k0ghQJFlh0/4QFiwEQsCiKxuh40BPgswITmJJAA 6FsA== X-Gm-Message-State: ALoCoQmfCU8Rf68YZu2aSZfVKWZu1558cBYEhsoKklCRzdvw4v1oHDHIvZIpBgbLlDYKmScCz63R X-Received: by 10.182.213.5 with SMTP id no5mr6306225obc.15.1391116345842; Thu, 30 Jan 2014 13:12:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.71 with SMTP id k65ls691846qgd.89.gmail; Thu, 30 Jan 2014 13:12:25 -0800 (PST) X-Received: by 10.58.161.227 with SMTP id xv3mr2021256veb.31.1391116345692; Thu, 30 Jan 2014 13:12:25 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id yv5si2539573veb.64.2014.01.30.13.12.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 13:12:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id pa12so2514247veb.5 for ; Thu, 30 Jan 2014 13:12:25 -0800 (PST) X-Received: by 10.52.50.177 with SMTP id d17mr11380249vdo.23.1391116345607; Thu, 30 Jan 2014 13:12:25 -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 u4csp45137vcz; Thu, 30 Jan 2014 13:12:25 -0800 (PST) X-Received: by 10.68.162.66 with SMTP id xy2mr16799951pbb.46.1391116343316; Thu, 30 Jan 2014 13:12:23 -0800 (PST) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by mx.google.com with ESMTPS id m1si7848039pbe.298.2014.01.30.13.12.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 13:12:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.170 is neither permitted nor denied by best guess record for domain of sebastian.capella@linaro.org) client-ip=209.85.192.170; Received: by mail-pd0-f170.google.com with SMTP id p10so3487291pdj.15 for ; Thu, 30 Jan 2014 13:12:22 -0800 (PST) X-Received: by 10.68.229.164 with SMTP id sr4mr16470687pbc.82.1391116342790; Thu, 30 Jan 2014 13:12:22 -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 qq5sm20570162pbb.24.2014.01.30.13.12.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 30 Jan 2014 13:12:21 -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 v5 2/2] PM / Hibernate: use name_to_dev_t to parse resume Date: Thu, 30 Jan 2014 13:11:58 -0800 Message-Id: <1391116318-17253-3-git-send-email-sebastian.capella@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391116318-17253-1-git-send-email-sebastian.capella@linaro.org> References: <1391116318-17253-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.128.174 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);