Skip to content

Commit

Permalink
driver core: platform: Emit a warning if a remove callback returned n…
Browse files Browse the repository at this point in the history
…on-zero

The driver core ignores the return value of a bus' remove callback. However
a driver returning an error code is a hint that there is a problem,
probably a driver author who expects that returning e.g. -EBUSY has any
effect.

The right thing to do would be to make struct platform_driver::remove()
return void. With the immense number of platform drivers this is however a
big quest and I hope to prevent at least a few new drivers that return an
error code here.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20210207211537.19992-1-uwe@kleine-koenig.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Uwe Kleine-König authored and Greg Kroah-Hartman committed Feb 9, 2021
1 parent f265f06 commit e5e1c20
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,13 +1463,16 @@ static int platform_remove(struct device *_dev)
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
int ret = 0;

if (drv->remove)
ret = drv->remove(dev);
if (drv->remove) {
int ret = drv->remove(dev);

if (ret)
dev_warn(_dev, "remove callback returned a non-zero value. This will be ignored.\n");
}
dev_pm_domain_detach(_dev, true);

return ret;
return 0;
}

static void platform_shutdown(struct device *_dev)
Expand Down

0 comments on commit e5e1c20

Please sign in to comment.