mirror of https://gitee.com/openkylin/linux.git
avr32: gpio: use gpiochip data pointer
This makes the driver use the data pointer added to the gpio_chip to store a pointer to the state container instead of relying on container_of(). Cc: Haavard Skinnemoen <hskinnemoen@gmail.com> Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
11680af7c8
commit
95bf0951e4
|
@ -203,7 +203,7 @@ void __init at32_reserve_pin(unsigned int port, u32 pin_mask)
|
||||||
|
|
||||||
static int direction_input(struct gpio_chip *chip, unsigned offset)
|
static int direction_input(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
struct pio_device *pio = container_of(chip, struct pio_device, chip);
|
struct pio_device *pio = gpiochip_get_data(chip);
|
||||||
u32 mask = 1 << offset;
|
u32 mask = 1 << offset;
|
||||||
|
|
||||||
if (!(pio_readl(pio, PSR) & mask))
|
if (!(pio_readl(pio, PSR) & mask))
|
||||||
|
@ -215,7 +215,7 @@ static int direction_input(struct gpio_chip *chip, unsigned offset)
|
||||||
|
|
||||||
static int gpio_get(struct gpio_chip *chip, unsigned offset)
|
static int gpio_get(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
struct pio_device *pio = container_of(chip, struct pio_device, chip);
|
struct pio_device *pio = gpiochip_get_data(chip);
|
||||||
|
|
||||||
return (pio_readl(pio, PDSR) >> offset) & 1;
|
return (pio_readl(pio, PDSR) >> offset) & 1;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ static void gpio_set(struct gpio_chip *chip, unsigned offset, int value);
|
||||||
|
|
||||||
static int direction_output(struct gpio_chip *chip, unsigned offset, int value)
|
static int direction_output(struct gpio_chip *chip, unsigned offset, int value)
|
||||||
{
|
{
|
||||||
struct pio_device *pio = container_of(chip, struct pio_device, chip);
|
struct pio_device *pio = gpiochip_get_data(chip);
|
||||||
u32 mask = 1 << offset;
|
u32 mask = 1 << offset;
|
||||||
|
|
||||||
if (!(pio_readl(pio, PSR) & mask))
|
if (!(pio_readl(pio, PSR) & mask))
|
||||||
|
@ -237,7 +237,7 @@ static int direction_output(struct gpio_chip *chip, unsigned offset, int value)
|
||||||
|
|
||||||
static void gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
static void gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||||
{
|
{
|
||||||
struct pio_device *pio = container_of(chip, struct pio_device, chip);
|
struct pio_device *pio = gpiochip_get_data(chip);
|
||||||
u32 mask = 1 << offset;
|
u32 mask = 1 << offset;
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
|
@ -335,7 +335,7 @@ gpio_irq_setup(struct pio_device *pio, int irq, int gpio_irq)
|
||||||
*/
|
*/
|
||||||
static void pio_bank_show(struct seq_file *s, struct gpio_chip *chip)
|
static void pio_bank_show(struct seq_file *s, struct gpio_chip *chip)
|
||||||
{
|
{
|
||||||
struct pio_device *pio = container_of(chip, struct pio_device, chip);
|
struct pio_device *pio = gpiochip_get_data(chip);
|
||||||
u32 psr, osr, imr, pdsr, pusr, ifsr, mdsr;
|
u32 psr, osr, imr, pdsr, pusr, ifsr, mdsr;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
u32 mask;
|
u32 mask;
|
||||||
|
@ -406,7 +406,7 @@ static int __init pio_probe(struct platform_device *pdev)
|
||||||
pio->chip.set = gpio_set;
|
pio->chip.set = gpio_set;
|
||||||
pio->chip.dbg_show = pio_bank_show;
|
pio->chip.dbg_show = pio_bank_show;
|
||||||
|
|
||||||
gpiochip_add(&pio->chip);
|
gpiochip_add_data(&pio->chip, pio);
|
||||||
|
|
||||||
gpio_irq_setup(pio, irq, gpio_irq_base);
|
gpio_irq_setup(pio, irq, gpio_irq_base);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue