Commit c9c9d764 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Rob Herring

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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230319100620.295849-4-u.kleine-koenig@pengutronix.deSigned-off-by: default avatarRob Herring <robh@kernel.org>
parent 13cd9ac6
......@@ -1529,13 +1529,12 @@ static int unittest_probe(struct platform_device *pdev)
return 0;
}
static int unittest_remove(struct platform_device *pdev)
static void unittest_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
dev_dbg(dev, "%s for node @%pOF\n", __func__, np);
return 0;
}
static const struct of_device_id unittest_match[] = {
......@@ -1545,7 +1544,7 @@ static const struct of_device_id unittest_match[] = {
static struct platform_driver unittest_driver = {
.probe = unittest_probe,
.remove = unittest_remove,
.remove_new = unittest_remove,
.driver = {
.name = "unittest",
.of_match_table = of_match_ptr(unittest_match),
......@@ -1626,7 +1625,7 @@ static int unittest_gpio_probe(struct platform_device *pdev)
return ret;
}
static int unittest_gpio_remove(struct platform_device *pdev)
static void unittest_gpio_remove(struct platform_device *pdev)
{
struct unittest_gpio_dev *devptr = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev;
......@@ -1637,8 +1636,6 @@ static int unittest_gpio_remove(struct platform_device *pdev)
gpiochip_remove(&devptr->chip);
kfree(devptr);
return 0;
}
static const struct of_device_id unittest_gpio_id[] = {
......@@ -1648,7 +1645,7 @@ static const struct of_device_id unittest_gpio_id[] = {
static struct platform_driver unittest_gpio_driver = {
.probe = unittest_gpio_probe,
.remove = unittest_gpio_remove,
.remove_new = unittest_gpio_remove,
.driver = {
.name = "unittest-gpio",
.of_match_table = of_match_ptr(unittest_gpio_id),
......@@ -2486,7 +2483,7 @@ static int unittest_i2c_bus_probe(struct platform_device *pdev)
return 0;
}
static int unittest_i2c_bus_remove(struct platform_device *pdev)
static void unittest_i2c_bus_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
......@@ -2494,8 +2491,6 @@ static int unittest_i2c_bus_remove(struct platform_device *pdev)
dev_dbg(dev, "%s for node @%pOF\n", __func__, np);
i2c_del_adapter(&std->adap);
return 0;
}
static const struct of_device_id unittest_i2c_bus_match[] = {
......@@ -2505,7 +2500,7 @@ static const struct of_device_id unittest_i2c_bus_match[] = {
static struct platform_driver unittest_i2c_bus_driver = {
.probe = unittest_i2c_bus_probe,
.remove = unittest_i2c_bus_remove,
.remove_new = unittest_i2c_bus_remove,
.driver = {
.name = "unittest-i2c-bus",
.of_match_table = of_match_ptr(unittest_i2c_bus_match),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment