summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-104-idi-48.c
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2016-02-03 15:15:22 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-02-15 18:19:51 -0500
commit5cfc05761ba0c7f1aa04f0d441fb68a28453d13b (patch)
tree35b6165a1b36908226fb0610b53896175372676e /drivers/gpio/gpio-104-idi-48.c
parentaa6c3602264e3dbdbccac79e125aafee261fdf7b (diff)
gpio: 104-idi-48: Use devm_request_region
By the time request_region is called in the ACCES 104-IDI-48 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-idi-48.c')
-rw-r--r--drivers/gpio/gpio-104-idi-48.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index 49b1188d1b16..e37cd4cdda35 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -39,7 +39,6 @@ MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number");
39 * @ack_lock: synchronization lock to prevent IRQ handler race conditions 39 * @ack_lock: synchronization lock to prevent IRQ handler race conditions
40 * @irq_mask: input bits affected by interrupts 40 * @irq_mask: input bits affected by interrupts
41 * @base: base port address of the GPIO device 41 * @base: base port address of the GPIO device
42 * @extent: extent of port address region of the GPIO device
43 * @irq: Interrupt line number 42 * @irq: Interrupt line number
44 * @cos_enb: Change-Of-State IRQ enable boundaries mask 43 * @cos_enb: Change-Of-State IRQ enable boundaries mask
45 */ 44 */
@@ -49,7 +48,6 @@ struct idi_48_gpio {
49 spinlock_t ack_lock; 48 spinlock_t ack_lock;
50 unsigned char irq_mask[6]; 49 unsigned char irq_mask[6];
51 unsigned base; 50 unsigned base;
52 unsigned extent;
53 unsigned irq; 51 unsigned irq;
54 unsigned char cos_enb; 52 unsigned char cos_enb;
55}; 53};
@@ -227,11 +225,10 @@ static int __init idi_48_probe(struct platform_device *pdev)
227 if (!idi48gpio) 225 if (!idi48gpio)
228 return -ENOMEM; 226 return -ENOMEM;
229 227
230 if (!request_region(base, extent, name)) { 228 if (!devm_request_region(dev, base, extent, name)) {
231 dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", 229 dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
232 name, base, base + extent); 230 base, base + extent);
233 err = -EBUSY; 231 return -EBUSY;
234 goto err_lock_io_port;
235 } 232 }
236 233
237 idi48gpio->chip.label = name; 234 idi48gpio->chip.label = name;
@@ -243,7 +240,6 @@ static int __init idi_48_probe(struct platform_device *pdev)
243 idi48gpio->chip.direction_input = idi_48_gpio_direction_input; 240 idi48gpio->chip.direction_input = idi_48_gpio_direction_input;
244 idi48gpio->chip.get = idi_48_gpio_get; 241 idi48gpio->chip.get = idi_48_gpio_get;
245 idi48gpio->base = base; 242 idi48gpio->base = base;
246 idi48gpio->extent = extent;
247 idi48gpio->irq = irq; 243 idi48gpio->irq = irq;
248 244
249 spin_lock_init(&idi48gpio->lock); 245 spin_lock_init(&idi48gpio->lock);
@@ -253,7 +249,7 @@ static int __init idi_48_probe(struct platform_device *pdev)
253 err = gpiochip_add_data(&idi48gpio->chip, idi48gpio); 249 err = gpiochip_add_data(&idi48gpio->chip, idi48gpio);
254 if (err) { 250 if (err) {
255 dev_err(dev, "GPIO registering failed (%d)\n", err); 251 dev_err(dev, "GPIO registering failed (%d)\n", err);
256 goto err_gpio_register; 252 return err;
257 } 253 }
258 254
259 /* Disable IRQ by default */ 255 /* Disable IRQ by default */
@@ -264,24 +260,20 @@ static int __init idi_48_probe(struct platform_device *pdev)
264 handle_edge_irq, IRQ_TYPE_NONE); 260 handle_edge_irq, IRQ_TYPE_NONE);
265 if (err) { 261 if (err) {
266 dev_err(dev, "Could not add irqchip (%d)\n", err); 262 dev_err(dev, "Could not add irqchip (%d)\n", err);
267 goto err_gpiochip_irqchip_add; 263 goto err_gpiochip_remove;
268 } 264 }
269 265
270 err = request_irq(irq, idi_48_irq_handler, IRQF_SHARED, name, 266 err = request_irq(irq, idi_48_irq_handler, IRQF_SHARED, name,
271 idi48gpio); 267 idi48gpio);
272 if (err) { 268 if (err) {
273 dev_err(dev, "IRQ handler registering failed (%d)\n", err); 269 dev_err(dev, "IRQ handler registering failed (%d)\n", err);
274 goto err_request_irq; 270 goto err_gpiochip_remove;
275 } 271 }
276 272
277 return 0; 273 return 0;
278 274
279err_request_irq: 275err_gpiochip_remove:
280err_gpiochip_irqchip_add:
281 gpiochip_remove(&idi48gpio->chip); 276 gpiochip_remove(&idi48gpio->chip);
282err_gpio_register:
283 release_region(base, extent);
284err_lock_io_port:
285 return err; 277 return err;
286} 278}
287 279
@@ -291,7 +283,6 @@ static int idi_48_remove(struct platform_device *pdev)
291 283
292 free_irq(idi48gpio->irq, idi48gpio); 284 free_irq(idi48gpio->irq, idi48gpio);
293 gpiochip_remove(&idi48gpio->chip); 285 gpiochip_remove(&idi48gpio->chip);
294 release_region(idi48gpio->base, idi48gpio->extent);
295 286
296 return 0; 287 return 0;
297} 288}