Skip to content

Commit

Permalink
libnvdimm: Make remove callback return void
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Uwe Kleine-König authored and djbw committed Feb 17, 2021
1 parent 8409f94 commit 1f97507
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 22 deletions.
3 changes: 1 addition & 2 deletions drivers/dax/pmem/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ static int dax_pmem_compat_release(struct device *dev, void *data)
return 0;
}

static int dax_pmem_compat_remove(struct device *dev)
static void dax_pmem_compat_remove(struct device *dev)
{
device_for_each_child(dev, NULL, dax_pmem_compat_release);
return 0;
}

static struct nd_device_driver dax_pmem_compat_driver = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/nvdimm/blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,10 @@ static int nd_blk_probe(struct device *dev)
return nsblk_attach_disk(nsblk);
}

static int nd_blk_remove(struct device *dev)
static void nd_blk_remove(struct device *dev)
{
if (is_nd_btt(dev))
nvdimm_namespace_detach_btt(to_nd_btt(dev));
return 0;
}

static struct nd_device_driver nd_blk_driver = {
Expand Down
13 changes: 5 additions & 8 deletions drivers/nvdimm/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,17 @@ 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 = 0;

if (nd_drv->remove) {
debug_nvdimm_lock(dev);
rc = nd_drv->remove(dev);
nd_drv->remove(dev);
debug_nvdimm_unlock(dev);
}

dev_dbg(&nvdimm_bus->dev, "%s.remove(%s) = %d\n", dev->driver->name,
dev_name(dev), rc);
dev_dbg(&nvdimm_bus->dev, "%s.remove(%s)\n", dev->driver->name,
dev_name(dev));
module_put(provider);
return rc;
return 0;
}

static void nvdimm_bus_shutdown(struct device *dev)
Expand Down Expand Up @@ -427,7 +426,7 @@ static void free_badrange_list(struct list_head *badrange_list)
list_del_init(badrange_list);
}

static int nd_bus_remove(struct device *dev)
static void nd_bus_remove(struct device *dev)
{
struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);

Expand All @@ -446,8 +445,6 @@ static int nd_bus_remove(struct device *dev)
spin_unlock(&nvdimm_bus->badrange.lock);

nvdimm_bus_destroy_ndctl(nvdimm_bus);

return 0;
}

static int nd_bus_probe(struct device *dev)
Expand Down
4 changes: 1 addition & 3 deletions drivers/nvdimm/dimm.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,14 @@ static int nvdimm_probe(struct device *dev)
return rc;
}

static int nvdimm_remove(struct device *dev)
static void nvdimm_remove(struct device *dev)
{
struct nvdimm_drvdata *ndd = dev_get_drvdata(dev);

nvdimm_bus_lock(dev);
dev_set_drvdata(dev, NULL);
nvdimm_bus_unlock(dev);
put_ndd(ndd);

return 0;
}

static struct nd_device_driver nvdimm_driver = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/nvdimm/pmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static int nd_pmem_probe(struct device *dev)
return pmem_attach_disk(dev, ndns);
}

static int nd_pmem_remove(struct device *dev)
static void nd_pmem_remove(struct device *dev)
{
struct pmem_device *pmem = dev_get_drvdata(dev);

Expand All @@ -579,8 +579,6 @@ static int nd_pmem_remove(struct device *dev)
pmem->bb_state = NULL;
}
nvdimm_flush(to_nd_region(dev->parent), NULL);

return 0;
}

static void nd_pmem_shutdown(struct device *dev)
Expand Down
4 changes: 1 addition & 3 deletions drivers/nvdimm/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static int child_unregister(struct device *dev, void *data)
return 0;
}

static int nd_region_remove(struct device *dev)
static void nd_region_remove(struct device *dev)
{
struct nd_region *nd_region = to_nd_region(dev);

Expand All @@ -108,8 +108,6 @@ static int nd_region_remove(struct device *dev)
*/
sysfs_put(nd_region->bb_state);
nd_region->bb_state = NULL;

return 0;
}

static int child_notify(struct device *dev, void *data)
Expand Down
2 changes: 1 addition & 1 deletion include/linux/nd.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct nd_device_driver {
struct device_driver drv;
unsigned long type;
int (*probe)(struct device *dev);
int (*remove)(struct device *dev);
void (*remove)(struct device *dev);
void (*shutdown)(struct device *dev);
void (*notify)(struct device *dev, enum nvdimm_event event);
};
Expand Down

0 comments on commit 1f97507

Please sign in to comment.