mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Rafael Wysocki <rjw@rjwysocki.net>,
	ulf.hansson@linaro.org, Kevin Hilman <khilman@linaro.org>,
	Kevin Hilman <khilman@kernel.org>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Stephen Boyd <sboyd@codeaurora.org>, Nishanth Menon <nm@ti.com>,
	robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: [PATCH V4 8/9] PM / Domain: Add struct device to genpd
Date: Mon, 20 Mar 2017 15:02:20 +0530	[thread overview]
Message-ID: <d5a9bf0beebda881d04ee7ffc2b9d94887db65dd.1490001099.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1490001099.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1490001099.git.viresh.kumar@linaro.org>

The power-domain core would be using the OPP core going forward and the
OPP core has a 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.

Note that the of_node field of the device is only set when separate DT
node is present for the power-domain, otherwise the of node is common
across multiple genpd devices and filling the of_node field with it
doesn't sound right.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/base/power/domain.c | 36 ++++++++++++++++++++++++++++++++++++
 include/linux/pm_domain.h   |  1 +
 2 files changed, 37 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 03dd7a61f08a..51d3afc0476d 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1536,6 +1536,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.
@@ -1588,6 +1592,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);
@@ -1625,6 +1641,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);
@@ -1794,6 +1811,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;
 		}
 	}
 
@@ -2407,3 +2425,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 83795935709e..d55c0112dcde 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -47,6 +47,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 */
-- 
2.12.0.432.g71c3a4f4ba37

  parent reply	other threads:[~2017-03-20  9:33 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20  9:32 [PATCH V4 0/9] PM / Domains: Implement domain performance states Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 1/9] PM / OPP: Allow OPP table to be used for power-domains Viresh Kumar
2017-03-24 15:44   ` Rob Herring
2017-04-10  9:25     ` Viresh Kumar
2017-04-10  9:50       ` Viresh Kumar
2017-04-12 16:49   ` Sudeep Holla
2017-04-13  5:37     ` Viresh Kumar
2017-04-13 13:42       ` Sudeep Holla
2017-04-17  5:27         ` Viresh Kumar
2017-04-18 16:01           ` Sudeep Holla
2017-04-19 10:11             ` Viresh Kumar
2017-04-19 11:47             ` Viresh Kumar
2017-04-19 13:58               ` Sudeep Holla
2017-04-20  5:25                 ` Viresh Kumar
2017-04-20  8:23                   ` Ulf Hansson
2017-04-20  9:33                     ` Viresh Kumar
2017-04-20  9:51                     ` Sudeep Holla
2017-04-20  9:43                   ` Sudeep Holla
2017-04-20  9:52                     ` Viresh Kumar
2017-04-23 22:07                       ` Kevin Hilman
2017-04-26  4:32             ` Rajendra Nayak
2017-04-26 13:55               ` Mark Brown
2017-04-27  9:42                 ` Sudeep Holla
2017-04-27 10:50                   ` Rajendra Nayak
2017-04-28  5:00                     ` Viresh Kumar
2017-04-28  9:44                       ` Sudeep Holla
2017-04-28 11:12                         ` Viresh Kumar
2017-04-30 12:49                   ` Mark Brown
2017-05-03 11:21                     ` Sudeep Holla
2017-05-14  9:55                       ` Mark Brown
2017-04-12 17:05   ` Sudeep Holla
2017-04-13  5:50     ` Viresh Kumar
2017-04-13 13:43       ` Sudeep Holla
2017-04-17  5:33         ` Viresh Kumar
2017-04-18 16:03           ` Sudeep Holla
2017-04-19 10:12             ` Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 2/9] PM / Domains: Use OPP tables " Viresh Kumar
2017-04-12 16:58   ` Sudeep Holla
2017-04-13  6:03     ` Viresh Kumar
2017-04-13 13:45       ` Sudeep Holla
2017-03-20  9:32 ` [PATCH V4 3/9] PM / QOS: Keep common notifier list for genpd constraints Viresh Kumar
2017-04-19 14:06   ` Ulf Hansson
2017-04-20  4:45   ` [PATCH V5 " Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 4/9] PM / QOS: Add DEV_PM_QOS_PERFORMANCE request Viresh Kumar
2017-04-19 14:07   ` Ulf Hansson
2017-04-20  4:34     ` Viresh Kumar
2017-04-20  4:46   ` [PATCH V5 " Viresh Kumar
2017-04-20  6:53     ` Ulf Hansson
2017-03-20  9:32 ` [PATCH V4 5/9] PM / OPP: Add support to parse OPP table for power-domains Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 6/9] PM / OPP: Add dev_pm_opp_find_dps() helper Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 7/9] PM / domain: Register for PM QOS performance notifier Viresh Kumar
2017-04-20  4:46   ` [PATCH V5 " Viresh Kumar
2017-03-20  9:32 ` Viresh Kumar [this message]
2017-03-20  9:32 ` [PATCH V4 9/9] PM / Domain: Add support to parse domain's OPP table Viresh Kumar
2017-04-12 14:24 ` [PATCH V4 0/9] PM / Domains: Implement domain performance states Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d5a9bf0beebda881d04ee7ffc2b9d94887db65dd.1490001099.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=khilman@kernel.org \
    --cc=khilman@linaro.org \
    --cc=len.brown@intel.com \
    --cc=lina.iyer@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=rnayak@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®