diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2016-02-22 07:13:28 -0500 |
---|---|---|
committer | Laxman Dewangan <ldewangan@nvidia.com> | 2016-02-23 10:05:44 -0500 |
commit | ad7b550ad7c2499dc5ed575a81830463fee51631 (patch) | |
tree | 81362e89b86ecf13e3ef223f9e68de46e4659684 /drivers/gpio/gpio-tb10x.c | |
parent | 94c683ab8d3f1201822f3ff18d62f96a7b26eed5 (diff) |
gpio: tb10x: Use devm_gpiochip_add_data() for gpio registration
Use devm_gpiochip_add_data() for GPIO registration and clean the
error path.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'drivers/gpio/gpio-tb10x.c')
-rw-r--r-- | drivers/gpio/gpio-tb10x.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c index 5eaec20ddbc7..80b6959ae995 100644 --- a/drivers/gpio/gpio-tb10x.c +++ b/drivers/gpio/gpio-tb10x.c | |||
@@ -205,10 +205,10 @@ static int tb10x_gpio_probe(struct platform_device *pdev) | |||
205 | tb10x_gpio->gc.can_sleep = false; | 205 | tb10x_gpio->gc.can_sleep = false; |
206 | 206 | ||
207 | 207 | ||
208 | ret = gpiochip_add_data(&tb10x_gpio->gc, tb10x_gpio); | 208 | ret = devm_gpiochip_add_data(&pdev->dev, &tb10x_gpio->gc, tb10x_gpio); |
209 | if (ret < 0) { | 209 | if (ret < 0) { |
210 | dev_err(&pdev->dev, "Could not add gpiochip.\n"); | 210 | dev_err(&pdev->dev, "Could not add gpiochip.\n"); |
211 | goto fail_gpiochip_registration; | 211 | return ret; |
212 | } | 212 | } |
213 | 213 | ||
214 | platform_set_drvdata(pdev, tb10x_gpio); | 214 | platform_set_drvdata(pdev, tb10x_gpio); |
@@ -219,7 +219,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev) | |||
219 | ret = platform_get_irq(pdev, 0); | 219 | ret = platform_get_irq(pdev, 0); |
220 | if (ret < 0) { | 220 | if (ret < 0) { |
221 | dev_err(&pdev->dev, "No interrupt specified.\n"); | 221 | dev_err(&pdev->dev, "No interrupt specified.\n"); |
222 | goto fail_get_irq; | 222 | return ret; |
223 | } | 223 | } |
224 | 224 | ||
225 | tb10x_gpio->gc.to_irq = tb10x_gpio_to_irq; | 225 | tb10x_gpio->gc.to_irq = tb10x_gpio_to_irq; |
@@ -229,14 +229,13 @@ static int tb10x_gpio_probe(struct platform_device *pdev) | |||
229 | IRQF_TRIGGER_NONE | IRQF_SHARED, | 229 | IRQF_TRIGGER_NONE | IRQF_SHARED, |
230 | dev_name(&pdev->dev), tb10x_gpio); | 230 | dev_name(&pdev->dev), tb10x_gpio); |
231 | if (ret != 0) | 231 | if (ret != 0) |
232 | goto fail_request_irq; | 232 | return ret; |
233 | 233 | ||
234 | tb10x_gpio->domain = irq_domain_add_linear(dn, | 234 | tb10x_gpio->domain = irq_domain_add_linear(dn, |
235 | tb10x_gpio->gc.ngpio, | 235 | tb10x_gpio->gc.ngpio, |
236 | &irq_generic_chip_ops, NULL); | 236 | &irq_generic_chip_ops, NULL); |
237 | if (!tb10x_gpio->domain) { | 237 | if (!tb10x_gpio->domain) { |
238 | ret = -ENOMEM; | 238 | return -ENOMEM; |
239 | goto fail_irq_domain; | ||
240 | } | 239 | } |
241 | 240 | ||
242 | ret = irq_alloc_domain_generic_chips(tb10x_gpio->domain, | 241 | ret = irq_alloc_domain_generic_chips(tb10x_gpio->domain, |
@@ -244,7 +243,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev) | |||
244 | handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE, | 243 | handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE, |
245 | IRQ_GC_INIT_MASK_CACHE); | 244 | IRQ_GC_INIT_MASK_CACHE); |
246 | if (ret) | 245 | if (ret) |
247 | goto fail_irq_domain; | 246 | return ret; |
248 | 247 | ||
249 | gc = tb10x_gpio->domain->gc->gc[0]; | 248 | gc = tb10x_gpio->domain->gc->gc[0]; |
250 | gc->reg_base = tb10x_gpio->base; | 249 | gc->reg_base = tb10x_gpio->base; |
@@ -258,14 +257,6 @@ static int tb10x_gpio_probe(struct platform_device *pdev) | |||
258 | } | 257 | } |
259 | 258 | ||
260 | return 0; | 259 | return 0; |
261 | |||
262 | fail_irq_domain: | ||
263 | fail_request_irq: | ||
264 | fail_get_irq: | ||
265 | gpiochip_remove(&tb10x_gpio->gc); | ||
266 | fail_gpiochip_registration: | ||
267 | fail_ioremap: | ||
268 | return ret; | ||
269 | } | 260 | } |
270 | 261 | ||
271 | static int tb10x_gpio_remove(struct platform_device *pdev) | 262 | static int tb10x_gpio_remove(struct platform_device *pdev) |
@@ -278,7 +269,6 @@ static int tb10x_gpio_remove(struct platform_device *pdev) | |||
278 | kfree(tb10x_gpio->domain->gc); | 269 | kfree(tb10x_gpio->domain->gc); |
279 | irq_domain_remove(tb10x_gpio->domain); | 270 | irq_domain_remove(tb10x_gpio->domain); |
280 | } | 271 | } |
281 | gpiochip_remove(&tb10x_gpio->gc); | ||
282 | 272 | ||
283 | return 0; | 273 | return 0; |
284 | } | 274 | } |