media: vpbe_display: properly handle error case
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 6 Apr 2018 12:12:51 +0000 (08:12 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 17 Apr 2018 09:29:32 +0000 (05:29 -0400)
if v4l2_subdev_call(..., VENC_GET_FLD,...) fails, it
currently returns a random value. Instead, return 1.

That's probably better than returning 0, as this is very
likely what happens in practice with the current code, as
as the probably of an unititialized 32 bits integer to
have an specific value (0, in this case), is 1/(2^32).

An alternative would be to return an error code, and
let the caller to hint, based on the past received
frame, but that sounds weird.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/davinci/vpbe_display.c

index 9849e44..a0b5e67 100644 (file)
@@ -56,8 +56,7 @@ static int vpbe_set_osd_display_params(struct vpbe_display *disp_dev,
 static int venc_is_second_field(struct vpbe_display *disp_dev)
 {
        struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
-       int ret;
-       int val;
+       int ret, val;
 
        ret = v4l2_subdev_call(vpbe_dev->venc,
                               core,
@@ -67,6 +66,7 @@ static int venc_is_second_field(struct vpbe_display *disp_dev)
        if (ret < 0) {
                v4l2_err(&vpbe_dev->v4l2_dev,
                         "Error in getting Field ID 0\n");
+               return 1;
        }
        return val;
 }