Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

William Breathitt Gray and committed by
Linus Walleij
148ad68b 13441457

+8 -17
+8 -17
drivers/gpio/gpio-ws16c48.c
··· 41 41 * @irq_mask: I/O bits affected by interrupts 42 42 * @flow_mask: IRQ flow type mask for the respective I/O bits 43 43 * @base: base port address of the GPIO device 44 - * @extent: extent of port address region of the GPIO device 45 44 * @irq: Interrupt line number 46 45 */ 47 46 struct ws16c48_gpio { ··· 51 52 unsigned long irq_mask; 52 53 unsigned long flow_mask; 53 54 unsigned base; 54 - unsigned extent; 55 55 unsigned irq; 56 56 }; 57 57 ··· 312 314 if (!ws16c48gpio) 313 315 return -ENOMEM; 314 316 315 - if (!request_region(base, extent, name)) { 316 - dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", 317 - name, base, base + extent); 318 - err = -EBUSY; 319 - goto err_lock_io_port; 317 + if (!devm_request_region(dev, base, extent, name)) { 318 + dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", 319 + base, base + extent); 320 + return -EBUSY; 320 321 } 321 322 322 323 ws16c48gpio->chip.label = name; ··· 329 332 ws16c48gpio->chip.get = ws16c48_gpio_get; 330 333 ws16c48gpio->chip.set = ws16c48_gpio_set; 331 334 ws16c48gpio->base = base; 332 - ws16c48gpio->extent = extent; 333 335 ws16c48gpio->irq = irq; 334 336 335 337 spin_lock_init(&ws16c48gpio->lock); ··· 338 342 err = gpiochip_add_data(&ws16c48gpio->chip, ws16c48gpio); 339 343 if (err) { 340 344 dev_err(dev, "GPIO registering failed (%d)\n", err); 341 - goto err_gpio_register; 345 + return err; 342 346 } 343 347 344 348 /* Disable IRQ by default */ ··· 352 356 handle_edge_irq, IRQ_TYPE_NONE); 353 357 if (err) { 354 358 dev_err(dev, "Could not add irqchip (%d)\n", err); 355 - goto err_gpiochip_irqchip_add; 359 + goto err_gpiochip_remove; 356 360 } 357 361 358 362 err = request_irq(irq, ws16c48_irq_handler, IRQF_SHARED, name, 359 363 ws16c48gpio); 360 364 if (err) { 361 365 dev_err(dev, "IRQ handler registering failed (%d)\n", err); 362 - goto err_request_irq; 366 + goto err_gpiochip_remove; 363 367 } 364 368 365 369 return 0; 366 370 367 - err_request_irq: 368 - err_gpiochip_irqchip_add: 371 + err_gpiochip_remove: 369 372 gpiochip_remove(&ws16c48gpio->chip); 370 - err_gpio_register: 371 - release_region(base, extent); 372 - err_lock_io_port: 373 373 return err; 374 374 } 375 375 ··· 375 383 376 384 free_irq(ws16c48gpio->irq, ws16c48gpio); 377 385 gpiochip_remove(&ws16c48gpio->chip); 378 - release_region(ws16c48gpio->base, ws16c48gpio->extent); 379 386 380 387 return 0; 381 388 }