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

of: unittest: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230319100620.295849-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Rob Herring <robh@kernel.org>

authored by

Uwe Kleine-König and committed by
Rob Herring
c9c9d764 13cd9ac6

+6 -11
+6 -11
drivers/of/unittest.c
··· 1529 1529 return 0; 1530 1530 } 1531 1531 1532 - static int unittest_remove(struct platform_device *pdev) 1532 + static void unittest_remove(struct platform_device *pdev) 1533 1533 { 1534 1534 struct device *dev = &pdev->dev; 1535 1535 struct device_node *np = dev->of_node; 1536 1536 1537 1537 dev_dbg(dev, "%s for node @%pOF\n", __func__, np); 1538 - return 0; 1539 1538 } 1540 1539 1541 1540 static const struct of_device_id unittest_match[] = { ··· 1544 1545 1545 1546 static struct platform_driver unittest_driver = { 1546 1547 .probe = unittest_probe, 1547 - .remove = unittest_remove, 1548 + .remove_new = unittest_remove, 1548 1549 .driver = { 1549 1550 .name = "unittest", 1550 1551 .of_match_table = of_match_ptr(unittest_match), ··· 1625 1626 return ret; 1626 1627 } 1627 1628 1628 - static int unittest_gpio_remove(struct platform_device *pdev) 1629 + static void unittest_gpio_remove(struct platform_device *pdev) 1629 1630 { 1630 1631 struct unittest_gpio_dev *devptr = platform_get_drvdata(pdev); 1631 1632 struct device *dev = &pdev->dev; ··· 1636 1637 gpiochip_remove(&devptr->chip); 1637 1638 1638 1639 kfree(devptr); 1639 - 1640 - return 0; 1641 1640 } 1642 1641 1643 1642 static const struct of_device_id unittest_gpio_id[] = { ··· 1645 1648 1646 1649 static struct platform_driver unittest_gpio_driver = { 1647 1650 .probe = unittest_gpio_probe, 1648 - .remove = unittest_gpio_remove, 1651 + .remove_new = unittest_gpio_remove, 1649 1652 .driver = { 1650 1653 .name = "unittest-gpio", 1651 1654 .of_match_table = of_match_ptr(unittest_gpio_id), ··· 2483 2486 return 0; 2484 2487 } 2485 2488 2486 - static int unittest_i2c_bus_remove(struct platform_device *pdev) 2489 + static void unittest_i2c_bus_remove(struct platform_device *pdev) 2487 2490 { 2488 2491 struct device *dev = &pdev->dev; 2489 2492 struct device_node *np = dev->of_node; ··· 2491 2494 2492 2495 dev_dbg(dev, "%s for node @%pOF\n", __func__, np); 2493 2496 i2c_del_adapter(&std->adap); 2494 - 2495 - return 0; 2496 2497 } 2497 2498 2498 2499 static const struct of_device_id unittest_i2c_bus_match[] = { ··· 2500 2505 2501 2506 static struct platform_driver unittest_i2c_bus_driver = { 2502 2507 .probe = unittest_i2c_bus_probe, 2503 - .remove = unittest_i2c_bus_remove, 2508 + .remove_new = unittest_i2c_bus_remove, 2504 2509 .driver = { 2505 2510 .name = "unittest-i2c-bus", 2506 2511 .of_match_table = of_match_ptr(unittest_i2c_bus_match),