]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
greybus: camera: Early update num_streams and flags
authorJacopo Mondi <jacopo.mondi@linaro.org>
Thu, 30 Jun 2016 14:18:00 +0000 (09:18 -0500)
committerAlex Elder <elder@linaro.org>
Wed, 6 Jul 2016 02:18:00 +0000 (21:18 -0500)
In configure_streams Operation, when returning from the greybus
operation call, we can assign the num_streams and flags variable earlier
so that if the following stream configuration inspection fails, the
caller receives the right number of configured streams anyway

Testing Done: White camera module preview and capture.
              Triggering failure during stream configuration inspection
              makes configuration fails, but avoid segfaulting as
              was previously happening

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Alex Elder <elder@linaro.org>
drivers/staging/greybus/camera.c

index c47e4244a13281b92e2b60514af9d6fbff47d400..584f85e7a02d9c7941abd08ae5af3a4e209617f6 100644 (file)
@@ -432,6 +432,9 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
                goto done;
        }
 
+       *flags = resp->flags;
+       *num_streams = resp->num_streams;
+
        for (i = 0; i < nstreams; ++i) {
                struct gb_camera_stream_config_response *cfg = &resp->config[i];
 
@@ -451,11 +454,8 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
        }
 
        if ((resp->flags & GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED) ||
-           (*flags & GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY)) {
-               *flags = resp->flags;
-               *num_streams = resp->num_streams;
+           (req->flags & GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY))
                goto done;
-       }
 
        if (gcam->state == GB_CAMERA_STATE_CONFIGURED) {
                gb_camera_teardown_data_connection(gcam);
@@ -469,15 +469,14 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
                        gb_operation_sync(gcam->connection,
                                          GB_CAMERA_TYPE_CONFIGURE_STREAMS,
                                          req, req_size, resp, resp_size);
+                       *flags = 0;
+                       *num_streams = 0;
                        goto done;
                }
 
                gcam->state = GB_CAMERA_STATE_CONFIGURED;
        }
 
-       *flags = resp->flags;
-       *num_streams = resp->num_streams;
-
 done:
        mutex_unlock(&gcam->mutex);
        kfree(req);