]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: unregister char device region
authorBryan Wu <pengw@nvidia.com>
Fri, 28 Mar 2014 23:47:21 +0000 (16:47 -0700)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Wed, 2 Apr 2014 05:44:18 +0000 (22:44 -0700)
Char device region needs to be released when we unloaded module,
otherwise it cause allocation failure and kernel oops.

Bug 1490541

Change-Id: Ib95aef54f90d4f743c208f497db1ed69873cf13d
Signed-off-by: Bryan Wu <pengw@nvidia.com>
Reviewed-on: http://git-master/r/389972
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/bus_client.c
include/linux/nvhost.h

index 61e3483a714cbdd54b9f64929831577cd46af032..d584d79f96f7664923846043ac00521dbe8d0f59 100644 (file)
@@ -974,6 +974,7 @@ static struct device *nvhost_client_device_create(
        return dev;
 }
 
+#define NVHOST_NUM_CDEV 4
 int nvhost_client_user_init(struct platform_device *dev)
 {
        dev_t devno;
@@ -982,11 +983,12 @@ int nvhost_client_user_init(struct platform_device *dev)
 
        /* reserve 3 minor #s for <dev>, and ctrl-<dev> */
 
-       err = alloc_chrdev_region(&devno, 0, 4, IFACE_NAME);
+       err = alloc_chrdev_region(&devno, 0, NVHOST_NUM_CDEV, IFACE_NAME);
        if (err < 0) {
                dev_err(&dev->dev, "failed to allocate devno\n");
                goto fail;
        }
+       pdata->cdev_region = devno;
 
        pdata->node = nvhost_client_device_create(dev, &pdata->cdev,
                                "", devno, &nvhost_channelops);
@@ -1028,6 +1030,8 @@ void nvhost_client_user_deinit(struct platform_device *dev)
                               pdata->ctrl_cdev.dev);
                cdev_del(&pdata->ctrl_cdev);
        }
+
+       unregister_chrdev_region(pdata->cdev_region, NVHOST_NUM_CDEV);
 }
 
 int nvhost_client_device_init(struct platform_device *dev)
index 15fa6ad11981db47407f78dd8c8cca643085d5b2..1a4cd37f7de82eefb5ee9d8844d8bceea02d2131 100644 (file)
@@ -148,6 +148,7 @@ struct nvhost_device_data {
        struct nvhost_channel *channel; /* Channel assigned for the module */
 
        /* device node for channel operations */
+       dev_t cdev_region;
        struct device *node;
        struct cdev cdev;