From patchwork Wed Apr 26 10:57:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9701107 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 4EC58603F4 for ; Wed, 26 Apr 2017 10:58:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4738C27F90 for ; Wed, 26 Apr 2017 10:58:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C14B28178; Wed, 26 Apr 2017 10:58: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, 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 CDBD627F90 for ; Wed, 26 Apr 2017 10:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2998889AbdDZK6X (ORCPT ); Wed, 26 Apr 2017 06:58:23 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:33561 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2998904AbdDZK5x (ORCPT ); Wed, 26 Apr 2017 06:57:53 -0400 Received: by mail-pg0-f46.google.com with SMTP id 63so42917319pgh.0 for ; Wed, 26 Apr 2017 03:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=RlVYrEmx7ZrG06nsAH/haTkq4F7Jhe6eAZ7lCLVRKvo=; b=G5OJTfXh5ejITGkqekgxKRGSVbnj9d0bFYwAPK57xRO1G2E+U/CXejQkKGzjW0ML0S Qr8V2TIhcXCmGgevJa2LWbTz6YMj5oQutBoMQgWuzRh0oaqa6FJavhUIqY4PVPFiSFbJ LlX71qMp6EVQ7fDP/gDCV3/UGsdEy/7qF66gU= 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:in-reply-to:references; bh=RlVYrEmx7ZrG06nsAH/haTkq4F7Jhe6eAZ7lCLVRKvo=; b=UT2O42kdAT1aVzsecyCFOzcvE71CTfkvz8oG7r+Dc75KDmzCs63RNMZI1dBdyRfxAK rgw+pB/oMkQjrl1s266HKgJMaXxBGxcynBE0zoY8XM7k9L3dBc5R7NpPSnUAHdTvFOuV BM3aZdzviVBDz+d/KtROSmEg+aCU5Ouw+IVW+V32VObxn34oY/HsxXfpvlQJ4idxOFqS t7kba/2QdTtP19aLLueXKb0YnQrqpflFBmqbTncl4xlB8MrH2F0qS1O65dQ7+Erz5RI0 GUtPofkuU/v8UcVGC28nrRiwM9K4BojOiEMpmzZlHecyjzLyJdhb2zBFQYxTo2/iioUz 3Kcg== X-Gm-Message-State: AN3rC/7vUxokA+1jUp8EvW/oVHxnoAb0bTdx5b27XsNmOwa52FdReq5v GVfp0jYBxCE2BHSx X-Received: by 10.84.224.70 with SMTP id a6mr42582242plt.25.1493204270787; Wed, 26 Apr 2017 03:57:50 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id e22sm41954809pgn.11.2017.04.26.03.57.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Apr 2017 03:57:50 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Kevin Hilman , Pavel Machek , Len Brown Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org, sudeep.holla@arm.com, Viresh Kumar Subject: [PATCH V6 8/9] PM / Domain: Add struct device to genpd Date: Wed, 26 Apr 2017 16:27:12 +0530 Message-Id: <695de87a5901febfbd15603fe9de7f32ff513fff.1493203884.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 In-Reply-To: References: In-Reply-To: References: 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 The power-domain core would be using the OPP core going forward and the OPP core has the basic requirement of a device structure for its working. Add a struct device to the genpd structure and also add a genpd bus type for the devices. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 1 + 2 files changed, 38 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7d35dafe8c97..85365611b258 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1546,6 +1546,10 @@ static void genpd_lock_init(struct generic_pm_domain *genpd) } } +static struct bus_type genpd_bus_type = { + .name = "genpd", +}; + /** * pm_genpd_init - Initialize a generic I/O PM domain object. * @genpd: PM domain object to initialize. @@ -1602,6 +1606,18 @@ int pm_genpd_init(struct generic_pm_domain *genpd, return ret; } + genpd->dev.bus = &genpd_bus_type; + device_initialize(&genpd->dev); + dev_set_name(&genpd->dev, "%s", genpd->name); + + ret = device_add(&genpd->dev); + if (ret) { + dev_err(&genpd->dev, "failed to add device: %d\n", ret); + put_device(&genpd->dev); + kfree(genpd->free); + return ret; + } + mutex_lock(&gpd_list_lock); list_add(&genpd->gpd_list_node, &gpd_list); mutex_unlock(&gpd_list_lock); @@ -1639,6 +1655,7 @@ static int genpd_remove(struct generic_pm_domain *genpd) list_del(&genpd->gpd_list_node); genpd_unlock(genpd); + device_del(&genpd->dev); cancel_work_sync(&genpd->power_off_work); kfree(genpd->free); pr_debug("%s: removed %s\n", __func__, genpd->name); @@ -1806,6 +1823,7 @@ int of_genpd_add_provider_simple(struct device_node *np, if (!ret) { genpd->provider = &np->fwnode; genpd->has_provider = true; + genpd->dev.of_node = np; } } @@ -1839,6 +1857,7 @@ int of_genpd_add_provider_onecell(struct device_node *np, data->domains[i]->provider = &np->fwnode; data->domains[i]->has_provider = true; + data->domains[i]->dev.of_node = np; } ret = genpd_add_provider(np, genpd_xlate_onecell, data); @@ -2421,3 +2440,21 @@ static void __exit pm_genpd_debug_exit(void) } __exitcall(pm_genpd_debug_exit); #endif /* CONFIG_DEBUG_FS */ + +static int __init pm_genpd_core_init(void) +{ + int ret; + + ret = bus_register(&genpd_bus_type); + if (ret) + pr_err("bus_register failed (%d)\n", ret); + + return ret; +} +pure_initcall(pm_genpd_core_init); + +static void __exit pm_genpd_core_exit(void) +{ + bus_unregister(&genpd_bus_type); +} +__exitcall(pm_genpd_core_exit); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 84ee474e66d0..c01f12b370d2 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -48,6 +48,7 @@ struct genpd_power_state { struct genpd_lock_ops; struct generic_pm_domain { + struct device dev; struct dev_pm_domain domain; /* PM domain operations */ struct list_head gpd_list_node; /* Node in the global PM domains list */ struct list_head master_links; /* Links with PM domain as a master */