diff options
author | Chengguang Xu <cgxu519@gmx.com> | 2019-02-12 13:59:31 +0800 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2019-02-12 13:21:14 -0700 |
commit | 18bc04bc8a2aa95c33c6613c5fffc4d3535397f0 (patch) | |
tree | f712d693bcb34811336782b63c47f298e84cb4d8 /samples | |
parent | 16355214a54efdb82a48d77b5389ee6fcc73015e (diff) | |
download | linux-18bc04bc8a2aa95c33c6613c5fffc4d3535397f0.tar.gz linux-18bc04bc8a2aa95c33c6613c5fffc4d3535397f0.tar.bz2 linux-18bc04bc8a2aa95c33c6613c5fffc4d3535397f0.zip |
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.c | 8 |
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) { int ret = 0; - ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK, MDPY_NAME); + ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK + 1, MDPY_NAME); if (ret < 0) { pr_err("Error: failed to register mdpy_dev, err: %d\n", ret); return ret; } cdev_init(&mdpy_cdev, &vd_fops); - cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK); + cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK + 1); pr_info("%s: major %d\n", __func__, MAJOR(mdpy_devt)); mdpy_class = class_create(THIS_MODULE, MDPY_CLASS_NAME); @@ -787,7 +787,7 @@ failed2: class_destroy(mdpy_class); failed1: cdev_del(&mdpy_cdev); - unregister_chrdev_region(mdpy_devt, MINORMASK); + unregister_chrdev_region(mdpy_devt, MINORMASK + 1); return ret; } @@ -798,7 +798,7 @@ static void __exit mdpy_dev_exit(void) device_unregister(&mdpy_dev); cdev_del(&mdpy_cdev); - unregister_chrdev_region(mdpy_devt, MINORMASK); + unregister_chrdev_region(mdpy_devt, MINORMASK + 1); class_destroy(mdpy_class); mdpy_class = NULL; } |