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

gpio: crystalcove: Free IRQ on error path

It appears that all, but request_irq(), calls in the driver are device managed.
In unlikely case of devm_gpiochip_add_data() failure the IRQ left requested.
Free IRQ on error path by switching to devm_request_threaded_irq() API.

Byproduct of this change is a drop of ->remove() callback completely.

Fixes: 945e72db36bd ("gpio: crystalcove: Use irqchip template")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20200728125504.27786-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Andy Shevchenko and committed by
Linus Walleij
a1cdaa64 2a93a0da

+3 -15
+3 -15
drivers/gpio/gpio-crystalcove.c
··· 364 364 girq->handler = handle_simple_irq; 365 365 girq->threaded = true; 366 366 367 - retval = request_threaded_irq(irq, NULL, crystalcove_gpio_irq_handler, 368 - IRQF_ONESHOT, KBUILD_MODNAME, cg); 369 - 367 + retval = devm_request_threaded_irq(&pdev->dev, irq, NULL, 368 + crystalcove_gpio_irq_handler, 369 + IRQF_ONESHOT, KBUILD_MODNAME, cg); 370 370 if (retval) { 371 371 dev_warn(&pdev->dev, "request irq failed: %d\n", retval); 372 372 return retval; ··· 381 381 return 0; 382 382 } 383 383 384 - static int crystalcove_gpio_remove(struct platform_device *pdev) 385 - { 386 - struct crystalcove_gpio *cg = platform_get_drvdata(pdev); 387 - int irq = platform_get_irq(pdev, 0); 388 - 389 - if (irq >= 0) 390 - free_irq(irq, cg); 391 - return 0; 392 - } 393 - 394 384 static struct platform_driver crystalcove_gpio_driver = { 395 385 .probe = crystalcove_gpio_probe, 396 - .remove = crystalcove_gpio_remove, 397 386 .driver = { 398 387 .name = "crystal_cove_gpio", 399 388 }, 400 389 }; 401 - 402 390 module_platform_driver(crystalcove_gpio_driver); 403 391 404 392 MODULE_AUTHOR("Yang, Bin <bin.yang@intel.com>");