mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
hwmon: (ltc2992) Use new GPIO line value setter callbacks
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Link: https://lore.kernel.org/r/20250407-gpiochip-set-rv-hwmon-v1-1-1fa38f34dc07@linaro.org Reviewed-by: Linus Walleij <linus.walleij@linaro.org> [groeck: Fixed multi-line alignment issue] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
73e5b6b51f
commit
e894b6442a
|
@ -256,33 +256,38 @@ static int ltc2992_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void ltc2992_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
static int ltc2992_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct ltc2992_state *st = gpiochip_get_data(chip);
|
||||
unsigned long gpio_ctrl;
|
||||
int reg;
|
||||
int reg, ret;
|
||||
|
||||
mutex_lock(&st->gpio_mutex);
|
||||
reg = ltc2992_read_reg(st, ltc2992_gpio_addr_map[offset].ctrl, 1);
|
||||
if (reg < 0) {
|
||||
mutex_unlock(&st->gpio_mutex);
|
||||
return;
|
||||
return reg;
|
||||
}
|
||||
|
||||
gpio_ctrl = reg;
|
||||
assign_bit(ltc2992_gpio_addr_map[offset].ctrl_bit, &gpio_ctrl, value);
|
||||
|
||||
ltc2992_write_reg(st, ltc2992_gpio_addr_map[offset].ctrl, 1, gpio_ctrl);
|
||||
ret = ltc2992_write_reg(st, ltc2992_gpio_addr_map[offset].ctrl, 1,
|
||||
gpio_ctrl);
|
||||
mutex_unlock(&st->gpio_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ltc2992_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask,
|
||||
unsigned long *bits)
|
||||
static int ltc2992_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask,
|
||||
unsigned long *bits)
|
||||
{
|
||||
struct ltc2992_state *st = gpiochip_get_data(chip);
|
||||
unsigned long gpio_ctrl_io = 0;
|
||||
unsigned long gpio_ctrl = 0;
|
||||
unsigned int gpio_nr;
|
||||
int ret;
|
||||
|
||||
for_each_set_bit(gpio_nr, mask, LTC2992_GPIO_NR) {
|
||||
if (gpio_nr < 3)
|
||||
|
@ -293,9 +298,14 @@ static void ltc2992_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mas
|
|||
}
|
||||
|
||||
mutex_lock(&st->gpio_mutex);
|
||||
ltc2992_write_reg(st, LTC2992_GPIO_IO_CTRL, 1, gpio_ctrl_io);
|
||||
ltc2992_write_reg(st, LTC2992_GPIO_CTRL, 1, gpio_ctrl);
|
||||
ret = ltc2992_write_reg(st, LTC2992_GPIO_IO_CTRL, 1, gpio_ctrl_io);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = ltc2992_write_reg(st, LTC2992_GPIO_CTRL, 1, gpio_ctrl);
|
||||
out:
|
||||
mutex_unlock(&st->gpio_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ltc2992_config_gpio(struct ltc2992_state *st)
|
||||
|
@ -329,8 +339,8 @@ static int ltc2992_config_gpio(struct ltc2992_state *st)
|
|||
st->gc.ngpio = ARRAY_SIZE(st->gpio_names);
|
||||
st->gc.get = ltc2992_gpio_get;
|
||||
st->gc.get_multiple = ltc2992_gpio_get_multiple;
|
||||
st->gc.set = ltc2992_gpio_set;
|
||||
st->gc.set_multiple = ltc2992_gpio_set_multiple;
|
||||
st->gc.set_rv = ltc2992_gpio_set;
|
||||
st->gc.set_multiple_rv = ltc2992_gpio_set_multiple;
|
||||
|
||||
ret = devm_gpiochip_add_data(&st->client->dev, &st->gc, st);
|
||||
if (ret)
|
||||
|
|
Loading…
Reference in New Issue
Block a user