mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Sangbeom Kim <sbkim73@samsung.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org
Cc: Sachin Kamat <sachin.kamat@linaro.org>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>
Subject: [PATCH 2/2] regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14
Date: Wed, 30 Apr 2014 10:40:42 +0200	[thread overview]
Message-ID: <1398847242-9394-2-git-send-email-k.kozlowski@samsung.com> (raw)
In-Reply-To: <1398847242-9394-1-git-send-email-k.kozlowski@samsung.com>

GPIO 0 is a valid GPIO so allow using it as external control for
S2MPS14 regulators.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/regulator/s2mps11.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 6dad0aa74a47..1583d4eaf911 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -412,7 +412,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev)
 
 	if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
 		val = S2MPS14_ENABLE_SUSPEND;
-	else if (s2mps11->ext_control_gpio[rdev_get_id(rdev)])
+	else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
 		val = S2MPS14_ENABLE_EXT_CONTROL;
 	else
 		val = rdev->desc->enable_mask;
@@ -593,9 +593,7 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
 
 		gpio[reg] = of_get_named_gpio(rdata[reg].of_node,
 				"samsung,ext-control-gpios", 0);
-		if (!gpio_is_valid(gpio[reg]))
-			gpio[reg] = 0;
-		else
+		if (gpio_is_valid(gpio[reg]))
 			dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n",
 					gpio[reg], reg, rdata[reg].name);
 	}
@@ -658,6 +656,12 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
 			GFP_KERNEL);
 	if (!s2mps11->ext_control_gpio)
 		return -ENOMEM;
+	/*
+	 * 0 is a valid GPIO so initialize all GPIO-s to negative value
+	 * to indicate that external control won't be used for this regulator.
+	 */
+	for (i = 0; i < s2mps11->rdev_num; i++)
+		s2mps11->ext_control_gpio[i] = -EINVAL;
 
 	if (!iodev->dev->of_node) {
 		if (iodev->pdata) {
@@ -687,6 +691,7 @@ common_reg:
 	config.dev = &pdev->dev;
 	config.regmap = iodev->regmap_pmic;
 	config.driver_data = s2mps11;
+	config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
 	for (i = 0; i < s2mps11->rdev_num; i++) {
 		struct regulator_dev *regulator;
 
@@ -697,12 +702,7 @@ common_reg:
 			config.init_data = rdata[i].init_data;
 			config.of_node = rdata[i].of_node;
 		}
-
-		if (s2mps11->ext_control_gpio[i]) {
-			config.ena_gpio = s2mps11->ext_control_gpio[i];
-			config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
-		} else
-			config.ena_gpio = config.ena_gpio_flags = 0;
+		config.ena_gpio = s2mps11->ext_control_gpio[i];
 
 		regulator = devm_regulator_register(&pdev->dev,
 						&regulators[i], &config);
@@ -713,7 +713,7 @@ common_reg:
 			goto out;
 		}
 
-		if (s2mps11->ext_control_gpio[i]) {
+		if (gpio_is_valid(s2mps11->ext_control_gpio[i])) {
 			ret = s2mps14_pmic_enable_ext_control(s2mps11,
 					regulator);
 			if (ret < 0) {
-- 
1.9.1


  reply	other threads:[~2014-04-30  8:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30  8:40 [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control Krzysztof Kozlowski
2014-04-30  8:40 ` Krzysztof Kozlowski [this message]
2014-05-01 17:53   ` [PATCH 2/2] regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14 Mark Brown
2014-05-01 17:53 ` [PATCH 1/2] regulator: s5m8767: Allow GPIO 0 to be used as external control 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=1398847242-9394-2-git-send-email-k.kozlowski@samsung.com \
    --to=k.kozlowski@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=broonie@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=sachin.kamat@linaro.org \
    --cc=sbkim73@samsung.com \
    /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®