Message ID | 20250310-gpiochip-set-conversion-v1-4-03798bb833eb@linaro.org (mailing list archive) |
---|---|
State | New |
Delegated to: | Geert Uytterhoeven |
Headers | show |
Series | gpio: more gpio_chip setter conversions | expand |
On 10/03/2025 14:40, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > struct gpio_chip now has callbacks for setting line values that return > an integer, allowing to indicate failures. Convert the driver to using > them. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > --- > drivers/gpio/gpio-bd71828.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpio/gpio-bd71828.c b/drivers/gpio/gpio-bd71828.c > index b2ccc320c7b5..4ba151e5cf25 100644 > --- a/drivers/gpio/gpio-bd71828.c > +++ b/drivers/gpio/gpio-bd71828.c > @@ -16,10 +16,9 @@ struct bd71828_gpio { > struct gpio_chip gpio; > }; > > -static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, > - int value) > +static int bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, > + int value) > { > - int ret; > struct bd71828_gpio *bdgpio = gpiochip_get_data(chip); > u8 val = (value) ? BD71828_GPIO_OUT_HI : BD71828_GPIO_OUT_LO; > > @@ -28,12 +27,10 @@ static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, > * we are dealing with - then we are done > */ > if (offset == HALL_GPIO_OFFSET) > - return; > + return 0; Should this be -EINVAL (or, can this check be just dropped?) Value of an input pin is tried to be set. > > - ret = regmap_update_bits(bdgpio->regmap, GPIO_OUT_REG(offset), > - BD71828_GPIO_OUT_MASK, val); > - if (ret) > - dev_err(bdgpio->dev, "Could not set gpio to %d\n", value); > + return regmap_update_bits(bdgpio->regmap, GPIO_OUT_REG(offset), > + BD71828_GPIO_OUT_MASK, val); > } > > static int bd71828_gpio_get(struct gpio_chip *chip, unsigned int offset) > @@ -112,7 +109,7 @@ static int bd71828_probe(struct platform_device *pdev) > bdgpio->gpio.set_config = bd71828_gpio_set_config; > bdgpio->gpio.can_sleep = true; > bdgpio->gpio.get = bd71828_gpio_get; > - bdgpio->gpio.set = bd71828_gpio_set; > + bdgpio->gpio.set_rv = bd71828_gpio_set; > bdgpio->gpio.base = -1; > > /* >
On Mon, Mar 10, 2025 at 2:20 PM Matti Vaittinen <mazziesaccount@gmail.com> wrote: > > > @@ -28,12 +27,10 @@ static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, > > * we are dealing with - then we are done > > */ > > if (offset == HALL_GPIO_OFFSET) > > - return; > > + return 0; > > Should this be -EINVAL (or, can this check be just dropped?) Value of an > input pin is tried to be set. > I don't want to break existing users but I did notice that and figured that we should rather check this in core GPIO code not each individual driver. I put that on my TODO list. Bart
On 10/03/2025 15:22, Bartosz Golaszewski wrote: > On Mon, Mar 10, 2025 at 2:20 PM Matti Vaittinen > <mazziesaccount@gmail.com> wrote: >> >>> @@ -28,12 +27,10 @@ static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, >>> * we are dealing with - then we are done >>> */ >>> if (offset == HALL_GPIO_OFFSET) >>> - return; >>> + return 0; >> >> Should this be -EINVAL (or, can this check be just dropped?) Value of an >> input pin is tried to be set. >> > > I don't want to break existing users but I did notice that and figured > that we should rather check this in core GPIO code not each individual > driver. Makes sense :) Thanks! In that case, Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> > > I put that on my TODO list. > > Bart
diff --git a/drivers/gpio/gpio-bd71828.c b/drivers/gpio/gpio-bd71828.c index b2ccc320c7b5..4ba151e5cf25 100644 --- a/drivers/gpio/gpio-bd71828.c +++ b/drivers/gpio/gpio-bd71828.c @@ -16,10 +16,9 @@ struct bd71828_gpio { struct gpio_chip gpio; }; -static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, - int value) +static int bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, + int value) { - int ret; struct bd71828_gpio *bdgpio = gpiochip_get_data(chip); u8 val = (value) ? BD71828_GPIO_OUT_HI : BD71828_GPIO_OUT_LO; @@ -28,12 +27,10 @@ static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, * we are dealing with - then we are done */ if (offset == HALL_GPIO_OFFSET) - return; + return 0; - ret = regmap_update_bits(bdgpio->regmap, GPIO_OUT_REG(offset), - BD71828_GPIO_OUT_MASK, val); - if (ret) - dev_err(bdgpio->dev, "Could not set gpio to %d\n", value); + return regmap_update_bits(bdgpio->regmap, GPIO_OUT_REG(offset), + BD71828_GPIO_OUT_MASK, val); } static int bd71828_gpio_get(struct gpio_chip *chip, unsigned int offset) @@ -112,7 +109,7 @@ static int bd71828_probe(struct platform_device *pdev) bdgpio->gpio.set_config = bd71828_gpio_set_config; bdgpio->gpio.can_sleep = true; bdgpio->gpio.get = bd71828_gpio_get; - bdgpio->gpio.set = bd71828_gpio_set; + bdgpio->gpio.set_rv = bd71828_gpio_set; bdgpio->gpio.base = -1; /*