From patchwork Fri Mar 4 11:23:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 8502871 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 17106C0553 for ; Fri, 4 Mar 2016 11:24:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42A1A201C7 for ; Fri, 4 Mar 2016 11:24:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52117201F2 for ; Fri, 4 Mar 2016 11:24:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751066AbcCDLYS (ORCPT ); Fri, 4 Mar 2016 06:24:18 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:9937 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751247AbcCDLYR (ORCPT ); Fri, 4 Mar 2016 06:24:17 -0500 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com id ; Fri, 04 Mar 2016 03:24:49 -0800 Received: from hqemhub02.nvidia.com ([172.20.150.31]) by hqnvupgp07.nvidia.com (PGP Universal service); Fri, 04 Mar 2016 03:23:03 -0800 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Fri, 04 Mar 2016 03:23:03 -0800 Received: from jonathanh-lm.nvidia.com (172.20.144.16) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.406.0; Fri, 4 Mar 2016 03:24:16 -0800 From: Jon Hunter To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson CC: Thierry Reding , Kukjin Kim , Krzysztof Kozlowski , Alexander Aring , Eric Anholt , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, Jon Hunter Subject: [RFC PATCH 6/8] PM / Domains: Remove a provider by referencing the data pointer Date: Fri, 4 Mar 2016 11:23:52 +0000 Message-ID: <1457090634-14785-7-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1457090634-14785-1-git-send-email-jonathanh@nvidia.com> References: <1457090634-14785-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 To remove a PM domain from the system, it is necessary to ensure that any PM domain providers associated with the PM domain have been removed. Otherwise it could be possible to obtain a pointer to a PM domain structure that has been removed. PM domains now have a reference to the pointer for the PM domain provider's data variable. Add a function so that a PM domain can remove a PM domain provider by referencing the data pointer. Signed-off-by: Jon Hunter --- drivers/base/power/domain.c | 24 ++++++++++++++++++++++++ include/linux/pm_domain.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 72055fef6256..438885f2455f 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1738,6 +1738,30 @@ void of_genpd_del_provider(struct device_node *np) EXPORT_SYMBOL_GPL(of_genpd_del_provider); /** + * of_genpd_del_provider_by_data() - Remove a registered PM domain provider + * @data: Pointer to the data associated with the PM domain provider + * + * Look up a PM domain provider based upon a pointer to it's data and + * remove the PM domain provider from the list of providers. + */ +void of_genpd_del_provider_by_data(void *data) +{ + struct of_genpd_provider *c, *cp; + + mutex_lock(&of_genpd_mutex); + list_for_each_entry_safe(cp, c, &of_genpd_providers, link) { + if (cp->data == data) { + list_del(&cp->link); + of_node_put(cp->node); + kfree(cp); + break; + } + } + mutex_unlock(&of_genpd_mutex); +} +EXPORT_SYMBOL_GPL(of_genpd_del_provider_by_data); + +/** * of_genpd_get_from_provider() - Look-up PM domain * @genpdspec: OF phandle args to use for look-up * diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index bed84413546f..7b7921a65cb0 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -199,6 +199,7 @@ int of_genpd_add_provider_simple(struct device_node *np, int of_genpd_add_provider_onecell(struct device_node *np, struct genpd_onecell_data *data); void of_genpd_del_provider(struct device_node *np); +void of_genpd_del_provider_by_data(void *data); struct generic_pm_domain *__of_genpd_xlate_simple( struct of_phandle_args *genpdspec, void *data); @@ -218,6 +219,7 @@ static inline int __of_genpd_add_provider(struct device_node *np, return 0; } static inline void of_genpd_del_provider(struct device_node *np) {} +static inline void of_genpd_del_provider_by_data(void *data) {} #define __of_genpd_xlate_simple NULL #define __of_genpd_xlate_onecell NULL