From patchwork Tue Aug 7 11:47:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 10565 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DB5A123E02 for ; Tue, 7 Aug 2012 11:41:32 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 87D11A181E1 for ; Tue, 7 Aug 2012 11:41:32 +0000 (UTC) Received: by ghbg10 with SMTP id g10so1790259ghb.11 for ; Tue, 07 Aug 2012 04:41:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to :subject:date:user-agent:cc:references:in-reply-to:mime-version :content-type:content-transfer-encoding:message-id:x-virus-scanned :x-gm-message-state; bh=HYt3XiVuStEl/qkLpiqXoqur0jHbVSIWqcJ61Z8Uxus=; b=T6pIWkIAo0N2Jq3UgE9vgRCWduKWIJnkKsg1RWsL1StV6IOzeII1WVRZLUUSPIMZBv 8+bHQsnBFEND3x765zLxwPIGIbIcaYJSazDKBhe+DQ+vHM/3dES5stV92HDtFaBP7iPc cxy2WY/i7lqrdXpmvh8tsruQ8gWNxmDBgZCpFqTQNle6u+7+Tb2YnaTOddbxO507VGOG 22TAeXJG+OBGYTGY5QFnOaomrL9YlVzUVd7T7iSMtahtD+KYovKYogNJNpJvtxETEhkV /Ay8XgfvMZGMpoM0sDa7Rlz+9YqxrPtiuppeVl4EJ0Z3spfNivOXpQgOvnIRO4u1NMKC CzGg== Received: by 10.50.219.194 with SMTP id pq2mr8153078igc.25.1344339691626; Tue, 07 Aug 2012 04:41:31 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.87.40 with SMTP id u8csp493246igz; Tue, 7 Aug 2012 04:41:31 -0700 (PDT) Received: by 10.68.239.103 with SMTP id vr7mr27633513pbc.0.1344339690763; Tue, 07 Aug 2012 04:41:30 -0700 (PDT) Received: from ogre.sisk.pl (ogre.sisk.pl. [193.178.161.156]) by mx.google.com with ESMTP id vx2si16270493pbc.261.2012.08.07.04.41.30; Tue, 07 Aug 2012 04:41:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rjw@sisk.pl designates 193.178.161.156 as permitted sender) client-ip=193.178.161.156; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rjw@sisk.pl designates 193.178.161.156 as permitted sender) smtp.mail=rjw@sisk.pl Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 2ADD01DB95C; Tue, 7 Aug 2012 13:31:22 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07394-07; Tue, 7 Aug 2012 13:31:12 +0200 (CEST) Received: from ferrari.rjw.lan (62-121-64-87.home.aster.pl [62.121.64.87]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 04C091DB92A; Tue, 7 Aug 2012 13:31:12 +0200 (CEST) From: "Rafael J. Wysocki" To: Tushar Behera Subject: Re: [PATCH] PM / Domains: Not return error when dev_pm_get_subsys_data returns 1 Date: Tue, 7 Aug 2012 13:47:22 +0200 User-Agent: KMail/1.13.6 (Linux/3.5.0+; KDE/4.6.0; x86_64; ; ) Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, len.brown@intel.com, pavel@ucw.cz, patches@linaro.org, Heiko =?iso-8859-2?q?St=FCbner?= References: <1344330256-6939-1-git-send-email-tushar.behera@linaro.org> In-Reply-To: <1344330256-6939-1-git-send-email-tushar.behera@linaro.org> MIME-Version: 1.0 Message-Id: <201208071347.22811.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux X-Gm-Message-State: ALoCoQkimZNaowyvQhc9+HTtlslF3QjN+T5vx0MuR69mFhGJqJVxsCVr8LGxWkNGIFLJGs7A7USB On Tuesday, August 07, 2012, Tushar Behera wrote: > Commit 1d5fcfec22 ("PM / Domains: Add device domain data reference > counter") returns error when dev_pm_get_subsys_data() returns a > non-zero value. > > However, dev_pm_get_subsys_data() returns 1 when dev->power.subsys_data > is allocated during this call. Hence we should only check for the error > codes in the return value. > > Without this patch, following errors are encountered while adding > devices to powerdomain on Origen board (based on EXYNOS4210). > > exynos_pm_add_dev_to_genpd: error in adding exynos4-fb.0 device to pd-lcd0 powerdomain > > Signed-off-by: Tushar Behera First of all, this particular problem has been reported already and patches addressing it were queued up for merging later in this cycle. However, your patch below shows that those two patches were incomplete, so I'm going to use the appended one instead. > --- > drivers/base/power/domain.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > index ba3487c..f6802cb 100644 > --- a/drivers/base/power/domain.c > +++ b/drivers/base/power/domain.c > @@ -1323,7 +1323,7 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, > } > > ret = dev_pm_get_subsys_data(dev); > - if (ret) > + if (ret < 0) > goto out; > > genpd->device_count++; > @@ -1358,7 +1358,7 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, > if (gpd_data != gpd_data_new) > __pm_genpd_free_dev_data(dev, gpd_data_new); > > - return ret; > + return (ret < 0) ? : 0; > } > > /** > Thanks, Rafael --- From: Rafael J. Wysocki Subject: PM: Make dev_pm_get_subsys_data() always return 0 on success Commits 1d5fcfec22 (PM / Domains: Add device domain data reference counter) and 62d4490294 (PM / Domains: Allow device callbacks to be added at any time) added checks for the return value of dev_pm_get_subsys_data(), but those checks were incorrect, because that function returned 1 on success in some cases. Since all of the existing users of dev_pm_get_subsys_data() don't use the positive value returned by it on success, change its definition so that it always returns 0 when successful. Reported-by: Heiko Stübner Reported-by: Tushar Behera Signed-off-by: Rafael J. Wysocki --- drivers/base/power/clock_ops.c | 3 +-- drivers/base/power/common.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) Index: linux/drivers/base/power/clock_ops.c =================================================================== --- linux.orig/drivers/base/power/clock_ops.c +++ linux/drivers/base/power/clock_ops.c @@ -171,8 +171,7 @@ void pm_clk_init(struct device *dev) */ int pm_clk_create(struct device *dev) { - int ret = dev_pm_get_subsys_data(dev); - return ret < 0 ? ret : 0; + return dev_pm_get_subsys_data(dev); } /** Index: linux/drivers/base/power/common.c =================================================================== --- linux.orig/drivers/base/power/common.c +++ linux/drivers/base/power/common.c @@ -24,7 +24,6 @@ int dev_pm_get_subsys_data(struct device *dev) { struct pm_subsys_data *psd; - int ret = 0; psd = kzalloc(sizeof(*psd), GFP_KERNEL); if (!psd) @@ -40,7 +39,6 @@ int dev_pm_get_subsys_data(struct device dev->power.subsys_data = psd; pm_clk_init(dev); psd = NULL; - ret = 1; } spin_unlock_irq(&dev->power.lock); @@ -48,7 +46,7 @@ int dev_pm_get_subsys_data(struct device /* kfree() verifies that its argument is nonzero. */ kfree(psd); - return ret; + return 0; } EXPORT_SYMBOL_GPL(dev_pm_get_subsys_data);