From patchwork Thu Oct 3 21:10:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Capella X-Patchwork-Id: 2986011 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 59B60BFF0B for ; Thu, 3 Oct 2013 21:11:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 975B1203AE for ; Thu, 3 Oct 2013 21:11:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C50042038B for ; Thu, 3 Oct 2013 21:11:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755648Ab3JCVLK (ORCPT ); Thu, 3 Oct 2013 17:11:10 -0400 Received: from mail-pb0-f51.google.com ([209.85.160.51]:41643 "EHLO mail-pb0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755638Ab3JCVLI (ORCPT ); Thu, 3 Oct 2013 17:11:08 -0400 Received: by mail-pb0-f51.google.com with SMTP id jt11so3002556pbb.38 for ; Thu, 03 Oct 2013 14:11:07 -0700 (PDT) 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=z/vfkxxQDFX3D1s2T352LxLciMW9/grWzdsmf2EaKhY=; b=QKujF96MX3jY9gEL55xM+BszrdS221+pOFF0IB0r2z6Uomk9YwWU6ePT7aVnBFgE55 ocL7ZSdo0S2FNz43ennZhbLTUIdTodJQwhln1fqXx2NifZSSRSQEw+9YtnNo5JFeyTUb Kzsivc81jCYkqrsl+wu2MfnxEOYoGtFGRGfgOymamR46kUg9xWqOpL9fz8cMS4GTD4FZ 1Wnoj18eSRvD2FBEojI2pUrrjfrIY6IcT0WoE8RXz1Bbh5WxkjDq9ZUycWMZFB2a4XZj oc1Y07OJaC6DXbtAnnTsM1/YT2IUJ7GA/wjKxIrD8KmDWVLWxm8B7++ruMHiw1uDw8vj 2iZA== X-Gm-Message-State: ALoCoQmDvaK7Fic524IylVO//EzjxIaPHto4VYvgfllEkiCPdBKRNvhFdifElDBQzAsoGpr8KejL X-Received: by 10.66.145.4 with SMTP id sq4mr4432728pab.178.1380834667460; Thu, 03 Oct 2013 14:11:07 -0700 (PDT) Received: from localhost (rrcs-108-178-170-106.west.biz.rr.com. [108.178.170.106]) by mx.google.com with ESMTPSA id og5sm10267775pbb.10.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 03 Oct 2013 14:11:06 -0700 (PDT) From: Sebastian Capella To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org Cc: Sebastian Capella , Len Brown , "Rafael J. Wysocki" Subject: [PATCH v3 2/2] PM / Hibernate: use name_to_dev_t to parse resume Date: Thu, 3 Oct 2013 14:10:38 -0700 Message-Id: <1380834638-24035-3-git-send-email-sebastian.capella@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1380834638-24035-1-git-send-email-sebastian.capella@linaro.org> References: <1380834638-24035-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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Acked-by: Pavel Machek Cc: Len Brown Cc: "Rafael J. Wysocki" --- kernel/power/hibernate.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index c9c759d..a29d2a7 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -972,16 +972,11 @@ 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; - if (sscanf(buf, "%u:%u", &maj, &min) != 2) - goto out; - - res = MKDEV(maj,min); - if (maj != MAJOR(res) || min != MINOR(res)) - goto out; + res = name_to_dev_t(buf); + if (res == 0) + return -EINVAL; lock_system_sleep(); swsusp_resume_device = res; @@ -989,9 +984,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);