From patchwork Fri Feb 14 22:52:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Capella X-Patchwork-Id: 24667 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 26390202B2 for ; Fri, 14 Feb 2014 22:53:21 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf28317359pbc.4 for ; Fri, 14 Feb 2014 14:53:20 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=hu293be1YUqoStcXTovdH0obvD1K+wVqW/4ypQWaFwM=; b=gYhhfLv0/NGdQenCQUkDi7H1G5gfj73SaXjA1LDCIJP5MpcO5bCpLwxxPCU+jzoGBG I9Tlch0DpKhQCzGU190mumusKboMU24f18wrDs0zwcE3g5laBSpLi0Gh9Sbehlen1ESe KGdJHjUF0GhvXRLhBzcD2P4ayQpV0Qt8KUga3w95nHfFNXbML3hIaNrjlnVzlna8Sn7f WXdeGT4luUg9YBVCHJWBmAW1TlOKZe63HfxOa/CdOr9XysvsqNfJWbh+Bg7o2fFOV4NL xCXL0/tFyfDoCYdT5m68OdMtHIp6avNImGNqeQp+/VLeayNuHPVW8/rmI9lOtjZtZmNQ NDEw== X-Gm-Message-State: ALoCoQl+FmMuv8hiZBPCsuvZdJ7w5VWNMMGi9B6op9iEu9uf4VMFo6JVx6Ae7owRU1xLAQRIPKCo X-Received: by 10.66.189.228 with SMTP id gl4mr4557889pac.26.1392418400173; Fri, 14 Feb 2014 14:53:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.33 with SMTP id 30ls177047qgs.22.gmail; Fri, 14 Feb 2014 14:53:20 -0800 (PST) X-Received: by 10.220.99.72 with SMTP id t8mr7212889vcn.10.1392418400061; Fri, 14 Feb 2014 14:53:20 -0800 (PST) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id dq2si2430222veb.69.2014.02.14.14.53.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Feb 2014 14:53:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id hq11so9815765vcb.14 for ; Fri, 14 Feb 2014 14:53:20 -0800 (PST) X-Received: by 10.52.94.77 with SMTP id da13mr4260vdb.55.1392418399971; Fri, 14 Feb 2014 14:53:19 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp144723vcz; Fri, 14 Feb 2014 14:53:19 -0800 (PST) X-Received: by 10.69.1.2 with SMTP id bc2mr11976971pbd.102.1392418398257; Fri, 14 Feb 2014 14:53:18 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7si7285180pbk.87.2014.02.14.14.53.17; Fri, 14 Feb 2014 14:53:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752829AbaBNWxF (ORCPT + 11 others); Fri, 14 Feb 2014 17:53:05 -0500 Received: from mail-pb0-f51.google.com ([209.85.160.51]:63253 "EHLO mail-pb0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752481AbaBNWxD (ORCPT ); Fri, 14 Feb 2014 17:53:03 -0500 Received: by mail-pb0-f51.google.com with SMTP id un15so12881190pbc.24 for ; Fri, 14 Feb 2014 14:53:02 -0800 (PST) X-Received: by 10.68.190.228 with SMTP id gt4mr12119900pbc.94.1392418382113; Fri, 14 Feb 2014 14:53:02 -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 fk4sm51010522pab.23.2014.02.14.14.53.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 14 Feb 2014 14:53:01 -0800 (PST) From: Sebastian Capella To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org Cc: Sebastian Capella , Len Brown , Pavel Machek , "Rafael J. Wysocki" Subject: [PATCH v9] PM / Hibernate: use name_to_dev_t to parse resume Date: Fri, 14 Feb 2014 14:52:56 -0800 Message-Id: <1392418376-30060-2-git-send-email-sebastian.capella@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392418376-30060-1-git-send-email-sebastian.capella@linaro.org> References: <1392418376-30060-1-git-send-email-sebastian.capella@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.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.220.169 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org 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: Len Brown Cc: Pavel Machek Cc: "Rafael J. Wysocki" --- kernel/power/hibernate.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 0121dab..a5f702a 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -972,16 +972,20 @@ 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; + int len = n; + char *name; - if (sscanf(buf, "%u:%u", &maj, &min) != 2) - goto out; + if (len && buf[len-1] == '\n') + len--; + name = kstrndup(buf, len, GFP_KERNEL); + if (!name) + return -ENOMEM; - res = MKDEV(maj,min); - if (maj != MAJOR(res) || min != MINOR(res)) - goto out; + res = name_to_dev_t(name); + kfree(name); + if (!res) + return -EINVAL; lock_system_sleep(); swsusp_resume_device = res; @@ -989,9 +993,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);