aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-tb10x.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-07 08:41:02 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-01-05 05:21:15 -0500
commit0ca8c5c4af758b2a8d763b33508f99a3116c3c01 (patch)
tree1372c5d94b0158553db609b53f2f706909a17168 /drivers/gpio/gpio-tb10x.c
parentd27ad7a833443fe0c4247129ab97105f1d845cda (diff)
gpio: tb10x: 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: Christian Ruppert <christian.ruppert@abilis.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-tb10x.c')
-rw-r--r--drivers/gpio/gpio-tb10x.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
index 1a7c3efae5d8..5eaec20ddbc7 100644
--- a/drivers/gpio/gpio-tb10x.c
+++ b/drivers/gpio/gpio-tb10x.c
@@ -87,14 +87,9 @@ static inline void tb10x_set_bits(struct tb10x_gpio *gpio, unsigned int offs,
87 spin_unlock_irqrestore(&gpio->spinlock, flags); 87 spin_unlock_irqrestore(&gpio->spinlock, flags);
88} 88}
89 89
90static inline struct tb10x_gpio *to_tb10x_gpio(struct gpio_chip *chip)
91{
92 return container_of(chip, struct tb10x_gpio, gc);
93}
94
95static int tb10x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) 90static int tb10x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
96{ 91{
97 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); 92 struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip);
98 int mask = BIT(offset); 93 int mask = BIT(offset);
99 int val = TB10X_GPIO_DIR_IN << offset; 94 int val = TB10X_GPIO_DIR_IN << offset;
100 95
@@ -105,7 +100,7 @@ static int tb10x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
105 100
106static int tb10x_gpio_get(struct gpio_chip *chip, unsigned offset) 101static int tb10x_gpio_get(struct gpio_chip *chip, unsigned offset)
107{ 102{
108 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); 103 struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip);
109 int val; 104 int val;
110 105
111 val = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_DATA); 106 val = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_DATA);
@@ -118,7 +113,7 @@ static int tb10x_gpio_get(struct gpio_chip *chip, unsigned offset)
118 113
119static void tb10x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 114static void tb10x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
120{ 115{
121 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); 116 struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip);
122 int mask = BIT(offset); 117 int mask = BIT(offset);
123 int val = value << offset; 118 int val = value << offset;
124 119
@@ -128,7 +123,7 @@ static void tb10x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
128static int tb10x_gpio_direction_out(struct gpio_chip *chip, 123static int tb10x_gpio_direction_out(struct gpio_chip *chip,
129 unsigned offset, int value) 124 unsigned offset, int value)
130{ 125{
131 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); 126 struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip);
132 int mask = BIT(offset); 127 int mask = BIT(offset);
133 int val = TB10X_GPIO_DIR_OUT << offset; 128 int val = TB10X_GPIO_DIR_OUT << offset;
134 129
@@ -140,7 +135,7 @@ static int tb10x_gpio_direction_out(struct gpio_chip *chip,
140 135
141static int tb10x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 136static int tb10x_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
142{ 137{
143 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); 138 struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip);
144 139
145 return irq_create_mapping(tb10x_gpio->domain, offset); 140 return irq_create_mapping(tb10x_gpio->domain, offset);
146} 141}
@@ -210,7 +205,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
210 tb10x_gpio->gc.can_sleep = false; 205 tb10x_gpio->gc.can_sleep = false;
211 206
212 207
213 ret = gpiochip_add(&tb10x_gpio->gc); 208 ret = gpiochip_add_data(&tb10x_gpio->gc, tb10x_gpio);
214 if (ret < 0) { 209 if (ret < 0) {
215 dev_err(&pdev->dev, "Could not add gpiochip.\n"); 210 dev_err(&pdev->dev, "Could not add gpiochip.\n");
216 goto fail_gpiochip_registration; 211 goto fail_gpiochip_registration;