mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-16 10:37:01 +07:00
gpiolib: Pass gpio_desc to gpio_set_config()
All callers of gpio_set_config() have to convert a gpio_desc to a gpio_chip and offset. Avoid these duplicated conversion steps by letting gpio_set_config() take a gpio_desc pointer directly. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20200325100439.14000-2-geert+renesas@glider.be Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
8ced32ffad
commit
8352235843
@ -3196,9 +3196,9 @@ static int gpio_do_set_config(struct gpio_chip *gc, unsigned int offset,
|
||||
return gc->set_config(gc, offset, config);
|
||||
}
|
||||
|
||||
static int gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
||||
enum pin_config_param mode)
|
||||
static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode)
|
||||
{
|
||||
struct gpio_chip *chip = desc->gdev->chip;
|
||||
unsigned long config;
|
||||
unsigned arg;
|
||||
|
||||
@ -3213,7 +3213,7 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
||||
}
|
||||
|
||||
config = PIN_CONF_PACKED(mode, arg);
|
||||
return gpio_do_set_config(gc, offset, config);
|
||||
return gpio_do_set_config(chip, gpio_chip_hwgpio(desc), config);
|
||||
}
|
||||
|
||||
static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc)
|
||||
@ -3229,7 +3229,7 @@ static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc)
|
||||
bias = PIN_CONFIG_BIAS_PULL_DOWN;
|
||||
|
||||
if (bias) {
|
||||
ret = gpio_set_config(chip, gpio_chip_hwgpio(desc), bias);
|
||||
ret = gpio_set_config(desc, bias);
|
||||
if (ret != -ENOTSUPP)
|
||||
return ret;
|
||||
}
|
||||
@ -3387,8 +3387,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
|
||||
gc = desc->gdev->chip;
|
||||
if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
|
||||
/* First see if we can enable open drain in hardware */
|
||||
ret = gpio_set_config(gc, gpio_chip_hwgpio(desc),
|
||||
PIN_CONFIG_DRIVE_OPEN_DRAIN);
|
||||
ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_DRAIN);
|
||||
if (!ret)
|
||||
goto set_output_value;
|
||||
/* Emulate open drain by not actively driving the line high */
|
||||
@ -3398,8 +3397,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
|
||||
}
|
||||
}
|
||||
else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) {
|
||||
ret = gpio_set_config(gc, gpio_chip_hwgpio(desc),
|
||||
PIN_CONFIG_DRIVE_OPEN_SOURCE);
|
||||
ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_SOURCE);
|
||||
if (!ret)
|
||||
goto set_output_value;
|
||||
/* Emulate open source by not actively driving the line low */
|
||||
@ -3408,8 +3406,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
|
||||
goto set_output_flag;
|
||||
}
|
||||
} else {
|
||||
gpio_set_config(gc, gpio_chip_hwgpio(desc),
|
||||
PIN_CONFIG_DRIVE_PUSH_PULL);
|
||||
gpio_set_config(desc, PIN_CONFIG_DRIVE_PUSH_PULL);
|
||||
}
|
||||
|
||||
set_output_value:
|
||||
|
Loading…
Reference in New Issue
Block a user