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: 3555251 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 624B4C02DC for ; Wed, 29 Jan 2014 23:49:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90CC0201B9 for ; Wed, 29 Jan 2014 23:49:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC6302018B for ; Wed, 29 Jan 2014 23:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752720AbaA2Xs7 (ORCPT ); Wed, 29 Jan 2014 18:48:59 -0500 Received: from mail-pb0-f54.google.com ([209.85.160.54]:63988 "EHLO mail-pb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752710AbaA2Xs5 (ORCPT ); Wed, 29 Jan 2014 18:48:57 -0500 Received: by mail-pb0-f54.google.com with SMTP id uo5so2437191pbc.27 for ; Wed, 29 Jan 2014 15:48:57 -0800 (PST) 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=6Pcj/pinjeip7Yu4Z8u29mP9r8KSJX+NAEuXZlPLoaM=; b=D4FjEuK65PO+WXvL9XzBLZGGrG4ZnZgk7kT9zn7ZM10e//dHiYNljkyVXKzW3cOGzl Wlx+fe0Bnyo29IsMXePkXk3ehvect/5ZwZVAh40VCGrPNQF7N4bXg0YCO6gMeXPoIQIU +lhgwllF306auz/SWwKdModVrIlquvLFTxve656aRi+cnTOw/Asz2DEUPUZeJuGnYASX ESDLBUknkO74cWdJZ/nIn+nX5seBuzSnnOoO621AENBMoOq9MhVPs3UvdOQ2gBNWEuwV rZZHLkW/vqsGzeqql1aorD9xMFvdolgYMLtHo2+AaJPnH1hwbVZPiWMQWMYPMAr7jsy8 EuIg== X-Gm-Message-State: ALoCoQnfuojfEv//2QKE/TyDJ6aa+3EuWAfdWbeXati+orT7ZeXGoEin/esd3XWc0O861LSf+S6+ 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> 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.4 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: Pavel Machek Cc: Len Brown Cc: "Rafael J. Wysocki" Acked-by: Pavel Machek --- 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);