mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
gpio: mmio: use new GPIO line value setter callbacks
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20250610-gpiochip-set-rv-gpio-v1-1-3a9a3c1472ff@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
d03b53c913
commit
b908d35d00
1 changed files with 33 additions and 20 deletions
|
@ -211,11 +211,12 @@ static int bgpio_get_multiple_be(struct gpio_chip *gc, unsigned long *mask,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgpio_set_none(struct gpio_chip *gc, unsigned int gpio, int val)
|
static int bgpio_set_none(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
static int bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||||
{
|
{
|
||||||
unsigned long mask = bgpio_line2mask(gc, gpio);
|
unsigned long mask = bgpio_line2mask(gc, gpio);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
@ -230,10 +231,12 @@ static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||||
gc->write_reg(gc->reg_dat, gc->bgpio_data);
|
gc->write_reg(gc->reg_dat, gc->bgpio_data);
|
||||||
|
|
||||||
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
|
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
|
static int bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
|
||||||
int val)
|
int val)
|
||||||
{
|
{
|
||||||
unsigned long mask = bgpio_line2mask(gc, gpio);
|
unsigned long mask = bgpio_line2mask(gc, gpio);
|
||||||
|
|
||||||
|
@ -241,9 +244,11 @@ static void bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
|
||||||
gc->write_reg(gc->reg_set, mask);
|
gc->write_reg(gc->reg_set, mask);
|
||||||
else
|
else
|
||||||
gc->write_reg(gc->reg_clr, mask);
|
gc->write_reg(gc->reg_clr, mask);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
static int bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||||
{
|
{
|
||||||
unsigned long mask = bgpio_line2mask(gc, gpio);
|
unsigned long mask = bgpio_line2mask(gc, gpio);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
@ -258,6 +263,8 @@ static void bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||||
gc->write_reg(gc->reg_set, gc->bgpio_data);
|
gc->write_reg(gc->reg_set, gc->bgpio_data);
|
||||||
|
|
||||||
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
|
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgpio_multiple_get_masks(struct gpio_chip *gc,
|
static void bgpio_multiple_get_masks(struct gpio_chip *gc,
|
||||||
|
@ -298,21 +305,25 @@ static void bgpio_set_multiple_single_reg(struct gpio_chip *gc,
|
||||||
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
|
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
|
static int bgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
|
||||||
unsigned long *bits)
|
unsigned long *bits)
|
||||||
{
|
{
|
||||||
bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_dat);
|
bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_dat);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgpio_set_multiple_set(struct gpio_chip *gc, unsigned long *mask,
|
static int bgpio_set_multiple_set(struct gpio_chip *gc, unsigned long *mask,
|
||||||
unsigned long *bits)
|
unsigned long *bits)
|
||||||
{
|
{
|
||||||
bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_set);
|
bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_set);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bgpio_set_multiple_with_clear(struct gpio_chip *gc,
|
static int bgpio_set_multiple_with_clear(struct gpio_chip *gc,
|
||||||
unsigned long *mask,
|
unsigned long *mask,
|
||||||
unsigned long *bits)
|
unsigned long *bits)
|
||||||
{
|
{
|
||||||
unsigned long set_mask, clear_mask;
|
unsigned long set_mask, clear_mask;
|
||||||
|
|
||||||
|
@ -322,6 +333,8 @@ static void bgpio_set_multiple_with_clear(struct gpio_chip *gc,
|
||||||
gc->write_reg(gc->reg_set, set_mask);
|
gc->write_reg(gc->reg_set, set_mask);
|
||||||
if (clear_mask)
|
if (clear_mask)
|
||||||
gc->write_reg(gc->reg_clr, clear_mask);
|
gc->write_reg(gc->reg_clr, clear_mask);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bgpio_dir_return(struct gpio_chip *gc, unsigned int gpio, bool dir_out)
|
static int bgpio_dir_return(struct gpio_chip *gc, unsigned int gpio, bool dir_out)
|
||||||
|
@ -510,18 +523,18 @@ static int bgpio_setup_io(struct gpio_chip *gc,
|
||||||
if (set && clr) {
|
if (set && clr) {
|
||||||
gc->reg_set = set;
|
gc->reg_set = set;
|
||||||
gc->reg_clr = clr;
|
gc->reg_clr = clr;
|
||||||
gc->set = bgpio_set_with_clear;
|
gc->set_rv = bgpio_set_with_clear;
|
||||||
gc->set_multiple = bgpio_set_multiple_with_clear;
|
gc->set_multiple_rv = bgpio_set_multiple_with_clear;
|
||||||
} else if (set && !clr) {
|
} else if (set && !clr) {
|
||||||
gc->reg_set = set;
|
gc->reg_set = set;
|
||||||
gc->set = bgpio_set_set;
|
gc->set_rv = bgpio_set_set;
|
||||||
gc->set_multiple = bgpio_set_multiple_set;
|
gc->set_multiple_rv = bgpio_set_multiple_set;
|
||||||
} else if (flags & BGPIOF_NO_OUTPUT) {
|
} else if (flags & BGPIOF_NO_OUTPUT) {
|
||||||
gc->set = bgpio_set_none;
|
gc->set_rv = bgpio_set_none;
|
||||||
gc->set_multiple = NULL;
|
gc->set_multiple_rv = NULL;
|
||||||
} else {
|
} else {
|
||||||
gc->set = bgpio_set;
|
gc->set_rv = bgpio_set;
|
||||||
gc->set_multiple = bgpio_set_multiple;
|
gc->set_multiple_rv = bgpio_set_multiple;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & BGPIOF_UNREADABLE_REG_SET) &&
|
if (!(flags & BGPIOF_UNREADABLE_REG_SET) &&
|
||||||
|
@ -654,7 +667,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
gc->bgpio_data = gc->read_reg(gc->reg_dat);
|
gc->bgpio_data = gc->read_reg(gc->reg_dat);
|
||||||
if (gc->set == bgpio_set_set &&
|
if (gc->set_rv == bgpio_set_set &&
|
||||||
!(flags & BGPIOF_UNREADABLE_REG_SET))
|
!(flags & BGPIOF_UNREADABLE_REG_SET))
|
||||||
gc->bgpio_data = gc->read_reg(gc->reg_set);
|
gc->bgpio_data = gc->read_reg(gc->reg_set);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue