[PATCH v2 3/3] udmabuf: Use module_misc_device() to register this device

From: Andrew Davis
Date: Thu Aug 14 2025 - 12:13:41 EST


Now that we do not need to call dma_coerce_mask_and_coherent() on our
miscdevice device, use the module_misc_device() helper for registering
and module init/exit.

While here, add module description and license, modules built with W=1
warn if built without these.

Signed-off-by: Andrew Davis <afd@xxxxxx>
Acked-by: Vivek Kasireddy <vivek.kasireddy@xxxxxxxxx>
---
drivers/dma-buf/udmabuf.c | 24 +++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index 8d71c3d72eb5e..d888e4d667c67 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -566,26 +566,8 @@ static struct miscdevice udmabuf_misc = {
.name = "udmabuf",
.fops = &udmabuf_fops,
};
-
-static int __init udmabuf_dev_init(void)
-{
- int ret;
-
- ret = misc_register(&udmabuf_misc);
- if (ret < 0) {
- pr_err("Could not initialize udmabuf device\n");
- return ret;
- }
-
- return 0;
-}
-
-static void __exit udmabuf_dev_exit(void)
-{
- misc_deregister(&udmabuf_misc);
-}
-
-module_init(udmabuf_dev_init)
-module_exit(udmabuf_dev_exit)
+module_misc_device(udmabuf_misc);

MODULE_AUTHOR("Gerd Hoffmann <kraxel@xxxxxxxxxx>");
+MODULE_DESCRIPTION("Userspace memfd to DMA-BUF misc Driver");
+MODULE_LICENSE("GPL");
--
2.39.2