All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Adamski <krzysztof.adamski@tieto.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org
Cc: Krzysztof Adamski <krzysztof.adamski@tieto.com>
Subject: [PATCH] regulator: core: Request GPIO before creating sysfs entries
Date: Mon, 22 Feb 2016 09:24:00 +0100	[thread overview]
Message-ID: <1456129440-28143-1-git-send-email-krzysztof.adamski@tieto.com> (raw)

regulator_attr_is_visible (which is a .is_visible callback of
regulator_dev_group attribute_grpup) checks rdev->ena_pin to decide if
"status" file should be present in sysfs. This field is set at the end
of regulator_ena_gpio_request so it has to be called before
device_register() otherwise this test will always fail, causing "status"
file to not be visible.

Since regulator_attr_is_visible also tests for is_enabled() op, this
problem is only visible for regulators that does not define this
callback, like regulator-fixed.c.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@tieto.com>
---
 drivers/regulator/core.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 4405be1..6ee9ba4 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3913,6 +3913,16 @@ regulator_register(const struct regulator_desc *regulator_desc,
 			goto clean;
 	}
 
+	if ((config->ena_gpio || config->ena_gpio_initialized) &&
+	    gpio_is_valid(config->ena_gpio)) {
+		ret = regulator_ena_gpio_request(rdev, config);
+		if (ret != 0) {
+			rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
+				 config->ena_gpio, ret);
+			goto wash;
+		}
+	}
+
 	/* register with sysfs */
 	rdev->dev.class = &regulator_class;
 	rdev->dev.parent = dev;
@@ -3926,16 +3936,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
 
 	dev_set_drvdata(&rdev->dev, rdev);
 
-	if ((config->ena_gpio || config->ena_gpio_initialized) &&
-	    gpio_is_valid(config->ena_gpio)) {
-		ret = regulator_ena_gpio_request(rdev, config);
-		if (ret != 0) {
-			rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
-				 config->ena_gpio, ret);
-			goto wash;
-		}
-	}
-
 	/* set regulator constraints */
 	if (init_data)
 		constraints = &init_data->constraints;
-- 
2.1.4

             reply	other threads:[~2016-02-22  8:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22  8:24 Krzysztof Adamski [this message]
     [not found] ` <1456129440-28143-1-git-send-email-krzysztof.adamski-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
2016-02-23 13:22   ` regulator: core: Request GPIO before creating sysfs entries Jon Hunter
     [not found]     ` <56CC5D1E.6010101-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-23 13:56       ` Krzysztof Adamski
2016-02-23 14:15         ` Jon Hunter
2016-02-23 14:34           ` Krzysztof Adamski
2016-02-23 14:47           ` [PATCH] regulator: core: fix error path of regulator_ena_gpio_free Krzysztof Adamski
2016-02-23 15:18             ` Jon Hunter
     [not found]               ` <56CC7863.4080202-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-24  8:26                 ` Krzysztof Adamski
2016-02-24  8:26                   ` Krzysztof Adamski
2016-02-24  9:03                   ` Jon Hunter
2016-02-24  8:27                 ` Krzysztof Adamski
2016-02-24  8:27                   ` Krzysztof Adamski
2016-02-24  9:18                   ` Jon Hunter
2016-02-24 10:52                     ` [PATCH v3] regulator: core: fix crash in error path of regulator_register Krzysztof Adamski
     [not found]                   ` <1456302479-14045-1-git-send-email-krzysztof.adamski-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
2016-02-24  9:20                     ` [PATCH] regulator: core: fix error path of regulator_ena_gpio_free Jon Hunter
2016-02-24  9:20                       ` Jon Hunter
2016-02-25  1:46                       ` Mark Brown
2016-02-24  3:48       ` regulator: core: Request GPIO before creating sysfs entries Mark Brown

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=1456129440-28143-1-git-send-email-krzysztof.adamski@tieto.com \
    --to=krzysztof.adamski@tieto.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.