mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 20:46:48 +02:00
gpio: generic: provide helpers for reading and writing registers
Provide helpers wrapping the read_reg() and write_reg() callbacks of the generic GPIO API that are called directly by many users. This is done to hide their implementation ahead of moving them into the separate generic GPIO struct. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20250825-gpio-mmio-gpio-conv-v1-2-356b4b1d5110@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
6e376f245f
commit
16397871b6
|
|
@ -100,6 +100,37 @@ gpio_generic_chip_set(struct gpio_generic_chip *chip, unsigned int offset,
|
|||
return chip->gc.set(&chip->gc, offset, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* gpio_generic_read_reg() - Read a register using the underlying callback.
|
||||
* @chip: Generic GPIO chip to use.
|
||||
* @reg: Register to read.
|
||||
*
|
||||
* Returns: value read from register.
|
||||
*/
|
||||
static inline unsigned long
|
||||
gpio_generic_read_reg(struct gpio_generic_chip *chip, void __iomem *reg)
|
||||
{
|
||||
if (WARN_ON(!chip->gc.read_reg))
|
||||
return 0;
|
||||
|
||||
return chip->gc.read_reg(reg);
|
||||
}
|
||||
|
||||
/**
|
||||
* gpio_generic_write_reg() - Write a register using the underlying callback.
|
||||
* @chip: Generic GPIO chip to use.
|
||||
* @reg: Register to write to.
|
||||
* @val: New value to write.
|
||||
*/
|
||||
static inline void gpio_generic_write_reg(struct gpio_generic_chip *chip,
|
||||
void __iomem *reg, unsigned long val)
|
||||
{
|
||||
if (WARN_ON(!chip->gc.write_reg))
|
||||
return;
|
||||
|
||||
chip->gc.write_reg(reg, val);
|
||||
}
|
||||
|
||||
#define gpio_generic_chip_lock(gen_gc) \
|
||||
raw_spin_lock(&(gen_gc)->gc.bgpio_lock)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user