]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: add user_deinit
authorBryan Wu <pengw@nvidia.com>
Mon, 7 Oct 2013 18:54:05 +0000 (11:54 -0700)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Wed, 23 Oct 2013 08:07:47 +0000 (01:07 -0700)
nvhost_client_device_release() should remove those char devices for
user space, otherwise Oops will happen when call
nvhost_client_user_init() again like modprobing.

Bug 1377330

Change-Id: I98bdb347f99aa049173387dee47d90faa795e7fa
Signed-off-by: Bryan Wu <pengw@nvidia.com>
Reviewed-on: http://git-master/r/289325
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/bus_client.c

index b7bacc8f69ab7582fb8b62781ef600b70d166dd2..e2a3f99d5d6065878207f512ddc2a3bcc9291080 100644 (file)
@@ -1199,6 +1199,43 @@ fail:
        return err;
 }
 
+void nvhost_client_user_deinit(struct platform_device *dev)
+{
+       struct nvhost_master *nvhost_master = nvhost_get_host(dev);
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+       struct nvhost_channel *ch = pdata->channel;
+
+       BUG_ON(!ch);
+
+       if (ch->node) {
+               device_destroy(nvhost_master->nvhost_class, ch->cdev.dev);
+               cdev_del(&ch->cdev);
+       }
+
+       if (ch->as_node) {
+               device_destroy(nvhost_master->nvhost_class, ch->as_cdev.dev);
+               cdev_del(&ch->as_cdev);
+       }
+
+       if (pdata->ctrl_node) {
+               device_destroy(nvhost_master->nvhost_class,
+                              pdata->ctrl_cdev.dev);
+               cdev_del(&pdata->ctrl_cdev);
+       }
+
+       if (pdata->dbg_node) {
+               device_destroy(nvhost_master->nvhost_class,
+                              pdata->dbg_cdev.dev);
+               cdev_del(&pdata->dbg_cdev);
+       }
+
+       if (pdata->prof_node) {
+               device_destroy(nvhost_master->nvhost_class,
+                              pdata->prof_cdev.dev);
+               cdev_del(&pdata->prof_cdev);
+       }
+}
+
 int nvhost_client_device_init(struct platform_device *dev)
 {
        int err;
@@ -1261,7 +1298,6 @@ EXPORT_SYMBOL(nvhost_client_device_init);
 
 int nvhost_client_device_release(struct platform_device *dev)
 {
-       struct nvhost_master *nvhost_master = nvhost_get_host(dev);
        struct nvhost_channel *ch;
        struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
@@ -1274,8 +1310,7 @@ int nvhost_client_device_release(struct platform_device *dev)
        nvhost_device_list_remove(dev);
 
        /* Release chardev and device node for user space */
-       device_destroy(nvhost_master->nvhost_class, ch->cdev.dev);
-       cdev_del(&ch->cdev);
+       nvhost_client_user_deinit(dev);
 
        /* Free nvhost channel */
        nvhost_free_channel(ch);