libnvdimm: stop requiring a driver ->remove() method
[cascardo/linux.git] / drivers / nvdimm / bus.c
index fc82743..7cbc3d5 100644 (file)
@@ -40,6 +40,8 @@ static int to_nd_device_type(struct device *dev)
                return ND_DEVICE_REGION_PMEM;
        else if (is_nd_blk(dev))
                return ND_DEVICE_REGION_BLK;
+       else if (is_nd_dax(dev))
+               return ND_DEVICE_DAX_PMEM;
        else if (is_nd_pmem(dev->parent) || is_nd_blk(dev->parent))
                return nd_region_to_nstype(to_nd_region(dev->parent));
 
@@ -122,9 +124,10 @@ static int nvdimm_bus_remove(struct device *dev)
        struct nd_device_driver *nd_drv = to_nd_device_driver(dev->driver);
        struct module *provider = to_bus_provider(dev);
        struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
-       int rc;
+       int rc = 0;
 
-       rc = nd_drv->remove(dev);
+       if (nd_drv->remove)
+               rc = nd_drv->remove(dev);
        nd_region_disable(nvdimm_bus, dev);
 
        dev_dbg(&nvdimm_bus->dev, "%s.remove(%s) = %d\n", dev->driver->name,
@@ -246,6 +249,8 @@ static void nd_async_device_unregister(void *d, async_cookie_t cookie)
 
 void __nd_device_register(struct device *dev)
 {
+       if (!dev)
+               return;
        dev->bus = &nvdimm_bus_type;
        get_device(dev);
        async_schedule_domain(nd_async_device_register, dev,
@@ -292,8 +297,8 @@ int __nd_driver_register(struct nd_device_driver *nd_drv, struct module *owner,
                return -EINVAL;
        }
 
-       if (!nd_drv->probe || !nd_drv->remove) {
-               pr_debug("->probe() and ->remove() must be specified\n");
+       if (!nd_drv->probe) {
+               pr_debug("%s ->probe() must be specified\n", mod_name);
                return -EINVAL;
        }
 
@@ -407,7 +412,7 @@ static const struct nd_cmd_desc __nd_cmd_dimm_descs[] = {
        [ND_CMD_IMPLEMENTED] = { },
        [ND_CMD_SMART] = {
                .out_num = 2,
-               .out_sizes = { 4, 8, },
+               .out_sizes = { 4, 128, },
        },
        [ND_CMD_SMART_THRESHOLD] = {
                .out_num = 2,