[RFC v1 1/4] regulator: core: Add regulator devices to bus instead of class
From: Saravana Kannan
Date: Sat Feb 18 2023 - 03:33:07 EST
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@xxxxxxxxxx>
---
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(®ulator_class, NULL, name, regulator_match);
+ dev = bus_find_device(®ulator_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 = ®ulator_class;
+ rdev->dev.bus = ®ulator_bus;
rdev->dev.parent = config->dev;
dev_set_name(&rdev->dev, "regulator.%lu",
(unsigned long) atomic_inc_return(®ulator_no));
@@ -5644,8 +5644,8 @@ regulator_register(struct device *dev,
mutex_unlock(®ulator_list_mutex);
/* try to resolve regulators supply since a new one was registered */
- class_for_each_device(®ulator_class, NULL, NULL,
- regulator_register_resolve_supply);
+ bus_for_each_dev(®ulator_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 = ®ulator_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 == ®ulator_class)
+ if (consumer->dev && consumer->dev->bus == ®ulator_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(®ulator_class, NULL, &summary_data,
- regulator_summary_show_children);
+ bus_for_each_dev(®ulator_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(®ulator_class, NULL, &lock_data,
- regulator_summary_lock_one);
+ ret = bus_for_each_dev(®ulator_bus, NULL, &lock_data,
+ regulator_summary_lock_one);
if (ret)
- class_for_each_device(®ulator_class, NULL, &lock_data,
- regulator_summary_unlock_one);
+ bus_for_each_dev(®ulator_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(®ulator_class, NULL, NULL,
- regulator_summary_unlock_one);
+ bus_for_each_dev(®ulator_bus, NULL, NULL,
+ regulator_summary_unlock_one);
ww_acquire_fini(ww_ctx);
mutex_unlock(®ulator_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(®ulator_class, NULL, s,
- regulator_summary_show_roots);
+ bus_for_each_dev(®ulator_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(®ulator_class);
+ ret = bus_register(®ulator_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(®ulator_class, NULL, NULL,
- regulator_register_resolve_supply);
+ bus_for_each_dev(®ulator_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(®ulator_class, NULL, NULL,
- regulator_late_cleanup);
+ bus_for_each_dev(®ulator_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(®ulator_class, np);
+ dev = bus_find_device_by_of_node(®ulator_bus, np);
return dev ? dev_to_rdev(dev) : NULL;
}
--
2.39.2.637.g21b0678d19-goog