Commit 5b68cc2d authored by Linus Walleij's avatar Linus Walleij

gpio: palmas: 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: Andrew Chew <achew@nvidia.com>
Cc: Stephen Warren <swarren@nvidia.com>
Acked-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent d99f7aec
...@@ -35,14 +35,9 @@ struct palmas_device_data { ...@@ -35,14 +35,9 @@ struct palmas_device_data {
int ngpio; int ngpio;
}; };
static inline struct palmas_gpio *to_palmas_gpio(struct gpio_chip *chip)
{
return container_of(chip, struct palmas_gpio, gpio_chip);
}
static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset)
{ {
struct palmas_gpio *pg = to_palmas_gpio(gc); struct palmas_gpio *pg = gpiochip_get_data(gc);
struct palmas *palmas = pg->palmas; struct palmas *palmas = pg->palmas;
unsigned int val; unsigned int val;
int ret; int ret;
...@@ -74,7 +69,7 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) ...@@ -74,7 +69,7 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset)
static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset,
int value) int value)
{ {
struct palmas_gpio *pg = to_palmas_gpio(gc); struct palmas_gpio *pg = gpiochip_get_data(gc);
struct palmas *palmas = pg->palmas; struct palmas *palmas = pg->palmas;
int ret; int ret;
unsigned int reg; unsigned int reg;
...@@ -96,7 +91,7 @@ static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, ...@@ -96,7 +91,7 @@ static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset,
static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset,
int value) int value)
{ {
struct palmas_gpio *pg = to_palmas_gpio(gc); struct palmas_gpio *pg = gpiochip_get_data(gc);
struct palmas *palmas = pg->palmas; struct palmas *palmas = pg->palmas;
int ret; int ret;
unsigned int reg; unsigned int reg;
...@@ -118,7 +113,7 @@ static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, ...@@ -118,7 +113,7 @@ static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset,
static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset)
{ {
struct palmas_gpio *pg = to_palmas_gpio(gc); struct palmas_gpio *pg = gpiochip_get_data(gc);
struct palmas *palmas = pg->palmas; struct palmas *palmas = pg->palmas;
int ret; int ret;
unsigned int reg; unsigned int reg;
...@@ -136,7 +131,7 @@ static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) ...@@ -136,7 +131,7 @@ static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset)
static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset) static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
{ {
struct palmas_gpio *pg = to_palmas_gpio(gc); struct palmas_gpio *pg = gpiochip_get_data(gc);
struct palmas *palmas = pg->palmas; struct palmas *palmas = pg->palmas;
return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset); return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset);
...@@ -200,7 +195,7 @@ static int palmas_gpio_probe(struct platform_device *pdev) ...@@ -200,7 +195,7 @@ static int palmas_gpio_probe(struct platform_device *pdev)
else else
palmas_gpio->gpio_chip.base = -1; palmas_gpio->gpio_chip.base = -1;
ret = gpiochip_add(&palmas_gpio->gpio_chip); ret = gpiochip_add_data(&palmas_gpio->gpio_chip, palmas_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