Skip to content

Commit

Permalink
gpiolib: Use proper type for bias enumerator in gpio_set_bias()
Browse files Browse the repository at this point in the history
First of all, bias has a special type as being a part of enum pin_config_param.
Second, 0 is also defined bias which is equivalent to BUS_HOLD.

Taking into account above, change type of bias variable and refactor
gpio_set_bias() in a way that it doesn't use BUS_HOLD as a place holder.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20201009184359.16427-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Andy Shevchenko authored and Linus Walleij committed Oct 28, 2020
1 parent 3650b22 commit 9ef6293
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,21 +2256,22 @@ static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode)

static int gpio_set_bias(struct gpio_desc *desc)
{
int bias = 0;
int ret = 0;
enum pin_config_param bias;
int ret;

if (test_bit(FLAG_BIAS_DISABLE, &desc->flags))
bias = PIN_CONFIG_BIAS_DISABLE;
else if (test_bit(FLAG_PULL_UP, &desc->flags))
bias = PIN_CONFIG_BIAS_PULL_UP;
else if (test_bit(FLAG_PULL_DOWN, &desc->flags))
bias = PIN_CONFIG_BIAS_PULL_DOWN;
else
return 0;

ret = gpio_set_config(desc, bias);
if (ret != -ENOTSUPP)
return ret;

if (bias) {
ret = gpio_set_config(desc, bias);
if (ret != -ENOTSUPP)
return ret;
}
return 0;
}

Expand Down

0 comments on commit 9ef6293

Please sign in to comment.