public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Saravana Kannan <saravanak@google.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: Saravana Kannan <saravanak@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Bjorn Andersson <andersson@kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Tony Lindgren <tony@atomide.com>,
	Doug Anderson <dianders@chromium.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Luca Weiss <luca.weiss@fairphone.com>,
	kernel-team@android.com, linux-kernel@vger.kernel.org
Subject: [RFC v1 1/4] regulator: core: Add regulator devices to bus instead of class
Date: Sat, 18 Feb 2023 00:32:48 -0800	[thread overview]
Message-ID: <20230218083252.2044423-2-saravanak@google.com> (raw)
In-Reply-To: <20230218083252.2044423-1-saravanak@google.com>

Add regulator devices to a bus instead of a class. This allows us to
probe these devices in later patches.

Signed-off-by: Saravana Kannan <saravanak@google.com>
---
 drivers/regulator/core.c         | 45 ++++++++++++++++----------------
 drivers/regulator/internal.h     |  2 +-
 drivers/regulator/of_regulator.c |  2 +-
 3 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ae69e493913d..1a212edcf216 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1918,7 +1918,7 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name)
 {
 	struct device *dev;
 
-	dev = class_find_device(&regulator_class, NULL, name, regulator_match);
+	dev = bus_find_device(&regulator_bus, NULL, name, regulator_match);
 
 	return dev ? dev_to_rdev(dev) : NULL;
 }
