From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] regulator: fixed: Use gpiod
Date: Thu, 17 Jun 2021 16:12:42 +0200 [thread overview]
Message-ID: <20210617141242.545-1-s.hauer@pengutronix.de> (raw)
Switch to gpiod_get() which makes the implementation a bit more
straight forward.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/regulator/fixed.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 160a55163f..e35b294fb2 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -20,10 +20,10 @@
#include <of.h>
#include <of_gpio.h>
#include <gpio.h>
+#include <gpiod.h>
struct regulator_fixed {
int gpio;
- int active_low;
int always_on;
struct regulator_dev rdev;
struct regulator_desc rdesc;
@@ -36,7 +36,7 @@ static int regulator_fixed_enable(struct regulator_dev *rdev)
if (!gpio_is_valid(fix->gpio))
return 0;
- return gpio_direction_output(fix->gpio, !fix->active_low);
+ return gpio_direction_active(fix->gpio, true);
}
static int regulator_fixed_disable(struct regulator_dev *rdev)
@@ -49,7 +49,7 @@ static int regulator_fixed_disable(struct regulator_dev *rdev)
if (!gpio_is_valid(fix->gpio))
return 0;
- return gpio_direction_output(fix->gpio, fix->active_low);
+ return gpio_direction_active(fix->gpio, false);
}
const static struct regulator_ops fixed_ops = {
@@ -60,7 +60,6 @@ const static struct regulator_ops fixed_ops = {
static int regulator_fixed_probe(struct device_d *dev)
{
struct regulator_fixed *fix;
- enum of_gpio_flags gpioflags;
int ret;
if (!dev->device_node)
@@ -70,14 +69,11 @@ static int regulator_fixed_probe(struct device_d *dev)
fix->gpio = -EINVAL;
if (of_get_property(dev->device_node, "gpio", NULL)) {
- fix->gpio = of_get_named_gpio_flags(dev->device_node, "gpio", 0, &gpioflags);
+ fix->gpio = gpiod_get(dev, NULL, GPIOD_ASIS);
if (fix->gpio < 0) {
ret = fix->gpio;
goto err;
}
-
- if (gpioflags & OF_GPIO_ACTIVE_LOW)
- fix->active_low = 1;
}
fix->rdesc.ops = &fixed_ops;
--
2.29.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2021-06-17 14:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210617141242.545-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox