]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00178052 v4l2_capture:Correct multi-sensor uninstallation
authorYuxi Sun <b36102@freescale.com>
Tue, 27 Mar 2012 06:15:39 +0000 (14:15 +0800)
committerOliver Wendt <ow@karo-electronics.de>
Mon, 30 Sep 2013 12:11:22 +0000 (14:11 +0200)
Point the current sensor to the right existent camera,
and remove the detached one

Signed-off-by: Yuxi Sun <b36102@freescale.com>
drivers/media/video/mxc/capture/mxc_v4l2_capture.c

index e3af2f817990e01c28a41e98437900bddce612ce..9d5fd09ef48af64cee13a091d1fa33f11cb839aa 100644 (file)
@@ -2890,7 +2890,28 @@ static int mxc_v4l2_master_attach(struct v4l2_int_device *slave)
  */
 static void mxc_v4l2_master_detach(struct v4l2_int_device *slave)
 {
+       unsigned int i;
+       cam_data *cam = slave->u.slave->master->priv;
+
        pr_debug("In MVC:mxc_v4l2_master_detach\n");
+
+       if (sensor_index > 1) {
+               for (i = 0; i < sensor_index; i++) {
+                       if (cam->all_sensors[i] != slave)
+                               continue;
+                       /* Move all the sensors behind this
+                        * sensor one step forward
+                        */
+                       for (; i < sensor_index - 1; i++)
+                               cam->all_sensors[i] = cam->all_sensors[i+1];
+                       break;
+               }
+               /* Point current sensor to the last one */
+               cam->sensor = cam->all_sensors[sensor_index - 2];
+       } else
+               cam->sensor = NULL;
+
+       sensor_index--;
        vidioc_int_dev_exit(slave);
 }