From patchwork Wed Sep 18 23:29:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Capella X-Patchwork-Id: 2909771 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6DF5A9F1E1 for ; Wed, 18 Sep 2013 23:30:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F89520412 for ; Wed, 18 Sep 2013 23:30:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5D38203F7 for ; Wed, 18 Sep 2013 23:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752432Ab3IRXah (ORCPT ); Wed, 18 Sep 2013 19:30:37 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:45801 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752435Ab3IRXad (ORCPT ); Wed, 18 Sep 2013 19:30:33 -0400 Received: by mail-pa0-f45.google.com with SMTP id bg4so8889766pad.32 for ; Wed, 18 Sep 2013 16:30:33 -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=Ydt+37CcO7aZDogMh6LrlcxkJrSj8v+YTEuWBs7+yZk=; b=TXLguUG04LmzKUDDIgbyKri8S9QSb91l9D+D0wt19QUYbQG4zWMRuW+XQjcwMo2N53 4emo5ZB5u1wXvAZol58XhpKZEeZ7w+MKlKtbtL+3TM1mmC7eIEM+qFBoUsU1esmg+br3 S/I9gJMT4fQwoSOBIlyUBw08anIb1MNx1PhrL5uy11f8S3ayMVzZjvbhaCWfoojsftQ5 zuT/mp3T2YkgtdSyWzsqRzNk3oCoBkPoBjmNi7D+RZ+WfnL2WS3bcxqOpVBMj13S1IeT cO53JsjTDZqy3SdLEd9zPFOEe4zJqCeenUMxDcA7MhjsfxaHzxAc5VTe5KCOWvxujocS KS/Q== X-Gm-Message-State: ALoCoQkWnk8cXTMqu96WCpXBf7bAUw+uKUkDWTqI6uZJHN2wKERqM/8gVwyOiEolzTNh3lZDZEv0 X-Received: by 10.68.175.67 with SMTP id by3mr8296911pbc.114.1379547033012; Wed, 18 Sep 2013 16:30:33 -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 uw6sm5174847pbc.8.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 18 Sep 2013 16:30:32 -0700 (PDT) From: Sebastian Capella To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org Cc: Sebastian Capella , Len Brown , Pavel Machek , "Rafael J. Wysocki" Subject: [PATCH v3 RFT 2/2] PM / Hibernate: use name_to_dev_t to parse resume Date: Wed, 18 Sep 2013 16:29:02 -0700 Message-Id: <1379546942-22344-3-git-send-email-sebastian.capella@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1379546942-22344-1-git-send-email-sebastian.capella@linaro.org> References: <1379546942-22344-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 Cc: Len Brown Cc: Pavel Machek Cc: "Rafael J. Wysocki" Acked-by: Pavel Machek --- 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 b26f5f1..8b253c2 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -971,16 +971,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; @@ -988,9 +983,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);