Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'libnvdimm-for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm

Pull libnvdimm and device-dax updates from Dan Williams:

- Fix the error code polarity for the device-dax/mapping attribute

- For the device-dax and libnvdimm bus implementations stop
implementing a useless return code for the remove() callback.

- Miscellaneous cleanups

* tag 'libnvdimm-for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
dax-device: Make remove callback return void
device-dax: Drop an empty .remove callback
device-dax: Fix error path in dax_driver_register
device-dax: Properly handle drivers without remove callback
device-dax: Prevent registering drivers without probe callback
libnvdimm: Make remove callback return void
libnvdimm/dimm: Simplify nvdimm_remove()
device-dax: Fix default return code of range_parse()

+36 -41
+21 -3
drivers/dax/bus.c
··· 179 179 struct dax_device_driver *dax_drv = to_dax_drv(dev->driver); 180 180 struct dev_dax *dev_dax = to_dev_dax(dev); 181 181 182 - return dax_drv->remove(dev_dax); 182 + if (dax_drv->remove) 183 + dax_drv->remove(dev_dax); 184 + 185 + return 0; 183 186 } 184 187 185 188 static struct bus_type dax_bus_type = { ··· 1041 1038 { 1042 1039 unsigned long long addr = 0; 1043 1040 char *start, *end, *str; 1044 - ssize_t rc = EINVAL; 1041 + ssize_t rc = -EINVAL; 1045 1042 1046 1043 str = kstrdup(opt, GFP_KERNEL); 1047 1044 if (!str) ··· 1395 1392 struct device_driver *drv = &dax_drv->drv; 1396 1393 int rc = 0; 1397 1394 1395 + /* 1396 + * dax_bus_probe() calls dax_drv->probe() unconditionally. 1397 + * So better be safe than sorry and ensure it is provided. 1398 + */ 1399 + if (!dax_drv->probe) 1400 + return -EINVAL; 1401 + 1398 1402 INIT_LIST_HEAD(&dax_drv->ids); 1399 1403 drv->owner = module; 1400 1404 drv->name = mod_name; ··· 1419 1409 mutex_unlock(&dax_bus_lock); 1420 1410 if (rc) 1421 1411 return rc; 1422 - return driver_register(drv); 1412 + 1413 + rc = driver_register(drv); 1414 + if (rc && dax_drv->match_always) { 1415 + mutex_lock(&dax_bus_lock); 1416 + match_always_count -= dax_drv->match_always; 1417 + mutex_unlock(&dax_bus_lock); 1418 + } 1419 + 1420 + return rc; 1423 1421 } 1424 1422 EXPORT_SYMBOL_GPL(__dax_driver_register); 1425 1423
+1 -1
drivers/dax/bus.h
··· 39 39 struct list_head ids; 40 40 int match_always; 41 41 int (*probe)(struct dev_dax *dev); 42 - int (*remove)(struct dev_dax *dev); 42 + void (*remove)(struct dev_dax *dev); 43 43 }; 44 44 45 45 int __dax_driver_register(struct dax_device_driver *dax_drv,
+1 -7
drivers/dax/device.c
··· 452 452 } 453 453 EXPORT_SYMBOL_GPL(dev_dax_probe); 454 454 455 - static int dev_dax_remove(struct dev_dax *dev_dax) 456 - { 457 - /* all probe actions are unwound by devm */ 458 - return 0; 459 - } 460 - 461 455 static struct dax_device_driver device_dax_driver = { 462 456 .probe = dev_dax_probe, 463 - .remove = dev_dax_remove, 457 + /* all probe actions are unwound by devm, so .remove isn't necessary */ 464 458 .match_always = 1, 465 459 }; 466 460
+2 -5
drivers/dax/kmem.c
··· 136 136 } 137 137 138 138 #ifdef CONFIG_MEMORY_HOTREMOVE 139 - static int dev_dax_kmem_remove(struct dev_dax *dev_dax) 139 + static void dev_dax_kmem_remove(struct dev_dax *dev_dax) 140 140 { 141 141 int i, success = 0; 142 142 struct device *dev = &dev_dax->dev; ··· 176 176 kfree(data); 177 177 dev_set_drvdata(dev, NULL); 178 178 } 179 - 180 - return 0; 181 179 } 182 180 #else 183 - static int dev_dax_kmem_remove(struct dev_dax *dev_dax) 181 + static void dev_dax_kmem_remove(struct dev_dax *dev_dax) 184 182 { 185 183 /* 186 184 * Without hotremove purposely leak the request_mem_region() for the ··· 188 190 * request_mem_region(). 189 191 */ 190 192 any_hotremove_failed = true; 191 - return 0; 192 193 } 193 194 #endif /* CONFIG_MEMORY_HOTREMOVE */ 194 195
+1 -2
drivers/dax/pmem/compat.c
··· 41 41 return 0; 42 42 } 43 43 44 - static int dax_pmem_compat_remove(struct device *dev) 44 + static void dax_pmem_compat_remove(struct device *dev) 45 45 { 46 46 device_for_each_child(dev, NULL, dax_pmem_compat_release); 47 - return 0; 48 47 } 49 48 50 49 static struct nd_device_driver dax_pmem_compat_driver = {
+1 -2
drivers/nvdimm/blk.c
··· 310 310 return nsblk_attach_disk(nsblk); 311 311 } 312 312 313 - static int nd_blk_remove(struct device *dev) 313 + static void nd_blk_remove(struct device *dev) 314 314 { 315 315 if (is_nd_btt(dev)) 316 316 nvdimm_namespace_detach_btt(to_nd_btt(dev)); 317 - return 0; 318 317 } 319 318 320 319 static struct nd_device_driver nd_blk_driver = {
+5 -8
drivers/nvdimm/bus.c
··· 113 113 struct nd_device_driver *nd_drv = to_nd_device_driver(dev->driver); 114 114 struct module *provider = to_bus_provider(dev); 115 115 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); 116 - int rc = 0; 117 116 118 117 if (nd_drv->remove) { 119 118 debug_nvdimm_lock(dev); 120 - rc = nd_drv->remove(dev); 119 + nd_drv->remove(dev); 121 120 debug_nvdimm_unlock(dev); 122 121 } 123 122 124 - dev_dbg(&nvdimm_bus->dev, "%s.remove(%s) = %d\n", dev->driver->name, 125 - dev_name(dev), rc); 123 + dev_dbg(&nvdimm_bus->dev, "%s.remove(%s)\n", dev->driver->name, 124 + dev_name(dev)); 126 125 module_put(provider); 127 - return rc; 126 + return 0; 128 127 } 129 128 130 129 static void nvdimm_bus_shutdown(struct device *dev) ··· 426 427 list_del_init(badrange_list); 427 428 } 428 429 429 - static int nd_bus_remove(struct device *dev) 430 + static void nd_bus_remove(struct device *dev) 430 431 { 431 432 struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev); 432 433 ··· 445 446 spin_unlock(&nvdimm_bus->badrange.lock); 446 447 447 448 nvdimm_bus_destroy_ndctl(nvdimm_bus); 448 - 449 - return 0; 450 449 } 451 450 452 451 static int nd_bus_probe(struct device *dev)
+1 -6
drivers/nvdimm/dimm.c
··· 113 113 return rc; 114 114 } 115 115 116 - static int nvdimm_remove(struct device *dev) 116 + static void nvdimm_remove(struct device *dev) 117 117 { 118 118 struct nvdimm_drvdata *ndd = dev_get_drvdata(dev); 119 - 120 - if (!ndd) 121 - return 0; 122 119 123 120 nvdimm_bus_lock(dev); 124 121 dev_set_drvdata(dev, NULL); 125 122 nvdimm_bus_unlock(dev); 126 123 put_ndd(ndd); 127 - 128 - return 0; 129 124 } 130 125 131 126 static struct nd_device_driver nvdimm_driver = {
+1 -3
drivers/nvdimm/pmem.c
··· 563 563 return pmem_attach_disk(dev, ndns); 564 564 } 565 565 566 - static int nd_pmem_remove(struct device *dev) 566 + static void nd_pmem_remove(struct device *dev) 567 567 { 568 568 struct pmem_device *pmem = dev_get_drvdata(dev); 569 569 ··· 578 578 pmem->bb_state = NULL; 579 579 } 580 580 nvdimm_flush(to_nd_region(dev->parent), NULL); 581 - 582 - return 0; 583 581 } 584 582 585 583 static void nd_pmem_shutdown(struct device *dev)
+1 -3
drivers/nvdimm/region.c
··· 87 87 return 0; 88 88 } 89 89 90 - static int nd_region_remove(struct device *dev) 90 + static void nd_region_remove(struct device *dev) 91 91 { 92 92 struct nd_region *nd_region = to_nd_region(dev); 93 93 ··· 108 108 */ 109 109 sysfs_put(nd_region->bb_state); 110 110 nd_region->bb_state = NULL; 111 - 112 - return 0; 113 111 } 114 112 115 113 static int child_notify(struct device *dev, void *data)
+1 -1
include/linux/nd.h
··· 26 26 struct device_driver drv; 27 27 unsigned long type; 28 28 int (*probe)(struct device *dev); 29 - int (*remove)(struct device *dev); 29 + void (*remove)(struct device *dev); 30 30 void (*shutdown)(struct device *dev); 31 31 void (*notify)(struct device *dev, enum nvdimm_event event); 32 32 };