aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@gmx.com>2019-02-12 00:59:31 -0500
committerAlex Williamson <alex.williamson@redhat.com>2019-02-12 15:21:14 -0500
commit18bc04bc8a2aa95c33c6613c5fffc4d3535397f0 (patch)
treef712d693bcb34811336782b63c47f298e84cb4d8 /samples
parent16355214a54efdb82a48d77b5389ee6fcc73015e (diff)
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>
Diffstat (limited to 'samples')
-rw-r--r--samples/vfio-mdev/mdpy.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
index 96e7969c473a..cc86bf6566e4 100644
--- a/samples/vfio-mdev/mdpy.c
+++ b/samples/vfio-mdev/mdpy.c
@@ -752,13 +752,13 @@ static int __init mdpy_dev_init(void)
752{ 752{
753 int ret = 0; 753 int ret = 0;
754 754
755 ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK, MDPY_NAME); 755 ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK + 1, MDPY_NAME);
756 if (ret < 0) { 756 if (ret < 0) {
757 pr_err("Error: failed to register mdpy_dev, err: %d\n", ret); 757 pr_err("Error: failed to register mdpy_dev, err: %d\n", ret);
758 return ret; 758 return ret;
759 } 759 }
760 cdev_init(&mdpy_cdev, &vd_fops); 760 cdev_init(&mdpy_cdev, &vd_fops);
761 cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK); 761 cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK + 1);
762 pr_info("%s: major %d\n", __func__, MAJOR(mdpy_devt)); 762 pr_info("%s: major %d\n", __func__, MAJOR(mdpy_devt));
763 763
764 mdpy_class = class_create(THIS_MODULE, MDPY_CLASS_NAME); 764 mdpy_class = class_create(THIS_MODULE, MDPY_CLASS_NAME);
@@ -787,7 +787,7 @@ failed2:
787 class_destroy(mdpy_class); 787 class_destroy(mdpy_class);
788failed1: 788failed1:
789 cdev_del(&mdpy_cdev); 789 cdev_del(&mdpy_cdev);
790 unregister_chrdev_region(mdpy_devt, MINORMASK); 790 unregister_chrdev_region(mdpy_devt, MINORMASK + 1);
791 return ret; 791 return ret;
792} 792}
793 793
@@ -798,7 +798,7 @@ static void __exit mdpy_dev_exit(void)
798 798
799 device_unregister(&mdpy_dev); 799 device_unregister(&mdpy_dev);
800 cdev_del(&mdpy_cdev); 800 cdev_del(&mdpy_cdev);
801 unregister_chrdev_region(mdpy_devt, MINORMASK); 801 unregister_chrdev_region(mdpy_devt, MINORMASK + 1);
802 class_destroy(mdpy_class); 802 class_destroy(mdpy_class);
803 mdpy_class = NULL; 803 mdpy_class = NULL;
804} 804}