Skip to content

Commit e31dac3

Browse files
jhovoldkawasaki
authored andcommitted
block: rbd: switch to dynamic root device
Driver core expects devices to be dynamically allocated and will, for example, complain loudly when no release function has been provided. Use root_device_register() to allocate and register the root device instead of open coding using a static device. Signed-off-by: Johan Hovold <[email protected]>
1 parent 857ada9 commit e31dac3

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

drivers/block/rbd.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -580,14 +580,7 @@ static const struct bus_type rbd_bus_type = {
580580
.bus_groups = rbd_bus_groups,
581581
};
582582

583-
static void rbd_root_dev_release(struct device *dev)
584-
{
585-
}
586-
587-
static struct device rbd_root_dev = {
588-
.init_name = "rbd",
589-
.release = rbd_root_dev_release,
590-
};
583+
static struct device *rbd_root_dev;
591584

592585
static __printf(2, 3)
593586
void rbd_warn(struct rbd_device *rbd_dev, const char *fmt, ...)
@@ -5390,7 +5383,7 @@ static struct rbd_device *__rbd_dev_create(struct rbd_spec *spec)
53905383

53915384
rbd_dev->dev.bus = &rbd_bus_type;
53925385
rbd_dev->dev.type = &rbd_device_type;
5393-
rbd_dev->dev.parent = &rbd_root_dev;
5386+
rbd_dev->dev.parent = rbd_root_dev;
53945387
device_initialize(&rbd_dev->dev);
53955388

53965389
return rbd_dev;
@@ -7331,23 +7324,21 @@ static int __init rbd_sysfs_init(void)
73317324
{
73327325
int ret;
73337326

7334-
ret = device_register(&rbd_root_dev);
7335-
if (ret < 0) {
7336-
put_device(&rbd_root_dev);
7337-
return ret;
7338-
}
7327+
rbd_root_dev = root_device_register("rbd");
7328+
if (IS_ERR(rbd_root_dev))
7329+
return PTR_ERR(rbd_root_dev);
73397330

73407331
ret = bus_register(&rbd_bus_type);
73417332
if (ret < 0)
7342-
device_unregister(&rbd_root_dev);
7333+
root_device_unregister(rbd_root_dev);
73437334

73447335
return ret;
73457336
}
73467337

73477338
static void __exit rbd_sysfs_cleanup(void)
73487339
{
73497340
bus_unregister(&rbd_bus_type);
7350-
device_unregister(&rbd_root_dev);
7341+
root_device_unregister(rbd_root_dev);
73517342
}
73527343

73537344
static int __init rbd_slab_init(void)

0 commit comments

Comments
 (0)