Commit 7f93eab7 authored by Jacopo Mondi's avatar Jacopo Mondi Committed by Alex Elder

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: default avatarJacopo Mondi <jacopo.mondi@linaro.org>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
parent e65579e3
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment