Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions drivers/gpio/gpio-mm-lantiq.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ static void ltq_mm_apply(struct ltq_mm *chip)
* @gpio: GPIO signal number.
* @val: Value to be written to specified signal.
*
* Set the shadow value and call ltq_mm_apply.
* Set the shadow value and call ltq_mm_apply. Always returns 0.
*/
static void ltq_mm_set(struct gpio_chip *gc, unsigned offset, int value)
static int ltq_mm_set(struct gpio_chip *gc, unsigned int offset, int value)
{
struct ltq_mm *chip = gpiochip_get_data(gc);

Expand All @@ -66,6 +66,8 @@ static void ltq_mm_set(struct gpio_chip *gc, unsigned offset, int value)
else
chip->shadow &= ~(1 << offset);
ltq_mm_apply(chip);

return 0;
}

/**
Expand All @@ -78,9 +80,7 @@ static void ltq_mm_set(struct gpio_chip *gc, unsigned offset, int value)
*/
static int ltq_mm_dir_out(struct gpio_chip *gc, unsigned offset, int value)
{
ltq_mm_set(gc, offset, value);

return 0;
return ltq_mm_set(gc, offset, value);
}

/**
Expand Down Expand Up @@ -111,7 +111,7 @@ static int ltq_mm_probe(struct platform_device *pdev)

chip->mmchip.gc.ngpio = 16;
chip->mmchip.gc.direction_output = ltq_mm_dir_out;
chip->mmchip.gc.set = ltq_mm_set;
chip->mmchip.gc.set_rv = ltq_mm_set;
chip->mmchip.save_regs = ltq_mm_save_regs;

/* store the shadow value if one was passed by the devicetree */
Expand Down
53 changes: 33 additions & 20 deletions drivers/gpio/gpio-mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,12 @@ static int bgpio_get_multiple_be(struct gpio_chip *gc, unsigned long *mask,
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 flags;
Expand All @@ -230,20 +231,24 @@ static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
gc->write_reg(gc->reg_dat, gc->bgpio_data);

raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);

return 0;
}

static void bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
int val)
static int bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
int val)
{
unsigned long mask = bgpio_line2mask(gc, gpio);

if (val)
gc->write_reg(gc->reg_set, mask);
else
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 flags;
Expand All @@ -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);

raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);

return 0;
}

static void bgpio_multiple_get_masks(struct gpio_chip *gc,
Expand Down Expand Up @@ -298,21 +305,25 @@ static void bgpio_set_multiple_single_reg(struct gpio_chip *gc,
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)
{
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,
unsigned long *bits)
static int bgpio_set_multiple_set(struct gpio_chip *gc, unsigned long *mask,
unsigned long *bits)
{
bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_set);

return 0;
}

static void bgpio_set_multiple_with_clear(struct gpio_chip *gc,
unsigned long *mask,
unsigned long *bits)
static int bgpio_set_multiple_with_clear(struct gpio_chip *gc,
unsigned long *mask,
unsigned long *bits)
{
unsigned long set_mask, clear_mask;

Expand All @@ -322,6 +333,8 @@ static void bgpio_set_multiple_with_clear(struct gpio_chip *gc,
gc->write_reg(gc->reg_set, set_mask);
if (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)
Expand Down Expand Up @@ -510,18 +523,18 @@ static int bgpio_setup_io(struct gpio_chip *gc,
if (set && clr) {
gc->reg_set = set;
gc->reg_clr = clr;
gc->set = bgpio_set_with_clear;
gc->set_multiple = bgpio_set_multiple_with_clear;
gc->set_rv = bgpio_set_with_clear;
gc->set_multiple_rv = bgpio_set_multiple_with_clear;
} else if (set && !clr) {
gc->reg_set = set;
gc->set = bgpio_set_set;
gc->set_multiple = bgpio_set_multiple_set;
gc->set_rv = bgpio_set_set;
gc->set_multiple_rv = bgpio_set_multiple_set;
} else if (flags & BGPIOF_NO_OUTPUT) {
gc->set = bgpio_set_none;
gc->set_multiple = NULL;
gc->set_rv = bgpio_set_none;
gc->set_multiple_rv = NULL;
} else {
gc->set = bgpio_set;
gc->set_multiple = bgpio_set_multiple;
gc->set_rv = bgpio_set;
gc->set_multiple_rv = bgpio_set_multiple;
}

if (!(flags & BGPIOF_UNREADABLE_REG_SET) &&
Expand Down Expand Up @@ -654,7 +667,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,
}

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))
gc->bgpio_data = gc->read_reg(gc->reg_set);

Expand Down
16 changes: 7 additions & 9 deletions drivers/gpio/gpio-moxtet.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ static int moxtet_gpio_get_value(struct gpio_chip *gc, unsigned int offset)
return !!(ret & BIT(offset));
}

static void moxtet_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
int val)
static int moxtet_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
int val)
{
struct moxtet_gpio_chip *chip = gpiochip_get_data(gc);
int state;

state = moxtet_device_written(chip->dev);
if (state < 0)
return;
return state;

offset -= MOXTET_GPIO_INPUTS;

Expand All @@ -69,7 +69,7 @@ static void moxtet_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
else
state &= ~BIT(offset);

moxtet_device_write(chip->dev, state);
return moxtet_device_write(chip->dev, state);
}

static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
Expand Down Expand Up @@ -104,13 +104,11 @@ static int moxtet_gpio_direction_output(struct gpio_chip *gc,
struct moxtet_gpio_chip *chip = gpiochip_get_data(gc);

if (chip->desc->out_mask & BIT(offset))
moxtet_gpio_set_value(gc, offset, val);
return moxtet_gpio_set_value(gc, offset, val);
else if (chip->desc->in_mask & BIT(offset))
return -ENOTSUPP;
else
return -EINVAL;

return 0;
return -EINVAL;
}

static int moxtet_gpio_probe(struct device *dev)
Expand Down Expand Up @@ -142,7 +140,7 @@ static int moxtet_gpio_probe(struct device *dev)
chip->gpio_chip.direction_input = moxtet_gpio_direction_input;
chip->gpio_chip.direction_output = moxtet_gpio_direction_output;
chip->gpio_chip.get = moxtet_gpio_get_value;
chip->gpio_chip.set = moxtet_gpio_set_value;
chip->gpio_chip.set_rv = moxtet_gpio_set_value;
chip->gpio_chip.base = -1;

chip->gpio_chip.ngpio = MOXTET_GPIO_NGPIOS;
Expand Down
12 changes: 8 additions & 4 deletions drivers/gpio/gpio-mpc5200.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ __mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
out_8(&regs->wkup_dvo, chip->shadow_dvo);
}

static void
static int
mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
{
unsigned long flags;
Expand All @@ -81,6 +81,8 @@ mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
spin_unlock_irqrestore(&gpio_lock, flags);

pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);

return 0;
}

static int mpc52xx_wkup_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
Expand Down Expand Up @@ -151,7 +153,7 @@ static int mpc52xx_wkup_gpiochip_probe(struct platform_device *ofdev)
gc->direction_input = mpc52xx_wkup_gpio_dir_in;
gc->direction_output = mpc52xx_wkup_gpio_dir_out;
gc->get = mpc52xx_wkup_gpio_get;
gc->set = mpc52xx_wkup_gpio_set;
gc->set_rv = mpc52xx_wkup_gpio_set;

ret = of_mm_gpiochip_add_data(ofdev->dev.of_node, &chip->mmchip, chip);
if (ret)
Expand Down Expand Up @@ -228,7 +230,7 @@ __mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
out_be32(&regs->simple_dvo, chip->shadow_dvo);
}

static void
static int
mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
{
unsigned long flags;
Expand All @@ -240,6 +242,8 @@ mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
spin_unlock_irqrestore(&gpio_lock, flags);

pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);

return 0;
}

static int mpc52xx_simple_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
Expand Down Expand Up @@ -311,7 +315,7 @@ static int mpc52xx_simple_gpiochip_probe(struct platform_device *ofdev)
gc->direction_input = mpc52xx_simple_gpio_dir_in;
gc->direction_output = mpc52xx_simple_gpio_dir_out;
gc->get = mpc52xx_simple_gpio_get;
gc->set = mpc52xx_simple_gpio_set;
gc->set_rv = mpc52xx_simple_gpio_set;

ret = of_mm_gpiochip_add_data(ofdev->dev.of_node, &chip->mmchip, chip);
if (ret)
Expand Down
11 changes: 7 additions & 4 deletions drivers/gpio/gpio-mpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,19 @@ static int mpfs_gpio_get(struct gpio_chip *gc, unsigned int gpio_index)
return regmap_test_bits(mpfs_gpio->regs, mpfs_gpio->offsets->inp, BIT(gpio_index));
}

