[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220218110604.1329024-1-vincent.whitchurch@axis.com>
Date: Fri, 18 Feb 2022 12:06:03 +0100
From: Vincent Whitchurch <vincent.whitchurch@...s.com>
To: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
CC: <kernel@...s.com>, <devicetree@...r.kernel.org>,
Vincent Whitchurch <vincent.whitchurch@...s.com>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH] regulator: virtual: add devicetree support
The reg-virt-consumer is very useful for development and testing of
regulator drivers since it allows voltages and modes to be set from
userspace. However, it currently requires platform data so it cannot be
used on modern platforms. Add support for probing it from the
devicetree to remedy this.
Since this driver is only meant for testing and is a purely software
construct, no binding documentation is added.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@...s.com>
---
drivers/regulator/virtual.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index 52c5a0e0acd8..c4d56b484ed5 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -13,6 +13,7 @@
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/of.h>
struct virtual_consumer_data {
struct mutex lock;
@@ -281,6 +282,14 @@ static const struct attribute_group regulator_virtual_attr_group = {
.attrs = regulator_virtual_attributes,
};
+#ifdef CONFIG_OF
+static const struct of_device_id regulator_virtual_consumer_of_match[] = {
+ { .compatible = "regulator-virtual-consumer" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, regulator_virtual_consumer_of_match);
+#endif
+
static int regulator_virtual_probe(struct platform_device *pdev)
{
char *reg_id = dev_get_platdata(&pdev->dev);
@@ -292,6 +301,9 @@ static int regulator_virtual_probe(struct platform_device *pdev)
if (drvdata == NULL)
return -ENOMEM;
+ if (!reg_id)
+ reg_id = "default";
+
mutex_init(&drvdata->lock);
drvdata->regulator = devm_regulator_get(&pdev->dev, reg_id);
@@ -334,6 +346,7 @@ static struct platform_driver regulator_virtual_consumer_driver = {
.remove = regulator_virtual_remove,
.driver = {
.name = "reg-virt-consumer",
+ .of_match_table = of_match_ptr(regulator_virtual_consumer_of_match),
},
};
--
2.34.1
Powered by blists - more mailing lists