From patchwork Tue Mar 14 19:15:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9624369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D275260244 for ; Tue, 14 Mar 2017 19:15:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C453B284BA for ; Tue, 14 Mar 2017 19:15:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B89F52858D; Tue, 14 Mar 2017 19:15:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47312284BA for ; Tue, 14 Mar 2017 19:15:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752506AbdCNTPY (ORCPT ); Tue, 14 Mar 2017 15:15:24 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36219 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752478AbdCNTPV (ORCPT ); Tue, 14 Mar 2017 15:15:21 -0400 Received: by mail-wr0-f193.google.com with SMTP id l37so25017883wrc.3; Tue, 14 Mar 2017 12:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WEDFIrbYHNGtPEYK9hooAz9XSIrOGeezL6OcYOGZkk8=; b=bROSDER2SbV9yA+eeW/q/rLPJhmmiBFBptqhWxlmYLW1n7nFmH3qe70R2AwOfZiuwQ vgadjEHB6l4z83kQkynPk7Mmr3FicXEXHCa1yBnfqvedGzuACTS0CuUtsO0LK3NvkteN /wUKht+pYfYUY3FQmMZ0NKl4Heuw6IO33qswsu5naVs0qjV/+2ICNXCHT4dNcWxyDeHy mDGMueEk4XY7P/3omSUsyv/r3UH0NSdPZ8GrNT8lIjiBP9E4dDTGtjpWAdzC/GTVzvzJ W3Y873viT9N2bY5sCKnx5mWNfNpa8WZ6RaXV+wBb1DE6bKf+hHtQluusoxsX+B/Qhbjh 8U+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WEDFIrbYHNGtPEYK9hooAz9XSIrOGeezL6OcYOGZkk8=; b=aC2gsn+MVvryKPDY7MULQmfXgrB8YLQSGSVHTLk8NBz1npBv/Nj8lNG7xgE38yrhzO YqagSV5TPao0h244CG7fHFeR9jFDyL4jwUng+T1oaBWiWoUM78oVon3gb7JulqPP3nLc Vqy7xC5lfv9UiLMxFPT94HQg5F13cLUnoprMj7WqH0LWrADLeYm7TgXzBa+NC6J+BS7W JcpqeOWjc0DAy2Oa3HhhVChcLlYUiRl3F0tJoczrbj38FPfnPe4ummJTO4cy9tSkP/ba JpEa/9nmWjCzQ95w56Z5fl6YwZQCORxc8LAPKFkU4fLdPfMeyeWHOfpedGdhqlWbNEcX RJMA== X-Gm-Message-State: AMke39lUxclV457zSDXyer6nNk9JsY9Zf+2GtP5+iXGRb3ZKLvCsYUO+ZjnD9O1/nsDXqA== X-Received: by 10.223.179.15 with SMTP id j15mr38483553wrd.62.1489518919666; Tue, 14 Mar 2017 12:15:19 -0700 (PDT) Received: from localhost (port-7480.pppoe.wtnet.de. [84.46.29.85]) by smtp.gmail.com with ESMTPSA id z88sm30363353wrb.26.2017.03.14.12.15.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Mar 2017 12:15:18 -0700 (PDT) From: Thierry Reding To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson Cc: Jonathan Hunter , Stefan Kristiansson , Mikko Perttunen , linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 1/3] PM / Domains: Allow overriding the ->xlate() callback Date: Tue, 14 Mar 2017 20:15:14 +0100 Message-Id: <20170314191516.13083-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170314191516.13083-1-thierry.reding@gmail.com> References: <20170314191516.13083-1-thierry.reding@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Allow generic power domain providers to override the ->xlate() callback in case the default genpd_xlate_onecell() translation callback is not good enough. One potential use-case for this is to allow generic power domains to be specified by an ID rather than an index. Signed-off-by: Thierry Reding --- drivers/base/power/domain.c | 8 ++++---- include/linux/pm_domain.h | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e697dec9d25b..c102557f6c7e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1570,9 +1570,6 @@ EXPORT_SYMBOL_GPL(pm_genpd_remove); #ifdef CONFIG_PM_GENERIC_DOMAINS_OF -typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args, - void *data); - /* * Device Tree based PM domain providers. * @@ -1730,6 +1727,9 @@ int of_genpd_add_provider_onecell(struct device_node *np, mutex_lock(&gpd_list_lock); + if (!data->xlate) + data->xlate = genpd_xlate_onecell; + for (i = 0; i < data->num_domains; i++) { if (!data->domains[i]) continue; @@ -1740,7 +1740,7 @@ int of_genpd_add_provider_onecell(struct device_node *np, data->domains[i]->has_provider = true; } - ret = genpd_add_provider(np, genpd_xlate_onecell, data); + ret = genpd_add_provider(np, data->xlate, data); if (ret < 0) goto error; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 5339ed5bd6f9..5163f371a308 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -204,9 +204,13 @@ static inline void pm_genpd_syscore_poweron(struct device *dev) {} /* OF PM domain providers */ struct of_device_id; +typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args, + void *data); + struct genpd_onecell_data { struct generic_pm_domain **domains; unsigned int num_domains; + genpd_xlate_t xlate; }; #ifdef CONFIG_PM_GENERIC_DOMAINS_OF