Commit 552dd795 authored by Linus Walleij's avatar Linus Walleij

gpio: da9055: 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: Ashish Jangam <ashish.jangam@kpitcummins.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 0f6082d2
...@@ -35,14 +35,9 @@ struct da9055_gpio { ...@@ -35,14 +35,9 @@ struct da9055_gpio {
struct gpio_chip gp; struct gpio_chip gp;
}; };
static inline struct da9055_gpio *to_da9055_gpio(struct gpio_chip *chip)
{
return container_of(chip, struct da9055_gpio, gp);
}
static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset) static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset)
{ {
struct da9055_gpio *gpio = to_da9055_gpio(gc); struct da9055_gpio *gpio = gpiochip_get_data(gc);
int gpio_direction = 0; int gpio_direction = 0;
int ret; int ret;
...@@ -71,7 +66,7 @@ static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset) ...@@ -71,7 +66,7 @@ static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset)
static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value) static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
{ {
struct da9055_gpio *gpio = to_da9055_gpio(gc); struct da9055_gpio *gpio = gpiochip_get_data(gc);
da9055_reg_update(gpio->da9055, da9055_reg_update(gpio->da9055,
DA9055_REG_GPIO_MODE0_2, DA9055_REG_GPIO_MODE0_2,
...@@ -81,7 +76,7 @@ static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value) ...@@ -81,7 +76,7 @@ static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset) static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
{ {
struct da9055_gpio *gpio = to_da9055_gpio(gc); struct da9055_gpio *gpio = gpiochip_get_data(gc);
unsigned char reg_byte; unsigned char reg_byte;
reg_byte = (DA9055_ACT_LOW | DA9055_GPI) reg_byte = (DA9055_ACT_LOW | DA9055_GPI)
...@@ -97,7 +92,7 @@ static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset) ...@@ -97,7 +92,7 @@ static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
static int da9055_gpio_direction_output(struct gpio_chip *gc, static int da9055_gpio_direction_output(struct gpio_chip *gc,
unsigned offset, int value) unsigned offset, int value)
{ {
struct da9055_gpio *gpio = to_da9055_gpio(gc); struct da9055_gpio *gpio = gpiochip_get_data(gc);
unsigned char reg_byte; unsigned char reg_byte;
int ret; int ret;
...@@ -119,7 +114,7 @@ static int da9055_gpio_direction_output(struct gpio_chip *gc, ...@@ -119,7 +114,7 @@ static int da9055_gpio_direction_output(struct gpio_chip *gc,
static int da9055_gpio_to_irq(struct gpio_chip *gc, u32 offset) static int da9055_gpio_to_irq(struct gpio_chip *gc, u32 offset)
{ {
struct da9055_gpio *gpio = to_da9055_gpio(gc); struct da9055_gpio *gpio = gpiochip_get_data(gc);
struct da9055 *da9055 = gpio->da9055; struct da9055 *da9055 = gpio->da9055;
return regmap_irq_get_virq(da9055->irq_data, return regmap_irq_get_virq(da9055->irq_data,
...@@ -156,7 +151,7 @@ static int da9055_gpio_probe(struct platform_device *pdev) ...@@ -156,7 +151,7 @@ static int da9055_gpio_probe(struct platform_device *pdev)
if (pdata && pdata->gpio_base) if (pdata && pdata->gpio_base)
gpio->gp.base = pdata->gpio_base; gpio->gp.base = pdata->gpio_base;
ret = gpiochip_add(&gpio->gp); ret = gpiochip_add_data(&gpio->gp, 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);
goto err_mem; goto err_mem;
......
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