From 36ab1108b60eb649c7c0f0653f854afc1234cfcb Mon Sep 17 00:00:00 2001
From: Jacopo Mondi <jacopo.mondi@linaro.org>
Date: Thu, 30 Jun 2016 09:18:00 -0500
Subject: [PATCH] greybus: camera: Fix number of configured streams

Camera Module may report a lower number of configured streams than the
one requested by the AP.
All the non-supported stream configuration are zeroed.
Make the stream configuration inspection loop take only the valid stream
into account, to avoid unnecessarily accessing zeroed memory areas.

So far, inspecting non valid streams configuration has prove to be
harmless, but as we'll need to inspect stream characteristics as reported
image sizes and format, we have to take only valid configurations into
account.

Testing Done: White Camera Module preview and capture.

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
index 584f85e7a02d9..41891b24ef05c 100644
--- a/drivers/staging/greybus/camera.c
+++ b/drivers/staging/greybus/camera.c
@@ -435,7 +435,7 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
 	*flags = resp->flags;
 	*num_streams = resp->num_streams;
 
-	for (i = 0; i < nstreams; ++i) {
+	for (i = 0; i < resp->num_streams; ++i) {
 		struct gb_camera_stream_config_response *cfg = &resp->config[i];
 
 		streams[i].width = le16_to_cpu(cfg->width);
-- 
2.30.2