aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2016-02-03 15:17:50 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-02-15 18:19:54 -0500
commit148ad68b3d0dd0f0068ff5f6f47bc360011c429e (patch)
tree7aa4f996989beacd5d4daa00c09baef954580ff3
parent134414578518f095b65185535bc696277b5c57c6 (diff)
gpio: ws16c48: Use devm_request_region
By the time request_region is called in the WinSystems WS16C48 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>
-rw-r--r--drivers/gpio/gpio-ws16c48.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index d5279a0a85bd..51f41e8fd21e 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -41,7 +41,6 @@ MODULE_PARM_DESC(ws16c48_irq, "WinSystems WS16C48 interrupt line number");
41 * @irq_mask: I/O bits affected by interrupts 41 * @irq_mask: I/O bits affected by interrupts
42 * @flow_mask: IRQ flow type mask for the respective I/O bits 42 * @flow_mask: IRQ flow type mask for the respective I/O bits
43 * @base: base port address of the GPIO device 43 * @base: base port address of the GPIO device
44 * @extent: extent of port address region of the GPIO device
45 * @irq: Interrupt line number 44 * @irq: Interrupt line number
46 */ 45 */
47struct ws16c48_gpio { 46struct ws16c48_gpio {
@@ -52,7 +51,6 @@ struct ws16c48_gpio {
52 unsigned long irq_mask; 51 unsigned long irq_mask;
53 unsigned long flow_mask; 52 unsigned long flow_mask;
54 unsigned base; 53 unsigned base;
55 unsigned extent;
56 unsigned irq; 54 unsigned irq;
57}; 55};
58 56
@@ -314,11 +312,10 @@ static int __init ws16c48_probe(struct platform_device *pdev)
314 if (!ws16c48gpio) 312 if (!ws16c48gpio)
315 return -ENOMEM; 313 return -ENOMEM;
316 314
317 if (!request_region(base, extent, name)) { 315 if (!devm_request_region(dev, base, extent, name)) {
318 dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", 316 dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
319 name, base, base + extent); 317 base, base + extent);
320 err = -EBUSY; 318 return -EBUSY;
321 goto err_lock_io_port;
322 } 319 }
323 320
324 ws16c48gpio->chip.label = name; 321 ws16c48gpio->chip.label = name;
@@ -332,7 +329,6 @@ static int __init ws16c48_probe(struct platform_device *pdev)
332 ws16c48gpio->chip.get = ws16c48_gpio_get; 329 ws16c48gpio->chip.get = ws16c48_gpio_get;
333 ws16c48gpio->chip.set = ws16c48_gpio_set; 330 ws16c48gpio->chip.set = ws16c48_gpio_set;
334 ws16c48gpio->base = base; 331 ws16c48gpio->base = base;
335 ws16c48gpio->extent = extent;
336 ws16c48gpio->irq = irq; 332 ws16c48gpio->irq = irq;
337 333
338 spin_lock_init(&ws16c48gpio->lock); 334 spin_lock_init(&ws16c48gpio->lock);
@@ -342,7 +338,7 @@ static int __init ws16c48_probe(struct platform_device *pdev)
342 err = gpiochip_add_data(&ws16c48gpio->chip, ws16c48gpio); 338 err = gpiochip_add_data(&ws16c48gpio->chip, ws16c48gpio);
343 if (err) { 339 if (err) {
344 dev_err(dev, "GPIO registering failed (%d)\n", err); 340 dev_err(dev, "GPIO registering failed (%d)\n", err);
345 goto err_gpio_register; 341 return err;
346 } 342 }
347 343
348 /* Disable IRQ by default */ 344 /* Disable IRQ by default */
@@ -356,24 +352,20 @@ static int __init ws16c48_probe(struct platform_device *pdev)
356 handle_edge_irq, IRQ_TYPE_NONE); 352 handle_edge_irq, IRQ_TYPE_NONE);
357 if (err) { 353 if (err) {
358 dev_err(dev, "Could not add irqchip (%d)\n", err); 354 dev_err(dev, "Could not add irqchip (%d)\n", err);
359 goto err_gpiochip_irqchip_add; 355 goto err_gpiochip_remove;
360 } 356 }
361 357
362 err = request_irq(irq, ws16c48_irq_handler, IRQF_SHARED, name, 358 err = request_irq(irq, ws16c48_irq_handler, IRQF_SHARED, name,
363 ws16c48gpio); 359 ws16c48gpio);
364 if (err) { 360 if (err) {
365 dev_err(dev, "IRQ handler registering failed (%d)\n", err); 361 dev_err(dev, "IRQ handler registering failed (%d)\n", err);
366 goto err_request_irq; 362 goto err_gpiochip_remove;
367 } 363 }
368 364
369 return 0; 365 return 0;
370 366
371err_request_irq: 367err_gpiochip_remove:
372err_gpiochip_irqchip_add:
373 gpiochip_remove(&ws16c48gpio->chip); 368 gpiochip_remove(&ws16c48gpio->chip);
374err_gpio_register:
375 release_region(base, extent);
376err_lock_io_port:
377 return err; 369 return err;
378} 370}
379 371
@@ -383,7 +375,6 @@ static int ws16c48_remove(struct platform_device *pdev)
383 375
384 free_irq(ws16c48gpio->irq, ws16c48gpio); 376 free_irq(ws16c48gpio->irq, ws16c48gpio);
385 gpiochip_remove(&ws16c48gpio->chip); 377 gpiochip_remove(&ws16c48gpio->chip);
386 release_region(ws16c48gpio->base, ws16c48gpio->extent);
387 378
388 return 0; 379 return 0;
389} 380}