[RFC,v1,3/4] regulator: core: Probe regulator devices

Message ID 20230218083252.2044423-4-saravanak@google.com
State New
Headers
Series Simplify regulator supply resolution code by offloading to driver core |

Commit Message

Saravana Kannan Feb. 18, 2023, 8:32 a.m. UTC
  Since devices added to a bus can be probed, add a stub probe function
for regulator devices.

Signed-off-by: Saravana Kannan <saravanak@google.com>
---
 drivers/regulator/core.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
  

Comments

Mark Brown Feb. 22, 2023, 5:50 p.m. UTC | #1
On Sat, Feb 18, 2023 at 12:32:50AM -0800, Saravana Kannan wrote:
> Since devices added to a bus can be probed, add a stub probe function
> for regulator devices.

Why?

> +static int regulator_drv_probe(struct device *dev)
> +{
> +	return 0;
> +}

This is just an empty function - why do we need it?  Looking at
call_driver_probe() it doesn't appear to be required.
  

Patch

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b6700d50d230..d5f9fdd79c14 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5780,6 +5780,17 @@  static const struct dev_pm_ops __maybe_unused regulator_pm_ops = {
 };
 #endif
 
+static int regulator_drv_probe(struct device *dev)
+{
+	return 0;
+}
+
+static struct device_driver regulator_drv = {
+	.name = "regulator_drv",
+	.bus = &regulator_bus,
+	.probe = regulator_drv_probe,
+};
+
 struct bus_type regulator_bus = {
 	.name = "regulator",
 	.remove = regulator_dev_release,
@@ -6123,6 +6134,10 @@  static int __init regulator_init(void)
 	if (ret)
 		goto unreg_compat;
 
+	ret = driver_register(&regulator_drv);
+	if (ret)
+		goto unreg_bus;
+
 	debugfs_root = debugfs_create_dir("regulator", NULL);
 	if (!debugfs_root)
 		pr_warn("regulator: Failed to create debugfs directory\n");
@@ -6141,6 +6156,8 @@  static int __init regulator_init(void)
 
 	return ret;
 
+unreg_bus:
+	bus_unregister(&regulator_bus);
 unreg_compat:
 	class_compat_unregister(regulator_compat_class);
 	return ret;