From: Johan Hovold <johan@kernel.org>
To: Ilya Dryomov <idryomov@gmail.com>
Cc: Dongsheng Yang <dongsheng.yang@linux.dev>,
Jens Axboe <axboe@kernel.dk>,
ceph-devel@vger.kernel.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH] block: rbd: switch to dynamic root device
Date: Fri, 24 Apr 2026 12:39:31 +0200 [thread overview]
Message-ID: <20260424103931.2616903-1-johan@kernel.org> (raw)
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 <johan@kernel.org>
---
drivers/block/rbd.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e7da06200c1e..ffab1b4e7c25 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -580,14 +580,7 @@ static const struct bus_type rbd_bus_type = {
.bus_groups = rbd_bus_groups,
};
-static void rbd_root_dev_release(struct device *dev)
-{
-}
-
-static struct device rbd_root_dev = {
- .init_name = "rbd",
- .release = rbd_root_dev_release,
-};
+static struct device *rbd_root_dev;
static __printf(2, 3)
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)
rbd_dev->dev.bus = &rbd_bus_type;
rbd_dev->dev.type = &rbd_device_type;
- rbd_dev->dev.parent = &rbd_root_dev;
+ rbd_dev->dev.parent = rbd_root_dev;
device_initialize(&rbd_dev->dev);
return rbd_dev;
@@ -7331,15 +7324,13 @@ static int __init rbd_sysfs_init(void)
{
int ret;
- ret = device_register(&rbd_root_dev);
- if (ret < 0) {
- put_device(&rbd_root_dev);
- return ret;
- }
+ rbd_root_dev = root_device_register("rbd");
+ if (IS_ERR(rbd_root_dev))
+ return PTR_ERR(rbd_root_dev);
ret = bus_register(&rbd_bus_type);
if (ret < 0)
- device_unregister(&rbd_root_dev);
+ root_device_unregister(rbd_root_dev);
return ret;
}
@@ -7347,7 +7338,7 @@ static int __init rbd_sysfs_init(void)
static void __exit rbd_sysfs_cleanup(void)
{
bus_unregister(&rbd_bus_type);
- device_unregister(&rbd_root_dev);
+ root_device_unregister(rbd_root_dev);
}
static int __init rbd_slab_init(void)
--
2.53.0
next reply other threads:[~2026-04-24 10:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 10:39 Johan Hovold [this message]
2026-04-24 18:48 ` [PATCH] block: rbd: switch to dynamic root device Viacheslav Dubeyko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260424103931.2616903-1-johan@kernel.org \
--to=johan@kernel.org \
--cc=axboe@kernel.dk \
--cc=ceph-devel@vger.kernel.org \
--cc=dongsheng.yang@linux.dev \
--cc=idryomov@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox