mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
gpio: regmap: Use regmap_test_bits() for single bit reads
Use regmap_test_bits() when reading a single GPIO value from a normal register and when reading the direction bit. Reviewed-by: Linus Walleij <linusw@kernel.org> Reviewed-by: Michael Walle <mwalle@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Janani Sunil <janani.sunil@analog.com> Link: https://patch.msgid.link/20260910-ad7768-gpio-v8-1-6aaaa15adeb3@analog.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
parent
4bfe5b08a5
commit
a4319947b5
|
|
@ -95,11 +95,11 @@ static int gpio_regmap_get(struct gpio_chip *chip, unsigned int offset)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (gpio->reg_dat_base != gpio->reg_set_base)
|
||||
return regmap_test_bits(gpio->regmap, reg, mask);
|
||||
|
||||
/* ensure we don't spoil any register cache with pin input values */
|
||||
if (gpio->reg_dat_base == gpio->reg_set_base)
|
||||
ret = regmap_read_bypassed(gpio->regmap, reg, &val);
|
||||
else
|
||||
ret = regmap_read(gpio->regmap, reg, &val);
|
||||
ret = regmap_read_bypassed(gpio->regmap, reg, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,
|
|||
unsigned int offset)
|
||||
{
|
||||
struct gpio_regmap *gpio = gpiochip_get_data(chip);
|
||||
unsigned int base, val, reg, mask;
|
||||
unsigned int base, reg, mask;
|
||||
int invert, ret;
|
||||
|
||||
if (gpio_regmap_fixed_direction(gpio, offset)) {
|
||||
|
|
@ -212,14 +212,14 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = regmap_read(gpio->regmap, reg, &val);
|
||||
if (ret)
|
||||
ret = regmap_test_bits(gpio->regmap, reg, mask);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (!!(val & mask) ^ invert)
|
||||
if (ret ^ invert)
|
||||
return GPIO_LINE_DIRECTION_OUT;
|
||||
else
|
||||
return GPIO_LINE_DIRECTION_IN;
|
||||
|
||||
return GPIO_LINE_DIRECTION_IN;
|
||||
}
|
||||
|
||||
static int gpio_regmap_try_direction_fixed(struct gpio_regmap *gpio,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user