From patchwork Wed Jan 29 23:48:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Capella X-Patchwork-Id: 23913 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7E8ED202FA for ; Wed, 29 Jan 2014 23:48:59 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c10sf9089664igq.2 for ; Wed, 29 Jan 2014 15:48:58 -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=6Pcj/pinjeip7Yu4Z8u29mP9r8KSJX+NAEuXZlPLoaM=; b=H2Zg5uNkEb+3Kq5hbrFXTM7KKgiAF9m+PhGEu/Am5yHWlDCimMfZtXYCWUBVcFy0Kd InLHUdQKEM02OlQyv57nGbnakxgbwUOMpKMQ0KImVqCvh4jjuoGZkCKrJ5R1v3OgUwbP rArwK93VveCilX595SPTCfB0/t5O0yeRGsKRq38gOsjTL7E3kka4Trm3GZ26r94A2vWm XnF73zQNQFrzlEFxM9EK2tkg7rYgs+lXuxLmMtuaOIdY7zyrykGlj4ZwmSI2s4Yfdgbg abcYuByr0wKiil71hf0qD6Y0Q1hc0UYM24q1+CWkAKB40pax0q/NyA9zup6ad5Xna/UJ VOMQ== X-Gm-Message-State: ALoCoQkD8kLmjPBJGZl0pUVATGB/eiJxAFlxPKftF9WZ7NL2hzloRuU2FtzY8v8LKLGjekxu1vD6 X-Received: by 10.182.109.200 with SMTP id hu8mr4230593obb.20.1391039338750; Wed, 29 Jan 2014 15:48:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.142 with SMTP id u14ls349252qga.35.gmail; Wed, 29 Jan 2014 15:48:58 -0800 (PST) X-Received: by 10.52.248.10 with SMTP id yi10mr1844739vdc.39.1391039338598; Wed, 29 Jan 2014 15:48:58 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id yt16si1301286vcb.117.2014.01.29.15.48.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 15:48:58 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so1743654veb.30 for ; Wed, 29 Jan 2014 15:48:58 -0800 (PST) X-Received: by 10.220.147.16 with SMTP id j16mr3121306vcv.28.1391039338524; Wed, 29 Jan 2014 15:48:58 -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 u4csp156740vcz; Wed, 29 Jan 2014 15:48:58 -0800 (PST) X-Received: by 10.66.149.37 with SMTP id tx5mr10847231pab.81.1391039337677; Wed, 29 Jan 2014 15:48:57 -0800 (PST) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by mx.google.com with ESMTPS id r3si4253706pbh.130.2014.01.29.15.48.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 15:48:57 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.47 is neither permitted nor denied by best guess record for domain of sebastian.capella@linaro.org) client-ip=209.85.220.47; Received: by mail-pa0-f47.google.com with SMTP id kp14so2412746pab.20 for ; Wed, 29 Jan 2014 15:48:57 -0800 (PST) X-Received: by 10.68.51.39 with SMTP id h7mr2848385pbo.101.1391039337201; Wed, 29 Jan 2014 15:48:57 -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 de1sm10999829pbc.7.2014.01.29.15.48.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 29 Jan 2014 15:48:56 -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 v4 2/2] PM / Hibernate: use name_to_dev_t to parse resume Date: Wed, 29 Jan 2014 15:48:24 -0800 Message-Id: <1391039304-3172-3-git-send-email-sebastian.capella@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391039304-3172-1-git-send-email-sebastian.capella@linaro.org> References: <1391039304-3172-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.171 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 37170d4..b4a3e0b 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -973,26 +973,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);