[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230218083252.2044423-3-saravanak@google.com>
Date: Sat, 18 Feb 2023 00:32:49 -0800
From: Saravana Kannan <saravanak@...gle.com>
To: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
Cc: Saravana Kannan <saravanak@...gle.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Bjorn Andersson <andersson@...nel.org>,
Sudeep Holla <sudeep.holla@....com>,
Tony Lindgren <tony@...mide.com>,
Doug Anderson <dianders@...omium.org>,
Guenter Roeck <linux@...ck-us.net>,
Luca Weiss <luca.weiss@...rphone.com>, kernel-team@...roid.com,
linux-kernel@...r.kernel.org
Subject: [RFC v1 2/4] regulator: core: Add sysfs class backward compatibility
A regulator device's sysfs directory used to be created under
/sys/class/regulator when it is added to a class. Since the device is
now moved to be under a bus, add symlinks from /sys/class/regulator to
the real device sysfs directory.
Signed-off-by: Saravana Kannan <saravanak@...gle.com>
---
drivers/regulator/core.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 1a212edcf216..b6700d50d230 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -43,6 +43,7 @@ static LIST_HEAD(regulator_coupler_list);
static bool has_full_constraints;
static struct dentry *debugfs_root;
+static struct class_compat *regulator_compat_class;
/*
* struct regulator_map
@@ -5636,6 +5637,11 @@ regulator_register(struct device *dev,
if (ret != 0)
goto unset_supplies;
+ if (class_compat_create_link(regulator_compat_class, &rdev->dev,
+ rdev->dev.parent))
+ dev_warn(&rdev->dev,
+ "Failed to create compatibility class link\n");
+
rdev_init_debugfs(rdev);
/* try to resolve regulators coupling since a new one was registered */
@@ -5702,6 +5708,8 @@ void regulator_unregister(struct regulator_dev *rdev)
unset_regulator_supplies(rdev);
list_del(&rdev->list);
regulator_ena_gpio_free(rdev);
+ class_compat_remove_link(regulator_compat_class, &rdev->dev,
+ rdev->dev.parent);
device_unregister(&rdev->dev);
mutex_unlock(®ulator_list_mutex);
@@ -6107,7 +6115,13 @@ static int __init regulator_init(void)
{
int ret;
+ regulator_compat_class = class_compat_register("regulator");
+ if (!regulator_compat_class)
+ return -ENOMEM;
+
ret = bus_register(®ulator_bus);
+ if (ret)
+ goto unreg_compat;
debugfs_root = debugfs_create_dir("regulator", NULL);
if (!debugfs_root)
@@ -6120,11 +6134,16 @@ static int __init regulator_init(void)
debugfs_create_file("regulator_summary", 0444, debugfs_root,
NULL, ®ulator_summary_fops);
#endif
+
regulator_dummy_init();
regulator_coupler_register(&generic_regulator_coupler);
return ret;
+
+unreg_compat:
+ class_compat_unregister(regulator_compat_class);
+ return ret;
}
/* init early to allow our consumers to complete system booting */
--
2.39.2.637.g21b0678d19-goog
Powered by blists - more mailing lists