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

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>

authored by

William Breathitt Gray and committed by
Linus Walleij
5cfc0576 aa6c3602

+8 -17
+8 -17
drivers/gpio/gpio-104-idi-48.c
··· 39 39 * @ack_lock: synchronization lock to prevent IRQ handler race conditions 40 40 * @irq_mask: input bits affected by interrupts 41 41 * @base: base port address of the GPIO device 42 - * @extent: extent of port address region of the GPIO device 43 42 * @irq: Interrupt line number 44 43 * @cos_enb: Change-Of-State IRQ enable boundaries mask 45 44 */ ··· 48 49 spinlock_t ack_lock; 49 50 unsigned char irq_mask[6]; 50 51 unsigned base; 51 - unsigned extent; 52 52 unsigned irq; 53 53 unsigned char cos_enb; 54 54 }; ··· 225 227 if (!idi48gpio) 226 228 return -ENOMEM; 227 229 228 - if (!request_region(base, extent, name)) { 229 - dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", 230 - name, base, base + extent); 231 - err = -EBUSY; 232 - goto err_lock_io_port; 230 + if (!devm_request_region(dev, base, extent, name)) { 231 + dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", 232 + base, base + extent); 233 + return -EBUSY; 233 234 } 234 235 235 236 idi48gpio->chip.label = name; ··· 240 243 idi48gpio->chip.direction_input = idi_48_gpio_direction_input; 241 244 idi48gpio->chip.get = idi_48_gpio_get; 242 245 idi48gpio->base = base; 243 - idi48gpio->extent = extent; 244 246 idi48gpio->irq = irq; 245 247 246 248 spin_lock_init(&idi48gpio->lock); ··· 249 253 err = gpiochip_add_data(&idi48gpio->chip, idi48gpio); 250 254 if (err) { 251 255 dev_err(dev, "GPIO registering failed (%d)\n", err); 252 - goto err_gpio_register; 256 + return err; 253 257 } 254 258 255 259 /* Disable IRQ by default */ ··· 260 264 handle_edge_irq, IRQ_TYPE_NONE); 261 265 if (err) { 262 266 dev_err(dev, "Could not add irqchip (%d)\n", err); 263 - goto err_gpiochip_irqchip_add; 267 + goto err_gpiochip_remove; 264 268 } 265 269 266 270 err = request_irq(irq, idi_48_irq_handler, IRQF_SHARED, name, 267 271 idi48gpio); 268 272 if (err) { 269 273 dev_err(dev, "IRQ handler registering failed (%d)\n", err); 270 - goto err_request_irq; 274 + goto err_gpiochip_remove; 271 275 } 272 276 273 277 return 0; 274 278 275 - err_request_irq: 276 - err_gpiochip_irqchip_add: 279 + err_gpiochip_remove: 277 280 gpiochip_remove(&idi48gpio->chip); 278 - err_gpio_register: 279 - release_region(base, extent); 280 - err_lock_io_port: 281 281 return err; 282 282 } 283 283 ··· 283 291 284 292 free_irq(idi48gpio->irq, idi48gpio); 285 293 gpiochip_remove(&idi48gpio->chip); 286 - release_region(idi48gpio->base, idi48gpio->extent); 287 294 288 295 return 0; 289 296 }