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);
|
return gc->set_config(gc, offset, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode)
|
||||||
enum pin_config_param mode)
|
|
||||||
{
|
{
|
||||||
|
struct gpio_chip *chip = desc->gdev->chip;
|
||||||
unsigned long config;
|
unsigned long config;
|
||||||
unsigned arg;
|
unsigned arg;
|
||||||
|
|
||||||
@ -3213,7 +3213,7 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
config = PIN_CONF_PACKED(mode, arg);
|
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)
|
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;
|
bias = PIN_CONFIG_BIAS_PULL_DOWN;
|
||||||
|
|
||||||
if (bias) {
|
if (bias) {
|
||||||
ret = gpio_set_config(chip, gpio_chip_hwgpio(desc), bias);
|
ret = gpio_set_config(desc, bias);
|
||||||
if (ret != -ENOTSUPP)
|
if (ret != -ENOTSUPP)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3387,8 +3387,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
|
|||||||
gc = desc->gdev->chip;
|
gc = desc->gdev->chip;
|
||||||
if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
|
if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
|
||||||
/* First see if we can enable open drain in hardware */
|
/* First see if we can enable open drain in hardware */
|
||||||
ret = gpio_set_config(gc, gpio_chip_hwgpio(desc),
|
ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_DRAIN);
|
||||||
PIN_CONFIG_DRIVE_OPEN_DRAIN);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
goto set_output_value;
|
goto set_output_value;
|
||||||
/* Emulate open drain by not actively driving the line high */
|
/* 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)) {
|
else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) {
|
||||||
ret = gpio_set_config(gc, gpio_chip_hwgpio(desc),
|
ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_SOURCE);
|
||||||
PIN_CONFIG_DRIVE_OPEN_SOURCE);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
goto set_output_value;
|
goto set_output_value;
|
||||||
/* Emulate open source by not actively driving the line low */
|
/* 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;
|
goto set_output_flag;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gpio_set_config(gc, gpio_chip_hwgpio(desc),
|
gpio_set_config(desc, PIN_CONFIG_DRIVE_PUSH_PULL);
|
||||||
PIN_CONFIG_DRIVE_PUSH_PULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_output_value:
|
set_output_value:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user