diff options
author | Jacopo Mondi <jacopo.mondi@linaro.org> | 2016-06-30 09:18:00 -0500 |
---|---|---|
committer | Alex Elder <elder@linaro.org> | 2016-07-05 21:18:00 -0500 |
commit | 7f93eab7c705527b0579b1bfd4d6e9f6acc9e5ca (patch) | |
tree | c640e83cd0c9ca817a0ae2292c3a50327f17dbc7 /drivers/staging/greybus/camera.c | |
parent | e65579e335da0a65b5a76a343ddff6a6f3c77dd1 (diff) |
greybus: camera: Early update num_streams and flags
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>
Diffstat (limited to 'drivers/staging/greybus/camera.c')
-rw-r--r-- | drivers/staging/greybus/camera.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c index c47e4244a132..584f85e7a02d 100644 --- a/drivers/staging/greybus/camera.c +++ b/drivers/staging/greybus/camera.c @@ -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); |