Skip to content

Commit 6cf9c5b

Browse files
committed
libnvdimm: stop requiring a driver ->remove() method
The dax_pmem driver was implementing an empty ->remove() method to satisfy the nvdimm bus driver that unconditionally calls ->remove(). Teach the core bus driver to check if ->remove() is NULL to remove that requirement. Reported-by: Johannes Thumshirn <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 45a0dac commit 6cf9c5b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/nvdimm/bus.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ static int nvdimm_bus_remove(struct device *dev)
124124
struct nd_device_driver *nd_drv = to_nd_device_driver(dev->driver);
125125
struct module *provider = to_bus_provider(dev);
126126
struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
127-
int rc;
127+
int rc = 0;
128128

129-
rc = nd_drv->remove(dev);
129+
if (nd_drv->remove)
130+
rc = nd_drv->remove(dev);
130131
nd_region_disable(nvdimm_bus, dev);
131132

132133
dev_dbg(&nvdimm_bus->dev, "%s.remove(%s) = %d\n", dev->driver->name,
@@ -296,8 +297,8 @@ int __nd_driver_register(struct nd_device_driver *nd_drv, struct module *owner,
296297
return -EINVAL;
297298
}
298299

299-
if (!nd_drv->probe || !nd_drv->remove) {
300-
pr_debug("->probe() and ->remove() must be specified\n");
300+
if (!nd_drv->probe) {
301+
pr_debug("%s ->probe() must be specified\n", mod_name);
301302
return -EINVAL;
302303
}
303304

0 commit comments

Comments
 (0)