* [PATCH] gpio: generic: add get_direction support
@ 2015-06-12 16:20 Philipp Zabel
2015-06-15 2:32 ` Alexandre Courbot
2015-06-30 6:19 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Philipp Zabel @ 2015-06-12 16:20 UTC (permalink / raw)
To: Linus Walleij
Cc: Alexandre Courbot, linux-gpio, linux-kernel, kernel, Philipp Zabel
Allow to determine the current direction configuration by
reading back from the direction register.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
drivers/gpio/gpio-generic.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index b92a690..fb9c572 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -291,6 +291,14 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
return 0;
}
+static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
+{
+ struct bgpio_chip *bgc = to_bgpio_chip(gc);
+
+ return (bgc->read_reg(bgc->reg_dir) & bgc->pin2mask(bgc, gpio)) ?
+ GPIOF_DIR_OUT : GPIOF_DIR_IN;
+}
+
static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
{
struct bgpio_chip *bgc = to_bgpio_chip(gc);
@@ -340,6 +348,14 @@ static int bgpio_dir_out_inv(struct gpio_chip *gc, unsigned int gpio, int val)
return 0;
}
+static int bgpio_get_dir_inv(struct gpio_chip *gc, unsigned int gpio)
+{
+ struct bgpio_chip *bgc = to_bgpio_chip(gc);
+
+ return (bgc->read_reg(bgc->reg_dir) & bgc->pin2mask(bgc, gpio)) ?
+ GPIOF_DIR_IN : GPIOF_DIR_OUT;
+}
+
static int bgpio_setup_accessors(struct device *dev,
struct bgpio_chip *bgc,
bool bit_be,
@@ -452,10 +468,12 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc,
bgc->reg_dir = dirout;
bgc->gc.direction_output = bgpio_dir_out;
bgc->gc.direction_input = bgpio_dir_in;
+ bgc->gc.get_direction = bgpio_get_dir;
} else if (dirin) {
bgc->reg_dir = dirin;
bgc->gc.direction_output = bgpio_dir_out_inv;
bgc->gc.direction_input = bgpio_dir_in_inv;
+ bgc->gc.get_direction = bgpio_get_dir_inv;
} else {
bgc->gc.direction_output = bgpio_simple_dir_out;
bgc->gc.direction_input = bgpio_simple_dir_in;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: generic: add get_direction support
2015-06-12 16:20 [PATCH] gpio: generic: add get_direction support Philipp Zabel
@ 2015-06-15 2:32 ` Alexandre Courbot
2015-06-30 6:19 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Courbot @ 2015-06-15 2:32 UTC (permalink / raw)
To: Philipp Zabel
Cc: Linus Walleij, linux-gpio, Linux Kernel Mailing List, Sascha Hauer
On Sat, Jun 13, 2015 at 1:20 AM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Allow to determine the current direction configuration by
> reading back from the direction register.
Interesting that this was missing.
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: generic: add get_direction support
2015-06-12 16:20 [PATCH] gpio: generic: add get_direction support Philipp Zabel
2015-06-15 2:32 ` Alexandre Courbot
@ 2015-06-30 6:19 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-06-30 6:19 UTC (permalink / raw)
To: Philipp Zabel; +Cc: Alexandre Courbot, linux-gpio, linux-kernel, Sascha Hauer
On Fri, Jun 12, 2015 at 6:20 PM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Allow to determine the current direction configuration by
> reading back from the direction register.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Patch applied for the next kernel cycle (4.3).
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-30 6:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 16:20 [PATCH] gpio: generic: add get_direction support Philipp Zabel
2015-06-15 2:32 ` Alexandre Courbot
2015-06-30 6:19 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).