OSDN Git Service

staging: bcm2835-camera: Refactored get_format function
authorNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Tue, 28 Feb 2017 23:52:53 +0000 (01:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Mar 2017 08:39:54 +0000 (09:39 +0100)
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.

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c

index 1baeef4..53e275e 100644 (file)
@@ -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;
 }
 
 /* ------------------------------------------------------------------