rpmsg: use hil_free_vqs to delete virtqueues
authorWendy Liang <jliang@xilinx.com>
Tue, 24 Jan 2017 22:45:11 +0000 (14:45 -0800)
committerWendy Liang <jliang@xilinx.com>
Fri, 3 Feb 2017 21:41:23 +0000 (13:41 -0800)
Use hil_free_vqs to delete virtqueues of the specified vdev.

Signed-off-by: Wendy Liang <jliang@xilinx.com>
lib/rpmsg/remote_device.c

index 1d038cbdebcd1572a044f470a16ef04937b37dd5..e9d690c3b38305bd149e42f59e53cb1bf56c7ca7 100644 (file)
@@ -214,20 +214,21 @@ void rpmsg_rdev_deinit(struct remote_device *rdev)
                _destroy_endpoint(rdev, rp_ept);
        }
 
-       if (rdev->rvq) {
-               virtqueue_free(rdev->rvq);
-       }
-       if (rdev->tvq) {
-               virtqueue_free(rdev->tvq);
-       }
+       metal_mutex_acquire(&rdev->lock);
+       rdev->rvq = 0;
+       rdev->tvq = 0;
        if (rdev->mem_pool) {
                sh_mem_delete_pool(rdev->mem_pool);
+               rdev->mem_pool = 0;
        }
-       metal_mutex_deinit(&rdev->lock);
+       metal_mutex_release(&rdev->lock);
+       hil_free_vqs(&rdev->virt_dev);
+
        if (rdev->proc) {
                hil_delete_proc(rdev->proc);
                rdev->proc = 0;
        }
+       metal_mutex_deinit(&rdev->lock);
 
        metal_free_memory(rdev);
 }