Re: [PATCH v1 1/3] virtio-blk: add virtio-blk chardev support.

From: Jingbo Xu
Date: Mon Jan 06 2025 - 23:53:45 EST




On 12/18/24 5:24 PM, Ferry Meng wrote:

> +static int virtblk_cdev_add(struct virtio_blk *vblk,
> + const struct file_operations *fops)

@fops argument is not necessary, as currently virtblk_chr_fops is the
only valid value.


> @@ -1690,7 +1770,9 @@ static void __exit virtio_blk_fini(void)
> {
> unregister_virtio_driver(&virtio_blk);
> unregister_blkdev(major, "virtblk");
> + unregister_chrdev_region(vd_chr_devt, VIRTBLK_MINORS);

Better to call "unregister_chrdev_region(vd_chr_devt, VIRTBLK_MINORS)"
before "unregister_blkdev(major, "virtblk")" to follow the convention
that the order of the cleanup routine is exactly the reverse of that of
the init routine.

> destroy_workqueue(virtblk_wq);
> + ida_destroy(&vd_chr_minor_ida);
> }
> module_init(virtio_blk_init);
> module_exit(virtio_blk_fini);

--
Thanks,
Jingbo