@@ -5539,7 +5539,7 @@ regulator_register(struct device *dev,
 		rdev->supply_name = regulator_desc->supply_name;
 
 	/* register with sysfs */
-	rdev->dev.class = &regulator_class;
+	rdev->dev.bus = &regulator_bus;
 	rdev->dev.parent = config->dev;
 	dev_set_name(&rdev->dev, "regulator.%lu",
 		    (unsigned long) atomic_inc_return(&regulator_no));
@@ -5644,8 +5644,8 @@ regulator_register(struct device *dev,
 	mutex_unlock(&regulator_list_mutex);
 
 	/* try to resolve regulators supply since a new one was registered */
-	class_for_each_device(&regulator_class, NULL, NULL,
-			      regulator_register_resolve_supply);
+	bus_for_each_dev(&regulator_bus, NULL, NULL,
+			 regulator_register_resolve_supply);
 	kfree(config);
 	return rdev;
 
@@ -5772,14 +5772,15 @@ static const struct dev_pm_ops __maybe_unused regulator_pm_ops = {
 };
 #endif
 
-struct class regulator_class = {
+struct bus_type regulator_bus = {
 	.name = "regulator",
-	.dev_release = regulator_dev_release,
+	.remove = regulator_dev_release,
 	.dev_groups = regulator_dev_groups,
 #ifdef CONFIG_PM
 	.pm = &regulator_pm_ops,
 #endif
 };
+
 /**
  * regulator_has_full_constraints - the system has fully specified constraints
  *
@@ -5939,7 +5940,7 @@ static void regulator_summary_show_subtree(struct seq_file *s,
 	seq_puts(s, "\n");
 
 	list_for_each_entry(consumer, &rdev->consumer_list, list) {
-		if (consumer->dev && consumer->dev->class == &regulator_class)
+		if (consumer->dev && consumer->dev->bus == &regulator_bus)
 			continue;
 
 		seq_printf(s, "%*s%-*s ",
@@ -5969,8 +5970,8 @@ static void regulator_summary_show_subtree(struct seq_file *s,
 	summary_data.level = level;
 	summary_data.parent = rdev;
 
-	class_for_each_device(&regulator_class, NULL, &summary_data,
-			      regulator_summary_show_children);
+	bus_for_each_dev(&regulator_bus, NULL, &summary_data,
+			 regulator_summary_show_children);
 }
 
 struct summary_lock_data {
@@ -6025,11 +6026,11 @@ static int regulator_summary_lock_all(struct ww_acquire_ctx *ww_ctx,
 	lock_data.new_contended_rdev = new_contended_rdev;
 	lock_data.old_contended_rdev = old_contended_rdev;
 
-	ret = class_for_each_device(&regulator_class, NULL, &lock_data,
-				    regulator_summary_lock_one);
+	ret = bus_for_each_dev(&regulator_bus, NULL, &lock_data,
+			       regulator_summary_lock_one);
 	if (ret)
-		class_for_each_device(&regulator_class, NULL, &lock_data,
-				      regulator_summary_unlock_one);
+		bus_for_each_dev(&regulator_bus, NULL, &lock_data,
+				 regulator_summary_unlock_one);
 
 	return ret;
 }
@@ -6065,8 +6066,8 @@ static void regulator_summary_lock(struct ww_acquire_ctx *ww_ctx)
 
 static void regulator_summary_unlock(struct ww_acquire_ctx *ww_ctx)
 {
-	class_for_each_device(&regulator_class, NULL, NULL,
-			      regulator_summary_unlock_one);
+	bus_for_each_dev(&regulator_bus, NULL, NULL,
+			 regulator_summary_unlock_one);
 	ww_acquire_fini(ww_ctx);
 
 	mutex_unlock(&regulator_list_mutex);
@@ -6092,8 +6093,8 @@ static int regulator_summary_show(struct seq_file *s, void *data)
 
 	regulator_summary_lock(&ww_ctx);
 
-	class_for_each_device(&regulator_class, NULL, s,
-			      regulator_summary_show_roots);
+	bus_for_each_dev(&regulator_bus, NULL, s,
+			 regulator_summary_show_roots);
 
 	regulator_summary_unlock(&ww_ctx);
 
@@ -6106,7 +6107,7 @@ static int __init regulator_init(void)
 {
 	int ret;
 
-	ret = class_register(&regulator_class);
+	ret = bus_register(&regulator_bus);
 
 	debugfs_root = debugfs_create_dir("regulator", NULL);
 	if (!debugfs_root)
@@ -6182,16 +6183,16 @@ static void regulator_init_complete_work_function(struct work_struct *work)
 	 * bound yet. So attempt to resolve the input supplies for
 	 * pending regulators before trying to disable unused ones.
 	 */
-	class_for_each_device(&regulator_class, NULL, NULL,
-			      regulator_register_resolve_supply);
+	bus_for_each_dev(&regulator_bus, NULL, NULL,
+			 regulator_register_resolve_supply);
 
 	/* If we have a full configuration then disable any regulators
 	 * we have permission to change the status for and which are
 	 * not in use or always_on.  This is effectively the default
 	 * for DT and ACPI as they have full constraints.
 	 */
-	class_for_each_device(&regulator_class, NULL, NULL,
-			      regulator_late_cleanup);
+	bus_for_each_dev(&regulator_bus, NULL, NULL,
+			 regulator_late_cleanup);
 }
 
 static DECLARE_DELAYED_WORK(regulator_init_complete_work,
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h
index fb4433068d29..6e489b3cffad 100644
--- a/drivers/regulator/internal.h
+++ b/drivers/regulator/internal.h
@@ -58,7 +58,7 @@ struct regulator {
 	struct dentry *debugfs;
 };
 
-extern struct class regulator_class;
+extern struct bus_type regulator_bus;
 
 static inline struct regulator_dev *dev_to_rdev(struct device *dev)
 {
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 1b65e5e4e40f..f0590e68f31d 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -545,7 +545,7 @@ struct regulator_dev *of_find_regulator_by_node(struct device_node *np)
 {
 	struct device *dev;
 
-	dev = class_find_device_by_of_node(&regulator_class, np);
+	dev = bus_find_device_by_of_node(&regulator_bus, np);
 
 	return dev ? dev_to_rdev(dev) : NULL;
 }
-- 
2.39.2.637.g21b0678d19-goog


  reply	other threads:[~2023-02-18  8:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230218083300eucas1p28c7c584877b8914a3b88904690be82f6@eucas1p2.samsung.com>
2023-02-18  8:32 ` [RFC v1 0/4] Simplify regulator supply resolution code by offloading to driver core Saravana Kannan
2023-02-18  8:32   ` Saravana Kannan [this message]
2023-02-18  8:32   ` [RFC v1 2/4] regulator: core: Add sysfs class backward compatibility Saravana Kannan
2023-02-22 17:47     ` Mark Brown
2023-02-18  8:32   ` [RFC v1 3/4] regulator: core: Probe regulator devices Saravana Kannan
2023-02-22 17:50     ` Mark Brown
2023-02-18  8:32   ` [RFC v1 4/4] regulator: core: Move regulator supply resolving to the probe function Saravana Kannan
2023-02-22 22:51     ` Mark Brown
2023-02-18  8:36   ` [RFC v1 0/4] Simplify regulator supply resolution code by offloading to driver core Saravana Kannan
2023-02-18  8:54   ` Greg Kroah-Hartman
2023-02-20  9:01   ` Marek Szyprowski
2023-02-21 22:36     ` Saravana Kannan
2023-02-21 22:52       ` Mark Brown
2023-02-22  3:13         ` Saravana Kannan
2023-02-22 14:54           ` Mark Brown
2023-02-22  7:15       ` Marek Szyprowski

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=20230218083252.2044423-2-saravanak@google.com \
    --to=saravanak@google.com \
    --cc=andersson@kernel.org \
    --cc=broonie@kernel.org \
    --cc=dianders@chromium.org \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@android.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=luca.weiss@fairphone.com \
    --cc=m.szyprowski@samsung.com \
    --cc=sudeep.holla@arm.com \
    --cc=tony@atomide.com \
    /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