diff options
author | William Breathitt Gray <vilhelm.gray@gmail.com> | 2016-02-03 15:15:21 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-02-15 18:19:51 -0500 |
commit | aa6c3602264e3dbdbccac79e125aafee261fdf7b (patch) | |
tree | 0510bf20a70c68550c24bb545c162ca165ff4530 /drivers/gpio/gpio-104-dio-48e.c | |
parent | 22aeddb58dcc920cf2f78652c01272d9dff3d30a (diff) |
gpio: 104-dio-48e: Use devm_request_region
By the time request_region is called in the ACCES 104-DIO-48E GPIO
driver, a corresponding device structure has already been allocated. The
devm_request_region function should be used to help simplify the cleanup
code and reduce the possible points of failure.
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-104-dio-48e.c')
-rw-r--r-- | drivers/gpio/gpio-104-dio-48e.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c index 1134a08304b0..448a903089ef 100644 --- a/drivers/gpio/gpio-104-dio-48e.c +++ b/drivers/gpio/gpio-104-dio-48e.c | |||
@@ -40,7 +40,6 @@ MODULE_PARM_DESC(dio_48e_irq, "ACCES 104-DIO-48E interrupt line number"); | |||
40 | * @control: Control registers state | 40 | * @control: Control registers state |
41 | * @lock: synchronization lock to prevent I/O race conditions | 41 | * @lock: synchronization lock to prevent I/O race conditions |
42 | * @base: base port address of the GPIO device | 42 | * @base: base port address of the GPIO device |
43 | * @extent: extent of port address region of the GPIO device | ||
44 | * @irq: Interrupt line number | 43 | * @irq: Interrupt line number |
45 | * @irq_mask: I/O bits affected by interrupts | 44 | * @irq_mask: I/O bits affected by interrupts |
46 | */ | 45 | */ |
@@ -51,7 +50,6 @@ struct dio48e_gpio { | |||
51 | unsigned char control[2]; | 50 | unsigned char control[2]; |
52 | spinlock_t lock; | 51 | spinlock_t lock; |
53 | unsigned base; | 52 | unsigned base; |
54 | unsigned extent; | ||
55 | unsigned irq; | 53 | unsigned irq; |
56 | unsigned char irq_mask; | 54 | unsigned char irq_mask; |
57 | }; | 55 | }; |
@@ -310,11 +308,10 @@ static int __init dio48e_probe(struct platform_device *pdev) | |||
310 | if (!dio48egpio) | 308 | if (!dio48egpio) |
311 | return -ENOMEM; | 309 | return -ENOMEM; |
312 | 310 | ||
313 | if (!request_region(base, extent, name)) { | 311 | if (!devm_request_region(dev, base, extent, name)) { |
314 | dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", | 312 | dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", |
315 | name, base, base + extent); | 313 | base, base + extent); |
316 | err = -EBUSY; | 314 | return -EBUSY; |
317 | goto err_lock_io_port; | ||
318 | } | 315 | } |
319 | 316 | ||
320 | dio48egpio->chip.label = name; | 317 | dio48egpio->chip.label = name; |
@@ -328,7 +325,6 @@ static int __init dio48e_probe(struct platform_device *pdev) | |||
328 | dio48egpio->chip.get = dio48e_gpio_get; | 325 | dio48egpio->chip.get = dio48e_gpio_get; |
329 | dio48egpio->chip.set = dio48e_gpio_set; | 326 | dio48egpio->chip.set = dio48e_gpio_set; |
330 | dio48egpio->base = base; | 327 | dio48egpio->base = base; |
331 | dio48egpio->extent = extent; | ||
332 | dio48egpio->irq = irq; | 328 | dio48egpio->irq = irq; |
333 | 329 | ||
334 | spin_lock_init(&dio48egpio->lock); | 330 | spin_lock_init(&dio48egpio->lock); |
@@ -338,7 +334,7 @@ static int __init dio48e_probe(struct platform_device *pdev) | |||
338 | err = gpiochip_add_data(&dio48egpio->chip, dio48egpio); | 334 | err = gpiochip_add_data(&dio48egpio->chip, dio48egpio); |
339 | if (err) { | 335 | if (err) { |
340 | dev_err(dev, "GPIO registering failed (%d)\n", err); | 336 | dev_err(dev, "GPIO registering failed (%d)\n", err); |
341 | goto err_gpio_register; | 337 | return err; |
342 | } | 338 | } |
343 | 339 | ||
344 | /* initialize all GPIO as output */ | 340 | /* initialize all GPIO as output */ |
@@ -360,23 +356,19 @@ static int __init dio48e_probe(struct platform_device *pdev) | |||
360 | handle_edge_irq, IRQ_TYPE_NONE); | 356 | handle_edge_irq, IRQ_TYPE_NONE); |
361 | if (err) { | 357 | if (err) { |
362 | dev_err(dev, "Could not add irqchip (%d)\n", err); | 358 | dev_err(dev, "Could not add irqchip (%d)\n", err); |
363 | goto err_gpiochip_irqchip_add; | 359 | goto err_gpiochip_remove; |
364 | } | 360 | } |
365 | 361 | ||
366 | err = request_irq(irq, dio48e_irq_handler, 0, name, dio48egpio); | 362 | err = request_irq(irq, dio48e_irq_handler, 0, name, dio48egpio); |
367 | if (err) { | 363 | if (err) { |
368 | dev_err(dev, "IRQ handler registering failed (%d)\n", err); | 364 | dev_err(dev, "IRQ handler registering failed (%d)\n", err); |
369 | goto err_request_irq; | 365 | goto err_gpiochip_remove; |
370 | } | 366 | } |
371 | 367 | ||
372 | return 0; | 368 | return 0; |
373 | 369 | ||
374 | err_request_irq: | 370 | err_gpiochip_remove: |
375 | err_gpiochip_irqchip_add: | ||
376 | gpiochip_remove(&dio48egpio->chip); | 371 | gpiochip_remove(&dio48egpio->chip); |
377 | err_gpio_register: | ||
378 | release_region(base, extent); | ||
379 | err_lock_io_port: | ||
380 | return err; | 372 | return err; |
381 | } | 373 | } |
382 | 374 | ||
@@ -386,7 +378,6 @@ static int dio48e_remove(struct platform_device *pdev) | |||
386 | 378 | ||
387 | free_irq(dio48egpio->irq, dio48egpio); | 379 | free_irq(dio48egpio->irq, dio48egpio); |
388 | gpiochip_remove(&dio48egpio->chip); | 380 | gpiochip_remove(&dio48egpio->chip); |
389 | release_region(dio48egpio->base, dio48egpio->extent); | ||
390 | 381 | ||
391 | return 0; | 382 | return 0; |
392 | } | 383 | } |