aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-07 08:46:45 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-01-05 05:21:15 -0500
commit94a90370427fb927442c0a00180ddbaf08f577df (patch)
tree48afb2b00e3146bcc45ee385e6a37fb0152cc706
parent92a41e2f73879373a4ce2df4b2137d03ba1289ec (diff)
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: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpio-tps6586x.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/gpio/gpio-tps6586x.c b/drivers/gpio/gpio-tps6586x.c
index 89b2249100b0..87de5486a29e 100644
--- a/drivers/gpio/gpio-tps6586x.c
+++ b/drivers/gpio/gpio-tps6586x.c
@@ -38,14 +38,9 @@ struct tps6586x_gpio {
38 struct device *parent; 38 struct device *parent;
39}; 39};
40 40
41static inline struct tps6586x_gpio *to_tps6586x_gpio(struct gpio_chip *chip)
42{
43 return container_of(chip, struct tps6586x_gpio, gpio_chip);
44}
45
46static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset) 41static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
47{ 42{
48 struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); 43 struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
49 uint8_t val; 44 uint8_t val;
50 int ret; 45 int ret;
51 46
@@ -59,7 +54,7 @@ static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
59static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset, 54static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset,
60 int value) 55 int value)
61{ 56{
62 struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); 57 struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
63 58
64 tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2, 59 tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2,
65 value << offset, 1 << offset); 60 value << offset, 1 << offset);
@@ -68,7 +63,7 @@ static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset,
68static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset, 63static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
69 int value) 64 int value)
70{ 65{
71 struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); 66 struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
72 uint8_t val, mask; 67 uint8_t val, mask;
73 68
74 tps6586x_gpio_set(gc, offset, value); 69 tps6586x_gpio_set(gc, offset, value);
@@ -82,7 +77,7 @@ static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
82 77
83static int tps6586x_gpio_to_irq(struct gpio_chip *gc, unsigned offset) 78static int tps6586x_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
84{ 79{
85 struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); 80 struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
86 81
87 return tps6586x_irq_get_virq(tps6586x_gpio->parent, 82 return tps6586x_irq_get_virq(tps6586x_gpio->parent,
88 TPS6586X_INT_PLDO_0 + offset); 83 TPS6586X_INT_PLDO_0 + offset);
@@ -122,7 +117,7 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
122 else 117 else
123 tps6586x_gpio->gpio_chip.base = -1; 118 tps6586x_gpio->gpio_chip.base = -1;
124 119
125 ret = gpiochip_add(&tps6586x_gpio->gpio_chip); 120 ret = gpiochip_add_data(&tps6586x_gpio->gpio_chip, tps6586x_gpio);
126 if (ret < 0) { 121 if (ret < 0) {
127 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 122 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
128 return ret; 123 return ret;