mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-02 03:30:08 -04:00
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()
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
* Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/gpio/driver.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -109,6 +110,22 @@ davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value)
|
||||
return __davinci_direction(chip, offset, true, value);
|
||||
}
|
||||
|
||||
static int davinci_get_direction(struct gpio_chip *chip, unsigned int offset)
|
||||
{
|
||||
struct davinci_gpio_controller *d = gpiochip_get_data(chip);
|
||||
struct davinci_gpio_regs __iomem *g;
|
||||
u32 mask = __gpio_mask(offset), val;
|
||||
int bank = offset / 32;
|
||||
|
||||
g = d->regs[bank];
|
||||
|
||||
guard(spinlock_irqsave)(&d->lock);
|
||||
|
||||
val = readl_relaxed(&g->dir);
|
||||
|
||||
return (val & mask) ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the pin's value (works even if it's set up as output);
|
||||
* returns zero/nonzero.
|
||||
@@ -203,6 +220,7 @@ static int davinci_gpio_probe(struct platform_device *pdev)
|
||||
chips->chip.get = davinci_gpio_get;
|
||||
chips->chip.direction_output = davinci_direction_out;
|
||||
chips->chip.set = davinci_gpio_set;
|
||||
chips->chip.get_direction = davinci_get_direction;
|
||||
|
||||
chips->chip.ngpio = ngpio;
|
||||
chips->chip.base = -1;
|
||||
|
||||
@@ -468,9 +468,6 @@ int gpiod_get_direction(struct gpio_desc *desc)
|
||||
test_bit(GPIOD_FLAG_IS_OUT, &flags))
|
||||
return 0;
|
||||
|
||||
if (!guard.gc->get_direction)
|
||||
return -ENOTSUPP;
|
||||
|
||||
ret = gpiochip_get_direction(guard.gc, offset);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user