mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Okazaki <dtokazaki@google.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,  Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Zev Weiss <zev@bewilderbeest.net>
Cc: Daniel Okazaki <dtokazaki@google.com>,
	kernel-team@android.com,  linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: [PATCH v1 2/2] regulator: userspace-consumer add shared supply functionality
Date: Wed, 28 May 2025 17:44:25 +0000	[thread overview]
Message-ID: <20250528174426.3318110-3-dtokazaki@google.com> (raw)
In-Reply-To: <20250528174426.3318110-1-dtokazaki@google.com>

Add is_shared flag to indictae that regulator control is not
exclusive to this module.

Signed-off-by: Daniel Okazaki <dtokazaki@google.com>
---
 drivers/regulator/userspace-consumer.c | 39 ++++++++++++++++----------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
index 72bb5ffb49a8..4ab316d528fb 100644
--- a/drivers/regulator/userspace-consumer.c
+++ b/drivers/regulator/userspace-consumer.c
@@ -26,6 +26,7 @@ struct userspace_consumer_data {
 	struct mutex lock;
 	bool enabled;
 	bool no_autoswitch;
+	bool is_shared;
 
 	int num_supplies;
 	struct regulator_bulk_data *supplies;
@@ -156,8 +157,14 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
 
 	mutex_init(&drvdata->lock);
 
-	ret = devm_regulator_bulk_get_exclusive(&pdev->dev, drvdata->num_supplies,
-						drvdata->supplies);
+	drvdata->is_shared = of_property_read_bool(pdev->dev.of_node, "is_shared");
+	if (drvdata->is_shared) {
+		ret = devm_regulator_bulk_get(&pdev->dev, drvdata->num_supplies,
+					      drvdata->supplies);
+	} else {
+		ret = devm_regulator_bulk_get_exclusive(&pdev->dev, drvdata->num_supplies,
+							drvdata->supplies);
+	}
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret, "Failed to get supplies\n");
 
@@ -167,22 +174,24 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
 	if (ret != 0)
 		return ret;
 
-	if (pdata->init_on && !pdata->no_autoswitch) {
-		ret = regulator_bulk_enable(drvdata->num_supplies,
-					    drvdata->supplies);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"Failed to set initial state: %d\n", ret);
-			goto err_enable;
+	if (!drvdata->is_shared) {
+		if (pdata->init_on && !pdata->no_autoswitch) {
+			ret = regulator_bulk_enable(drvdata->num_supplies,
+						    drvdata->supplies);
+			if (ret) {
+				dev_err(&pdev->dev,
+					"Failed to set initial state: %d\n", ret);
+				goto err_enable;
+			}
 		}
-	}
 
-	ret = regulator_is_enabled(pdata->supplies[0].consumer);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "Failed to get regulator status\n");
-		goto err_enable;
+		ret = regulator_is_enabled(pdata->supplies[0].consumer);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "Failed to get regulator status\n");
+			goto err_enable;
+		}
+		drvdata->enabled = !!ret;
 	}
-	drvdata->enabled = !!ret;
 
 	return 0;
 
-- 
2.49.0.1204.g71687c7c1d-goog


  parent reply	other threads:[~2025-05-28 17:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28 17:44 [PATCH v1 0/2] userspace-consumer: adding is_shared flag Daniel Okazaki
2025-05-28 17:44 ` [PATCH v1 1/2] regulator: Add regulator-output is_shared property Daniel Okazaki
2025-05-28 17:44 ` Daniel Okazaki [this message]
2025-05-28 18:16 ` [PATCH v1 0/2] userspace-consumer: adding is_shared flag Mark Brown
2025-05-28 18:32   ` Daniel Okazaki
2025-05-28 19:20     ` Mark Brown
2025-05-28 21:15       ` Daniel Okazaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250528174426.3318110-3-dtokazaki@google.com \
    --to=dtokazaki@google.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel-team@android.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=zev@bewilderbeest.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®