summaryrefslogtreecommitdiff
path: root/samples/vfio-mdev/mtty.c
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@gmx.com>2019-02-12 08:59:32 +0300
committerAlex Williamson <alex.williamson@redhat.com>2019-02-12 23:21:18 +0300
commit3e4835f7d7a84ab022682aaeecaae5c508aeb76c (patch)
treeb64f07cab3b4dbf49e25dcb6f0c5046d066e6f9f /samples/vfio-mdev/mtty.c
parent18bc04bc8a2aa95c33c6613c5fffc4d3535397f0 (diff)
downloadlinux-3e4835f7d7a84ab022682aaeecaae5c508aeb76c.tar.xz
samples/vfio-mdev/mtty: 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/vfio-mdev/mtty.c')
-rw-r--r--samples/vfio-mdev/mtty.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 19cd29071ab0..1c77c370c92f 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -1442,7 +1442,8 @@ static int __init mtty_dev_init(void)
idr_init(&mtty_dev.vd_idr);
- ret = alloc_chrdev_region(&mtty_dev.vd_devt, 0, MINORMASK, MTTY_NAME);
+ ret = alloc_chrdev_region(&mtty_dev.vd_devt, 0, MINORMASK + 1,
+ MTTY_NAME);
if (ret < 0) {
pr_err("Error: failed to register mtty_dev, err:%d\n", ret);
@@ -1450,7 +1451,7 @@ static int __init mtty_dev_init(void)
}
cdev_init(&mtty_dev.vd_cdev, &vd_fops);
- cdev_add(&mtty_dev.vd_cdev, mtty_dev.vd_devt, MINORMASK);
+ cdev_add(&mtty_dev.vd_cdev, mtty_dev.vd_devt, MINORMASK + 1);
pr_info("major_number:%d\n", MAJOR(mtty_dev.vd_devt));
@@ -1487,7 +1488,7 @@ failed2:
failed1:
cdev_del(&mtty_dev.vd_cdev);
- unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK);
+ unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK + 1);
all_done:
return ret;
@@ -1501,7 +1502,7 @@ static void __exit mtty_dev_exit(void)
device_unregister(&mtty_dev.dev);
idr_destroy(&mtty_dev.vd_idr);
cdev_del(&mtty_dev.vd_cdev);
- unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK);
+ unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK + 1);
class_destroy(mtty_dev.vd_class);
mtty_dev.vd_class = NULL;
pr_info("mtty_dev: Unloaded!\n");