Commit 94a90370 authored by Linus Walleij's avatar Linus Walleij

gpio: tps6586x: 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().
Acked-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 92a41e2f
...@@ -38,14 +38,9 @@ struct tps6586x_gpio { ...@@ -38,14 +38,9 @@ struct tps6586x_gpio {
struct device *parent; struct device *parent;
}; };
static inline struct tps6586x_gpio *to_tps6586x_gpio(struct gpio_chip *chip)
{
return container_of(chip, struct tps6586x_gpio, gpio_chip);
}
static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset) static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
{ {
struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
uint8_t val; uint8_t val;
int ret; int ret;
...@@ -59,7 +54,7 @@ static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset) ...@@ -59,7 +54,7 @@ static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset, static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset,
int value) int value)
{ {
struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2, tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2,
value << offset, 1 << offset); value << offset, 1 << offset);
...@@ -68,7 +63,7 @@ static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset, ...@@ -68,7 +63,7 @@ static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset,
static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset, static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
int value) int value)
{ {
struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
uint8_t val, mask; uint8_t val, mask;
tps6586x_gpio_set(gc, offset, value); tps6586x_gpio_set(gc, offset, value);
...@@ -82,7 +77,7 @@ static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset, ...@@ -82,7 +77,7 @@ static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
static int tps6586x_gpio_to_irq(struct gpio_chip *gc, unsigned offset) static int tps6586x_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
{ {
struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
return tps6586x_irq_get_virq(tps6586x_gpio->parent, return tps6586x_irq_get_virq(tps6586x_gpio->parent,
TPS6586X_INT_PLDO_0 + offset); TPS6586X_INT_PLDO_0 + offset);
...@@ -122,7 +117,7 @@ static int tps6586x_gpio_probe(struct platform_device *pdev) ...@@ -122,7 +117,7 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
else else
tps6586x_gpio->gpio_chip.base = -1; tps6586x_gpio->gpio_chip.base = -1;
ret = gpiochip_add(&tps6586x_gpio->gpio_chip); ret = gpiochip_add_data(&tps6586x_gpio->gpio_chip, tps6586x_gpio);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret; return ret;
......
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