[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230418145051.4192963-2-Naresh.Solanki@9elements.com>
Date: Tue, 18 Apr 2023 16:50:51 +0200
From: Naresh Solanki <naresh.solanki@...ements.com>
To: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
Cc: Naresh Solanki <Naresh.Solanki@...ements.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] regulator: userspace-consumer: Multiple regulators
Use property regulator-supplies to determine all regulator
supplies.
This is useful in case of a connector having 2 or more supplies.
Example: PCIe connector on mainboard can be powered by 12V & 3.3V
suplies.
Signed-off-by: Naresh Solanki <Naresh.Solanki@...ements.com>
---
drivers/regulator/userspace-consumer.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
index 97f075ed68c9..0bb49547b926 100644
--- a/drivers/regulator/userspace-consumer.c
+++ b/drivers/regulator/userspace-consumer.c
@@ -120,7 +120,10 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
struct regulator_userspace_consumer_data tmpdata;
struct regulator_userspace_consumer_data *pdata;
struct userspace_consumer_data *drvdata;
- int ret;
+ struct device_node *np = pdev->dev.of_node;
+ struct property *prop;
+ const char *supply;
+ int ret, count = 0;
pdata = dev_get_platdata(&pdev->dev);
if (!pdata) {
@@ -131,11 +134,19 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
memset(pdata, 0, sizeof(*pdata));
pdata->no_autoswitch = true;
- pdata->num_supplies = 1;
- pdata->supplies = devm_kzalloc(&pdev->dev, sizeof(*pdata->supplies), GFP_KERNEL);
+ pdata->num_supplies = of_property_count_strings(np, "regulator-supplies");
+ if (pdata->num_supplies < 0) {
+ dev_err(&pdev->dev, "could not parse property regulator-supplies");
+ return -EINVAL;
+ }
+ pdata->supplies = devm_kzalloc(&pdev->dev,
+ sizeof(*pdata->supplies) * pdata->num_supplies,
+ GFP_KERNEL);
if (!pdata->supplies)
return -ENOMEM;
- pdata->supplies[0].supply = "vout";
+
+ of_property_for_each_string(np, "regulator-supplies", prop, supply)
+ pdata->supplies[count++].supply = supply;
}
if (pdata->num_supplies < 1) {
--
2.39.1
Powered by blists - more mailing lists