Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754963AbbLGKEU (ORCPT ); Mon, 7 Dec 2015 05:04:20 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:16188 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754193AbbLGKES (ORCPT ); Mon, 7 Dec 2015 05:04:18 -0500 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 07 Dec 2015 01:50:40 -0800 Subject: Re: [PATCH v2 1/5] power: domain: add pm_genpd_exit To: Eric Anholt , "Rafael J. Wysocki" References: <1449251148-19344-1-git-send-email-eric@anholt.net> <1449251148-19344-2-git-send-email-eric@anholt.net> CC: Mark Rutland , , "Ulf Hansson" , Florian Fainelli , Alexander Aring , Pawel Moll , Stephen Warren , Greg Kroah-Hartman , , Lee Jones , , Kevin Hilman , Rob Herring , , Pavel Machek , "Len Brown" , Ian Campbell , From: Jon Hunter Message-ID: <5665599A.4060509@nvidia.com> Date: Mon, 7 Dec 2015 10:04:10 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1449251148-19344-2-git-send-email-eric@anholt.net> X-Originating-IP: [10.21.132.159] X-ClientProxiedBy: UKMAIL102.nvidia.com (10.26.138.15) To UKMAIL101.nvidia.com (10.26.138.13) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2748 Lines: 78 On 04/12/15 17:45, Eric Anholt wrote: > From: Alexander Aring > > This patch adds function pm_genpd_exit for undo a pm_genpd_init. This > is useful for multiple power domains while probing. If the probing fails > after one pm_genpd_init was called we need to undo all previous > registrations of generic pm domains inside the gpd_list list. > > There is a check on IS_ERR_OR_NULL(genpd) which is useful to check again > registered power domains and not registered domains, the driver can use > this mechanism to have an array with registered and non-registered power > domains, where non-registered power domains are NULL. > > Cc: Rafael J. Wysocki > Cc: Kevin Hilman > Cc: Ulf Hansson > Cc: Pavel Machek > Cc: Len Brown > Cc: Greg Kroah-Hartman > Signed-off-by: Alexander Aring > Signed-off-by: Eric Anholt > Acked-by: Ulf Hansson > --- > drivers/base/power/domain.c | 22 ++++++++++++++++++++++ > include/linux/pm_domain.h | 4 ++++ > 2 files changed, 26 insertions(+) > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > index 167418e..e7aca27 100644 > --- a/drivers/base/power/domain.c > +++ b/drivers/base/power/domain.c > @@ -1509,6 +1509,28 @@ void pm_genpd_init(struct generic_pm_domain *genpd, > } > EXPORT_SYMBOL_GPL(pm_genpd_init); > > +/** > + * pm_genpd_exit - Uninitialize a generic I/O PM domain object. > + * @genpd: PM domain object to uninitialize. > + */ > +void pm_genpd_exit(struct generic_pm_domain *genpd) > +{ > + if (IS_ERR_OR_NULL(genpd)) > + return; > + > + /* check if domain is still in registered inside the pm subsystem */ > + WARN_ON_ONCE(!list_empty(&genpd->master_links) || > + !list_empty(&genpd->slave_links) || > + !list_empty(&genpd->dev_list)); > + Why not return an error here? Seems bad to remove it, if it could still be referenced by other domains. Also not sure if you need to lock around the above test and removing the domain. > + mutex_lock(&gpd_list_lock); > + list_del(&genpd->gpd_list_node); > + mutex_unlock(&gpd_list_lock); > + > + mutex_destroy(&genpd->lock); > +} > +EXPORT_SYMBOL_GPL(pm_genpd_exit); > + BTW, I had just submitted a similar patch here [0]. So I would also like to see such an API added. Cheers Jon [0] http://marc.info/?l=devicetree&m=144924138932726&w=2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/