Skip to contentSkip to conversation

staging: bcm2835-camera: Refactored get_format function

PATCH New Narcisa Ana Maria Vasile 1 participant 1 message Feb 28, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: bcm2835-camera: Refactored get_format function

Now, when the condition inside the for is fulfilled, I return the result, instead of checking afterwards whether the counter has reached or not the end of the list.

---
 drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +2 -5
index c4dad30..00e0ea2 100644
@@ -229,13 +229,10 @@ static struct mmal_fmt *get_format(struct v4l2_format *f)
 	for (k = 0; k < ARRAY_SIZE(formats); k++) {
 		fmt = &formats[k];
 		if (fmt->fourcc == f->fmt.pix.pixelformat)
-			break;
+			return fmt;
 	}
 
-	if (k == ARRAY_SIZE(formats))
-		return NULL;
-
-	return &formats[k];
+	return NULL;
 }
 
 /* ------------------------------------------------------------------
Signature · 1 line
1.9.1