Skip to content

Commit fa10247

Browse files
Bartosz GolaszewskiLinus Walleij
authored andcommitted
pinctrl: axp209: 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: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/20250424-gpiochip-set-rv-pinctrl-part2-v1-2-504f91120b99@linaro.org [Drop unnecessary curly braces] Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent ec08e2c commit fa10247

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

drivers/pinctrl/pinctrl-axp209.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -192,34 +192,30 @@ static int axp20x_gpio_get_direction(struct gpio_chip *chip,
192192
static int axp20x_gpio_output(struct gpio_chip *chip, unsigned int offset,
193193
int value)
194194
{
195-
chip->set(chip, offset, value);
196-
197-
return 0;
195+
return chip->set_rv(chip, offset, value);
198196
}
199197

200-
static void axp20x_gpio_set(struct gpio_chip *chip, unsigned int offset,
201-
int value)
198+
static int axp20x_gpio_set(struct gpio_chip *chip, unsigned int offset,
199+
int value)
202200
{
203201
struct axp20x_pctl *pctl = gpiochip_get_data(chip);
204202
int reg;
205203

206204
/* AXP209 has GPIO3 status sharing the settings register */
207-
if (offset == 3) {
208-
regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL,
209-
AXP20X_GPIO3_FUNCTIONS,
210-
value ? AXP20X_GPIO3_FUNCTION_OUT_HIGH :
211-
AXP20X_GPIO3_FUNCTION_OUT_LOW);
212-
return;
213-
}
205+
if (offset == 3)
206+
return regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL,
207+
AXP20X_GPIO3_FUNCTIONS,
208+
value ?
209+
AXP20X_GPIO3_FUNCTION_OUT_HIGH :
210+
AXP20X_GPIO3_FUNCTION_OUT_LOW);
214211

215212
reg = axp20x_gpio_get_reg(offset);
216213
if (reg < 0)
217-
return;
214+
return reg;
218215

219-
regmap_update_bits(pctl->regmap, reg,
220-
AXP20X_GPIO_FUNCTIONS,
221-
value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
222-
AXP20X_GPIO_FUNCTION_OUT_LOW);
216+
return regmap_update_bits(pctl->regmap, reg, AXP20X_GPIO_FUNCTIONS,
217+
value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
218+
AXP20X_GPIO_FUNCTION_OUT_LOW);
223219
}
224220

225221
static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
@@ -229,12 +225,11 @@ static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
229225
int reg;
230226

231227
/* AXP209 GPIO3 settings have a different layout */
232-
if (offset == 3) {
228+
if (offset == 3)
233229
return regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL,
234230
AXP20X_GPIO3_FUNCTIONS,
235231
config == AXP20X_MUX_GPIO_OUT ? AXP20X_GPIO3_FUNCTION_OUT_LOW :
236232
AXP20X_GPIO3_FUNCTION_INPUT);
237-
}
238233

239234
reg = axp20x_gpio_get_reg(offset);
240235
if (reg < 0)
@@ -468,7 +463,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
468463
pctl->chip.owner = THIS_MODULE;
469464
pctl->chip.get = axp20x_gpio_get;
470465
pctl->chip.get_direction = axp20x_gpio_get_direction;
471-
pctl->chip.set = axp20x_gpio_set;
466+
pctl->chip.set_rv = axp20x_gpio_set;
472467
pctl->chip.direction_input = pinctrl_gpio_direction_input;
473468
pctl->chip.direction_output = axp20x_gpio_output;
474469

0 commit comments

Comments
 (0)