Skip to content

Commit c2a44a0

Browse files
committed
Merge tag 'gpio-fixes-for-v6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: "Two more GPIO fixes addressing an issue uncovered by the shared GPIO management changes in v6.19: - implement the missing .get_direction() callback for gpio-davinci - remove redundant check in GPIO core which can also propagate an invalid errno to user-space" * tag 'gpio-fixes-for-v6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpiolib: remove redundant callback check gpio: davinci: implement .get_direction()
2 parents 7a2c1b2 + 471e998 commit c2a44a0

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

drivers/gpio/gpio-davinci.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com>
77
*/
88

9+
#include <linux/cleanup.h>
910
#include <linux/gpio/driver.h>
1011
#include <linux/errno.h>
1112
#include <linux/kernel.h>
@@ -109,6 +110,22 @@ davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value)
109110
return __davinci_direction(chip, offset, true, value);
110111
}
111112

113+
static int davinci_get_direction(struct gpio_chip *chip, unsigned int offset)
114+
{
115+
struct davinci_gpio_controller *d = gpiochip_get_data(chip);
116+
struct davinci_gpio_regs __iomem *g;
117+
u32 mask = __gpio_mask(offset), val;
118+
int bank = offset / 32;
119+
120+
g = d->regs[bank];
121+
122+
guard(spinlock_irqsave)(&d->lock);
123+
124+
val = readl_relaxed(&g->dir);
125+
126+
return (val & mask) ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
127+
}
128+
112129
/*
113130
* Read the pin's value (works even if it's set up as output);
114131
* returns zero/nonzero.
@@ -203,6 +220,7 @@ static int davinci_gpio_probe(struct platform_device *pdev)
203220
chips->chip.get = davinci_gpio_get;
204221
chips->chip.direction_output = davinci_direction_out;
205222
chips->chip.set = davinci_gpio_set;
223+
chips->chip.get_direction = davinci_get_direction;
206224

207225
chips->chip.ngpio = ngpio;
208226
chips->chip.base = -1;

drivers/gpio/gpiolib.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,6 @@ int gpiod_get_direction(struct gpio_desc *desc)
468468
test_bit(GPIOD_FLAG_IS_OUT, &flags))
469469
return 0;
470470

471-
if (!guard.gc->get_direction)
472-
return -ENOTSUPP;
473-
474471
ret = gpiochip_get_direction(guard.gc, offset);
475472
if (ret < 0)
476473
return ret;

0 commit comments

Comments
 (0)