mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
pinctrl: cirrus: lochnagar: 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. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/20250612-gpiochip-set-rv-pinctrl-cirrus-v1-1-2d45c1f92557@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
5b797bcc00
commit
76ba1bb25c
1 changed files with 13 additions and 12 deletions
|
|
@ -1058,13 +1058,12 @@ static const struct pinctrl_desc lochnagar_pin_desc = {
|
|||
.confops = &lochnagar_pin_conf_ops,
|
||||
};
|
||||
|
||||
static void lochnagar_gpio_set(struct gpio_chip *chip,
|
||||
static int lochnagar_gpio_set(struct gpio_chip *chip,
|
||||
unsigned int offset, int value)
|
||||
{
|
||||
struct lochnagar_pin_priv *priv = gpiochip_get_data(chip);
|
||||
struct lochnagar *lochnagar = priv->lochnagar;
|
||||
const struct lochnagar_pin *pin = priv->pins[offset].drv_data;
|
||||
int ret;
|
||||
|
||||
value = !!value;
|
||||
|
||||
|
|
@ -1075,29 +1074,31 @@ static void lochnagar_gpio_set(struct gpio_chip *chip,
|
|||
case LN_PTYPE_MUX:
|
||||
value |= LN2_OP_GPIO;
|
||||
|
||||
ret = lochnagar_pin_set_mux(priv, pin, value);
|
||||
return lochnagar_pin_set_mux(priv, pin, value);
|
||||
break;
|
||||
case LN_PTYPE_GPIO:
|
||||
if (pin->invert)
|
||||
value = !value;
|
||||
|
||||
ret = regmap_update_bits(lochnagar->regmap, pin->reg,
|
||||
BIT(pin->shift), value << pin->shift);
|
||||
return regmap_update_bits(lochnagar->regmap, pin->reg,
|
||||
BIT(pin->shift),
|
||||
value << pin->shift);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
dev_err(chip->parent, "Failed to set %s value: %d\n",
|
||||
pin->name, ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int lochnagar_gpio_direction_out(struct gpio_chip *chip,
|
||||
unsigned int offset, int value)
|
||||
{
|
||||
lochnagar_gpio_set(chip, offset, value);
|
||||
int ret;
|
||||
|
||||
ret = lochnagar_gpio_set(chip, offset, value);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return pinctrl_gpio_direction_output(chip, offset);
|
||||
}
|
||||
|
|
@ -1160,7 +1161,7 @@ static int lochnagar_pin_probe(struct platform_device *pdev)
|
|||
priv->gpio_chip.request = gpiochip_generic_request;
|
||||
priv->gpio_chip.free = gpiochip_generic_free;
|
||||
priv->gpio_chip.direction_output = lochnagar_gpio_direction_out;
|
||||
priv->gpio_chip.set = lochnagar_gpio_set;
|
||||
priv->gpio_chip.set_rv = lochnagar_gpio_set;
|
||||
priv->gpio_chip.can_sleep = true;
|
||||
priv->gpio_chip.parent = dev;
|
||||
priv->gpio_chip.base = -1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue