Commit 0788b644 authored by Linus Walleij's avatar Linus Walleij

gpio: max732x: 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: Nicholas Krause <xerofoify@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Semen Protsenko <semen.protsenko@globallogic.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 5e45e019
...@@ -158,11 +158,6 @@ struct max732x_chip { ...@@ -158,11 +158,6 @@ struct max732x_chip {
#endif #endif
}; };
static inline struct max732x_chip *to_max732x(struct gpio_chip *gc)
{
return container_of(gc, struct max732x_chip, gpio_chip);
}
static int max732x_writeb(struct max732x_chip *chip, int group_a, uint8_t val) static int max732x_writeb(struct max732x_chip *chip, int group_a, uint8_t val)
{ {
struct i2c_client *client; struct i2c_client *client;
...@@ -201,7 +196,7 @@ static inline int is_group_a(struct max732x_chip *chip, unsigned off) ...@@ -201,7 +196,7 @@ static inline int is_group_a(struct max732x_chip *chip, unsigned off)
static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off)
{ {
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
uint8_t reg_val; uint8_t reg_val;
int ret; int ret;
...@@ -215,7 +210,7 @@ static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) ...@@ -215,7 +210,7 @@ static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off)
static void max732x_gpio_set_mask(struct gpio_chip *gc, unsigned off, int mask, static void max732x_gpio_set_mask(struct gpio_chip *gc, unsigned off, int mask,
int val) int val)
{ {
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
uint8_t reg_out; uint8_t reg_out;
int ret; int ret;
...@@ -259,7 +254,7 @@ static void max732x_gpio_set_multiple(struct gpio_chip *gc, ...@@ -259,7 +254,7 @@ static void max732x_gpio_set_multiple(struct gpio_chip *gc,
static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off) static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off)
{ {
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
unsigned int mask = 1u << off; unsigned int mask = 1u << off;
if ((mask & chip->dir_input) == 0) { if ((mask & chip->dir_input) == 0) {
...@@ -281,7 +276,7 @@ static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off) ...@@ -281,7 +276,7 @@ static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off)
static int max732x_gpio_direction_output(struct gpio_chip *gc, static int max732x_gpio_direction_output(struct gpio_chip *gc,
unsigned off, int val) unsigned off, int val)
{ {
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
unsigned int mask = 1u << off; unsigned int mask = 1u << off;
if ((mask & chip->dir_output) == 0) { if ((mask & chip->dir_output) == 0) {
...@@ -356,7 +351,7 @@ static void max732x_irq_update_mask(struct max732x_chip *chip) ...@@ -356,7 +351,7 @@ static void max732x_irq_update_mask(struct max732x_chip *chip)
static void max732x_irq_mask(struct irq_data *d) static void max732x_irq_mask(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
chip->irq_mask_cur &= ~(1 << d->hwirq); chip->irq_mask_cur &= ~(1 << d->hwirq);
} }
...@@ -364,7 +359,7 @@ static void max732x_irq_mask(struct irq_data *d) ...@@ -364,7 +359,7 @@ static void max732x_irq_mask(struct irq_data *d)
static void max732x_irq_unmask(struct irq_data *d) static void max732x_irq_unmask(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
chip->irq_mask_cur |= 1 << d->hwirq; chip->irq_mask_cur |= 1 << d->hwirq;
} }
...@@ -372,7 +367,7 @@ static void max732x_irq_unmask(struct irq_data *d) ...@@ -372,7 +367,7 @@ static void max732x_irq_unmask(struct irq_data *d)
static void max732x_irq_bus_lock(struct irq_data *d) static void max732x_irq_bus_lock(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
mutex_lock(&chip->irq_lock); mutex_lock(&chip->irq_lock);
chip->irq_mask_cur = chip->irq_mask; chip->irq_mask_cur = chip->irq_mask;
...@@ -381,7 +376,7 @@ static void max732x_irq_bus_lock(struct irq_data *d) ...@@ -381,7 +376,7 @@ static void max732x_irq_bus_lock(struct irq_data *d)
static void max732x_irq_bus_sync_unlock(struct irq_data *d) static void max732x_irq_bus_sync_unlock(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
uint16_t new_irqs; uint16_t new_irqs;
uint16_t level; uint16_t level;
...@@ -400,7 +395,7 @@ static void max732x_irq_bus_sync_unlock(struct irq_data *d) ...@@ -400,7 +395,7 @@ static void max732x_irq_bus_sync_unlock(struct irq_data *d)
static int max732x_irq_set_type(struct irq_data *d, unsigned int type) static int max732x_irq_set_type(struct irq_data *d, unsigned int type)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct max732x_chip *chip = to_max732x(gc); struct max732x_chip *chip = gpiochip_get_data(gc);
uint16_t off = d->hwirq; uint16_t off = d->hwirq;
uint16_t mask = 1 << off; uint16_t mask = 1 << off;
...@@ -694,7 +689,7 @@ static int max732x_probe(struct i2c_client *client, ...@@ -694,7 +689,7 @@ static int max732x_probe(struct i2c_client *client,
goto out_failed; goto out_failed;
} }
ret = gpiochip_add(&chip->gpio_chip); ret = gpiochip_add_data(&chip->gpio_chip, chip);
if (ret) if (ret)
goto out_failed; goto out_failed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment