From patchwork Fri Feb 26 15:48:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 8439001 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 507C3C0553 for ; Fri, 26 Feb 2016 15:49:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7223A203B7 for ; Fri, 26 Feb 2016 15:49:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7BA52203AA for ; Fri, 26 Feb 2016 15:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933286AbcBZPtG (ORCPT ); Fri, 26 Feb 2016 10:49:06 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:4782 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932771AbcBZPtF (ORCPT ); Fri, 26 Feb 2016 10:49:05 -0500 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com id ; Fri, 26 Feb 2016 07:49:33 -0800 Received: from hqemhub03.nvidia.com ([172.20.150.15]) by hqnvupgp08.nvidia.com (PGP Universal service); Fri, 26 Feb 2016 07:48:53 -0800 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Fri, 26 Feb 2016 07:48:53 -0800 Received: from jonathanh-lm.nvidia.com (172.20.144.16) by hqemhub03.nvidia.com (172.20.150.15) with Microsoft SMTP Server (TLS) id 8.3.406.0; Fri, 26 Feb 2016 07:49:04 -0800 From: Jon Hunter To: Stephen Warren , Thierry Reding , Alexandre Courbot , "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson CC: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, Jon Hunter Subject: [PATCH V6 03/10] PM / Domains: Add function to remove a pm-domain Date: Fri, 26 Feb 2016 15:48:37 +0000 Message-ID: <1456501724-28477-4-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456501724-28477-1-git-send-email-jonathanh@nvidia.com> References: <1456501724-28477-1-git-send-email-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 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 The genpd framework allows users to add power-domains via the pm_genpd_init() function, however, there is no corresponding function to remove a power-domain. For most devices this may be fine as the power domains are never removed, however, for devices that wish to populate the power-domains from within a driver, having the ability to remove a power domain if the probing of the device fails or the driver is unloaded is necessary. Therefore, add a function to remove a power-domain. Please note that the power domain can only be removed if there are no devices using the power-domain and it is not linked to another domain. Signed-off-by: Jon Hunter Reviewed-by: Thierry Reding --- drivers/base/power/domain.c | 31 +++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 5 +++++ 2 files changed, 36 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 608bc00655ee..22f6e9d738bf 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1557,6 +1557,37 @@ void pm_genpd_init(struct generic_pm_domain *genpd, } EXPORT_SYMBOL_GPL(pm_genpd_init); +/** + * pm_genpd_remove - Remove a generic I/O PM domain object. + * @genpd: PM domain object to remove. + */ +int pm_genpd_remove(struct generic_pm_domain *genpd) +{ + int ret = 0; + + if (IS_ERR_OR_NULL(genpd)) + return -EINVAL; + + mutex_lock(&gpd_list_lock); + mutex_lock(&genpd->lock); + + if (!list_empty(&genpd->master_links) + || !list_empty(&genpd->slave_links) || genpd->device_count) { + ret = -EBUSY; + goto out; + } + + cancel_work_sync(&genpd->power_off_work); + list_del(&genpd->gpd_list_node); + +out: + mutex_unlock(&genpd->lock); + mutex_unlock(&gpd_list_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(pm_genpd_remove); + #ifdef CONFIG_PM_GENERIC_DOMAINS_OF /* * Device Tree based PM domain providers. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index b38dd74dea9b..9ae9c42f807f 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -134,6 +134,7 @@ extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *target); extern void pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); +extern int pm_genpd_remove(struct generic_pm_domain *genpd); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -177,6 +178,10 @@ static inline void pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off) { } +static inline int pm_genpd_remove(struct generic_pm_domain *genpd) +{ + return -ENOTSUPP; +} #endif static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,