Skip to content

Commit 18bc04b

Browse files
Chengguang XuAlex Williamson
authored andcommitted
samples/vfio-mdev/mdpy: expand minor range when registering chrdev region
Actually, total amount of available minor number for a single major is MINORMARK + 1. So expand minor range when registering chrdev region. Signed-off-by: Chengguang Xu <cgxu519@gmx.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 1635521 commit 18bc04b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎samples/vfio-mdev/mdpy.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,13 +752,13 @@ static int __init mdpy_dev_init(void)
752752
{
753753
int ret = 0;
754754

755-
ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK, MDPY_NAME);
755+
ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK + 1, MDPY_NAME);
756756
if (ret < 0) {
757757
pr_err("Error: failed to register mdpy_dev, err: %d\n", ret);
758758
return ret;
759759
}
760760
cdev_init(&mdpy_cdev, &vd_fops);
761-
cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK);
761+
cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK + 1);
762762
pr_info("%s: major %d\n", __func__, MAJOR(mdpy_devt));
763763

764764
mdpy_class = class_create(THIS_MODULE, MDPY_CLASS_NAME);
@@ -787,7 +787,7 @@ static int __init mdpy_dev_init(void)
787787
class_destroy(mdpy_class);
788788
failed1:
789789
cdev_del(&mdpy_cdev);
790-
unregister_chrdev_region(mdpy_devt, MINORMASK);
790+
unregister_chrdev_region(mdpy_devt, MINORMASK + 1);
791791
return ret;
792792
}
793793

@@ -798,7 +798,7 @@ static void __exit mdpy_dev_exit(void)
798798

799799
device_unregister(&mdpy_dev);
800800
cdev_del(&mdpy_cdev);
801-
unregister_chrdev_region(mdpy_devt, MINORMASK);
801+
unregister_chrdev_region(mdpy_devt, MINORMASK + 1);
802802
class_destroy(mdpy_class);
803803
mdpy_class = NULL;
804804
}

0 commit comments

Comments
 (0)