Commit 71479789 authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Linus Walleij

gpio: rename gpio_set_drive_single_ended() to gpio_set_config()

This commit simply renames gpio_set_drive_single_ended() to
gpio_set_config(), as the function is not specific to setting the GPIO
drive type, and will be used for other purposes in followup commits.

In addition, it moves the function above gpiod_direction_input(), as
it will be used from gpiod_direction_input().
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ede033e1
...@@ -2518,6 +2518,14 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc); ...@@ -2518,6 +2518,14 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc);
* rely on gpio_request() having been called beforehand. * rely on gpio_request() having been called beforehand.
*/ */
static int gpio_set_config(struct gpio_chip *gc, unsigned offset,
enum pin_config_param mode)
{
unsigned long config = { PIN_CONF_PACKED(mode, 0) };
return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP;
}
/** /**
* gpiod_direction_input - set the GPIO direction to input * gpiod_direction_input - set the GPIO direction to input
* @desc: GPIO to set to input * @desc: GPIO to set to input
...@@ -2571,14 +2579,6 @@ int gpiod_direction_input(struct gpio_desc *desc) ...@@ -2571,14 +2579,6 @@ int gpiod_direction_input(struct gpio_desc *desc)
} }
EXPORT_SYMBOL_GPL(gpiod_direction_input); EXPORT_SYMBOL_GPL(gpiod_direction_input);
static int gpio_set_drive_single_ended(struct gpio_chip *gc, unsigned offset,
enum pin_config_param mode)
{
unsigned long config = { PIN_CONF_PACKED(mode, 0) };
return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP;
}
static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value) static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value)
{ {
struct gpio_chip *gc = desc->gdev->chip; struct gpio_chip *gc = desc->gdev->chip;
...@@ -2675,8 +2675,8 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) ...@@ -2675,8 +2675,8 @@ 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_drive_single_ended(gc, gpio_chip_hwgpio(desc), ret = gpio_set_config(gc, gpio_chip_hwgpio(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 */
...@@ -2684,16 +2684,16 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) ...@@ -2684,16 +2684,16 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
return gpiod_direction_input(desc); return gpiod_direction_input(desc);
} }
else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) { else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) {
ret = gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc), ret = gpio_set_config(gc, gpio_chip_hwgpio(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 */
if (!value) if (!value)
return gpiod_direction_input(desc); return gpiod_direction_input(desc);
} else { } else {
gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc), gpio_set_config(gc, gpio_chip_hwgpio(desc),
PIN_CONFIG_DRIVE_PUSH_PULL); PIN_CONFIG_DRIVE_PUSH_PULL);
} }
set_output_value: set_output_value:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment