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

libnvdimm: Make remove callback return void

All drivers return 0 in their remove callback and the driver core ignores
the return value of nvdimm_bus_remove() anyhow. So simplify by changing
the driver remove callback to return void and return 0 unconditionally
to the upper layer.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20210212171043.2136580-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Uwe Kleine-König and committed by
Dan Williams
1f975074 8409f942

+11 -22
+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 -3
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 119 ··· 121 121 dev_set_drvdata(dev, NULL); 122 122 nvdimm_bus_unlock(dev); 123 123 put_ndd(ndd); 124 - 125 - return 0; 126 124 } 127 125 128 126 static struct nd_device_driver nvdimm_driver = {
+1 -3
drivers/nvdimm/pmem.c
··· 564 564 return pmem_attach_disk(dev, ndns); 565 565 } 566 566 567 - static int nd_pmem_remove(struct device *dev) 567 + static void nd_pmem_remove(struct device *dev) 568 568 { 569 569 struct pmem_device *pmem = dev_get_drvdata(dev); 570 570 ··· 579 579 pmem->bb_state = NULL; 580 580 } 581 581 nvdimm_flush(to_nd_region(dev->parent), NULL); 582 - 583 - return 0; 584 582 } 585 583 586 584 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 };