From patchwork Tue Feb 4 20:43:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Capella X-Patchwork-Id: 24146 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B7B24202FA for ; Tue, 4 Feb 2014 20:44:06 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id p5sf22752172vbn.10 for ; Tue, 04 Feb 2014 12:44:05 -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=uNshwtY5RU4WJC5yFIlWLeuDS6pjg2mZyvyGwHv9/xw=; b=QzPSTNHkAGNK0Mcy7yo+QAMoyuVh6xnamPCwR/1EmGCBuc+3USkWkplh6lbJjMRWAY jlJAfBvpzmEnCwezcCL60iDl/U/jUTfnP9Qhcb8JfPfJKniIZMeYeERlp7ASnxZ4rM5g DJd1lT5GangSye3VqhIr9BcT+hqf+wH/BeSmxZnCPm/IN+OzFxCL3bIn+McdK3ulnxW1 iQ2Fy8ITqRLCgFXw2RSTSEefJZI8gsoymslJtlXzhGmSBj6dwhi8HFYbSmrECjvaZvJt q4DVOmlIv920uVKpLKfUTqBkUWEpi6Wr9C9QfqufbJOI1M5gOlRW2eXL82Bzo8vD5bAy IisA== X-Gm-Message-State: ALoCoQkZ3qepGWGio7gL2w5DscZWsu4mNu81bAmLejk3qE3poycLzaLfNBsK9D4oddgLUhxTvlni X-Received: by 10.236.221.168 with SMTP id r38mr711187yhp.54.1391546645523; Tue, 04 Feb 2014 12:44:05 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.203 with SMTP id t69ls2573912qgd.87.gmail; Tue, 04 Feb 2014 12:44:05 -0800 (PST) X-Received: by 10.52.251.232 with SMTP id zn8mr1409616vdc.41.1391546645386; Tue, 04 Feb 2014 12:44:05 -0800 (PST) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id cx4si8721539vcb.5.2014.02.04.12.44.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 12:44:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.41 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.41; Received: by mail-vb0-f41.google.com with SMTP id g10so6355474vbg.28 for ; Tue, 04 Feb 2014 12:44:05 -0800 (PST) X-Received: by 10.220.99.7 with SMTP id s7mr11250076vcn.19.1391546645300; Tue, 04 Feb 2014 12:44:05 -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 u4csp273882vcz; Tue, 4 Feb 2014 12:44:04 -0800 (PST) X-Received: by 10.66.241.73 with SMTP id wg9mr46826163pac.69.1391546643921; Tue, 04 Feb 2014 12:44:03 -0800 (PST) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id bq5si26102007pbb.18.2014.02.04.12.44.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 12:44:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of sebastian.capella@linaro.org) client-ip=209.85.220.50; Received: by mail-pa0-f50.google.com with SMTP id kp14so9013794pab.37 for ; Tue, 04 Feb 2014 12:44:03 -0800 (PST) X-Received: by 10.66.189.100 with SMTP id gh4mr45499574pac.25.1391546643519; Tue, 04 Feb 2014 12:44:03 -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 by1sm69090012pbd.25.2014.02.04.12.44.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 04 Feb 2014 12:44:02 -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 , Pavel Machek , Len Brown , "Rafael J. Wysocki" Subject: [PATCH v7 3/3] PM / Hibernate: use name_to_dev_t to parse resume Date: Tue, 4 Feb 2014 12:43:51 -0800 Message-Id: <1391546631-7715-4-git-send-email-sebastian.capella@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391546631-7715-1-git-send-email-sebastian.capella@linaro.org> References: <1391546631-7715-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.41 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 Cc: 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 cd1e30c..3abd192 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -970,26 +970,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 = kstrdup_trimnl(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(); - pr_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(); + pr_info("PM: Starting manual resume from disk\n"); + noresume = 0; + software_resume(); + } else { + n = -EINVAL; + } + + kfree(name); + return n; } power_attr(resume);