device-dax: Properly handle drivers without remove callback

If all resources are allocated in .probe() using devm_ functions it
might make sense to not provide a .remove() callback. Then the right
thing is to just return success.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20210205222842.34896-3-uwe@kleine-koenig.org
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
Uwe Kleine-König 2021-02-05 23:28:39 +01:00 committed by Dan Williams
parent 5b8e64f1ad
commit 8029968e2a
1 changed files with 5 additions and 1 deletions

View File

@ -178,8 +178,12 @@ static int dax_bus_remove(struct device *dev)
{
struct dax_device_driver *dax_drv = to_dax_drv(dev->driver);
struct dev_dax *dev_dax = to_dev_dax(dev);
int ret = 0;
return dax_drv->remove(dev_dax);
if (dax_drv->remove)
ret = dax_drv->remove(dev_dax);
return ret;
}
static struct bus_type dax_bus_type = {