static void mpfs_gpio_set(struct gpio_chip *gc, unsigned int gpio_index, int value)
static int mpfs_gpio_set(struct gpio_chip *gc, unsigned int gpio_index, int value)
{
struct mpfs_gpio_chip *mpfs_gpio = gpiochip_get_data(gc);
int ret;

mpfs_gpio_get(gc, gpio_index);

regmap_update_bits(mpfs_gpio->regs, mpfs_gpio->offsets->outp, BIT(gpio_index),
value << gpio_index);
ret = regmap_update_bits(mpfs_gpio->regs, mpfs_gpio->offsets->outp,
BIT(gpio_index), value << gpio_index);

mpfs_gpio_get(gc, gpio_index);

return ret;
}

static int mpfs_gpio_probe(struct platform_device *pdev)
Expand Down Expand Up @@ -147,7 +150,7 @@ static int mpfs_gpio_probe(struct platform_device *pdev)
mpfs_gpio->gc.direction_output = mpfs_gpio_direction_output;
mpfs_gpio->gc.get_direction = mpfs_gpio_get_direction;
mpfs_gpio->gc.get = mpfs_gpio_get;
mpfs_gpio->gc.set = mpfs_gpio_set;
mpfs_gpio->gc.set_rv = mpfs_gpio_set;
mpfs_gpio->gc.base = -1;
mpfs_gpio->gc.ngpio = ngpios;
mpfs_gpio->gc.label = dev_name(dev);
Expand Down
22 changes: 10 additions & 12 deletions drivers/gpio/gpio-mpsse.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ static int gpio_mpsse_get_bank(struct mpsse_priv *priv, u8 bank)
return buf;
}

static void gpio_mpsse_set_multiple(struct gpio_chip *chip, unsigned long *mask,
unsigned long *bits)
static int gpio_mpsse_set_multiple(struct gpio_chip *chip, unsigned long *mask,
unsigned long *bits)
{
unsigned long i, bank, bank_mask, bank_bits;
int ret;
Expand All @@ -180,11 +180,11 @@ static void gpio_mpsse_set_multiple(struct gpio_chip *chip, unsigned long *mask,

ret = gpio_mpsse_set_bank(priv, bank);
if (ret)
dev_err(&priv->intf->dev,
"Couldn't set values for bank %ld!",
bank);
return ret;
}
}

return 0;
}

static int gpio_mpsse_get_multiple(struct gpio_chip *chip, unsigned long *mask,
Expand Down Expand Up @@ -227,7 +227,7 @@ static int gpio_mpsse_gpio_get(struct gpio_chip *chip, unsigned int offset)
return 0;
}

static void gpio_mpsse_gpio_set(struct gpio_chip *chip, unsigned int offset,
static int gpio_mpsse_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
unsigned long mask = 0, bits = 0;
Expand All @@ -236,7 +236,7 @@ static void gpio_mpsse_gpio_set(struct gpio_chip *chip, unsigned int offset,
if (value)
__set_bit(offset, &bits);

gpio_mpsse_set_multiple(chip, &mask, &bits);
return gpio_mpsse_set_multiple(chip, &mask, &bits);
}

static int gpio_mpsse_direction_output(struct gpio_chip *chip,
Expand All @@ -249,9 +249,7 @@ static int gpio_mpsse_direction_output(struct gpio_chip *chip,
scoped_guard(mutex, &priv->io_mutex)
priv->gpio_dir[bank] |= BIT(bank_offset);

gpio_mpsse_gpio_set(chip, offset, value);

return 0;
return gpio_mpsse_gpio_set(chip, offset, value);
}

static int gpio_mpsse_direction_input(struct gpio_chip *chip,
Expand Down Expand Up @@ -450,9 +448,9 @@ static int gpio_mpsse_probe(struct usb_interface *interface,
priv->gpio.direction_input = gpio_mpsse_direction_input;
priv->gpio.direction_output = gpio_mpsse_direction_output;
priv->gpio.get = gpio_mpsse_gpio_get;
priv->gpio.set = gpio_mpsse_gpio_set;
priv->gpio.set_rv = gpio_mpsse_gpio_set;
priv->gpio.get_multiple = gpio_mpsse_get_multiple;
priv->gpio.set_multiple = gpio_mpsse_set_multiple;
priv->gpio.set_multiple_rv = gpio_mpsse_set_multiple;
priv->gpio.base = -1;
priv->gpio.ngpio = 16;
priv->gpio.offset = priv->intf_id * priv->gpio.ngpio;
Expand Down
Loading
Loading