Commit a92dbb9c authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Jakub Kicinski

net: ipa: 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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

Link: https://lore.kernel.org/r/20231117095922.876489-3-u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/c43193b9a002e88da36b111bb44ce2973ecde722.1701713943.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 2ff46b9e
......@@ -943,7 +943,7 @@ static int ipa_probe(struct platform_device *pdev)
return ret;
}
static int ipa_remove(struct platform_device *pdev)
static void ipa_remove(struct platform_device *pdev)
{
struct ipa *ipa = dev_get_drvdata(&pdev->dev);
struct ipa_power *power = ipa->power;
......@@ -966,8 +966,16 @@ static int ipa_remove(struct platform_device *pdev)
usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC);
ret = ipa_modem_stop(ipa);
}
if (ret)
return ret;
if (ret) {
/*
* Not cleaning up here properly might also yield a
* crash later on. As the device is still unregistered
* in this case, this might even yield a crash later on.
*/
dev_err(dev, "Failed to stop modem (%pe), leaking resources\n",
ERR_PTR(ret));
return;
}
ipa_teardown(ipa);
}
......@@ -985,17 +993,6 @@ static int ipa_remove(struct platform_device *pdev)
ipa_power_exit(power);
dev_info(dev, "IPA driver removed");
return 0;
}
static void ipa_shutdown(struct platform_device *pdev)
{
int ret;
ret = ipa_remove(pdev);
if (ret)
dev_err(&pdev->dev, "shutdown: remove returned %d\n", ret);
}
static const struct attribute_group *ipa_attribute_groups[] = {
......@@ -1008,8 +1005,8 @@ static const struct attribute_group *ipa_attribute_groups[] = {
static struct platform_driver ipa_driver = {
.probe = ipa_probe,
.remove = ipa_remove,
.shutdown = ipa_shutdown,
.remove_new = ipa_remove,
.shutdown = ipa_remove,
.driver = {
.name = "ipa",
.pm = &ipa_pm_ops,
......
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