aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-04 10:21:53 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-01-05 05:21:04 -0500
commit552dd7959c7d2c4f60ea4fc1f06985db76ec2beb (patch)
tree4a40f9c17e9bcbaf4d6285c5d52075af9a0aceb2
parent0f6082d2b811ec56c4f7ecdde80410e17cf04452 (diff)
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: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpio-da9055.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/gpio/gpio-da9055.c b/drivers/gpio/gpio-da9055.c
index 7227e6ed3cb9..18210fb2cb13 100644
--- a/drivers/gpio/gpio-da9055.c
+++ b/drivers/gpio/gpio-da9055.c
@@ -35,14 +35,9 @@ struct da9055_gpio {
35 struct gpio_chip gp; 35 struct gpio_chip gp;
36}; 36};
37 37
38static inline struct da9055_gpio *to_da9055_gpio(struct gpio_chip *chip)
39{
40 return container_of(chip, struct da9055_gpio, gp);
41}
42
43static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset) 38static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset)
44{ 39{
45 struct da9055_gpio *gpio = to_da9055_gpio(gc); 40 struct da9055_gpio *gpio = gpiochip_get_data(gc);
46 int gpio_direction = 0; 41 int gpio_direction = 0;
47 int ret; 42 int ret;
48 43
@@ -71,7 +66,7 @@ static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset)
71 66
72static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value) 67static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
73{ 68{
74 struct da9055_gpio *gpio = to_da9055_gpio(gc); 69 struct da9055_gpio *gpio = gpiochip_get_data(gc);
75 70
76 da9055_reg_update(gpio->da9055, 71 da9055_reg_update(gpio->da9055,
77 DA9055_REG_GPIO_MODE0_2, 72 DA9055_REG_GPIO_MODE0_2,
@@ -81,7 +76,7 @@ static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
81 76
82static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset) 77static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
83{ 78{
84 struct da9055_gpio *gpio = to_da9055_gpio(gc); 79 struct da9055_gpio *gpio = gpiochip_get_data(gc);
85 unsigned char reg_byte; 80 unsigned char reg_byte;
86 81
87 reg_byte = (DA9055_ACT_LOW | DA9055_GPI) 82 reg_byte = (DA9055_ACT_LOW | DA9055_GPI)
@@ -97,7 +92,7 @@ static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
97static int da9055_gpio_direction_output(struct gpio_chip *gc, 92static int da9055_gpio_direction_output(struct gpio_chip *gc,
98 unsigned offset, int value) 93 unsigned offset, int value)
99{ 94{
100 struct da9055_gpio *gpio = to_da9055_gpio(gc); 95 struct da9055_gpio *gpio = gpiochip_get_data(gc);
101 unsigned char reg_byte; 96 unsigned char reg_byte;
102 int ret; 97 int ret;
103 98
@@ -119,7 +114,7 @@ static int da9055_gpio_direction_output(struct gpio_chip *gc,
119 114
120static int da9055_gpio_to_irq(struct gpio_chip *gc, u32 offset) 115static int da9055_gpio_to_irq(struct gpio_chip *gc, u32 offset)
121{ 116{
122 struct da9055_gpio *gpio = to_da9055_gpio(gc); 117 struct da9055_gpio *gpio = gpiochip_get_data(gc);
123 struct da9055 *da9055 = gpio->da9055; 118 struct da9055 *da9055 = gpio->da9055;
124 119
125 return regmap_irq_get_virq(da9055->irq_data, 120 return regmap_irq_get_virq(da9055->irq_data,
@@ -156,7 +151,7 @@ static int da9055_gpio_probe(struct platform_device *pdev)
156 if (pdata && pdata->gpio_base) 151 if (pdata && pdata->gpio_base)
157 gpio->gp.base = pdata->gpio_base; 152 gpio->gp.base = pdata->gpio_base;
158 153
159 ret = gpiochip_add(&gpio->gp); 154 ret = gpiochip_add_data(&gpio->gp, gpio);
160 if (ret < 0) { 155 if (ret < 0) {
161 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 156 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
162 goto err_mem; 157 goto err_mem;