Skip to contentSkip to conversation

media: ov2659: two fixes for ov2659 driver

PATCH In review Akinobu Mita 2 participants 5 messages Mar 30, 2019 – Apr 4, 2019

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

cover media: ov2659: two fixes for ov2659 driver

This patchset contains two fixes for ov2659 driver.

Akinobu Mita (2):
media: ov2659: make S_FMT ioctl succeed even if requested format
doesn't match
media: ov2659: fix unbalanced mutex_lock/unlock

 drivers/media/i2c/ov2659.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 media: ov2659: make S_FMT ioctl succeed even if requested format doesn't match

This driver returns an error if unsupported media bus pixel code is requested by VIDIOC_SUBDEV_S_FMT.

But according to Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst,

Drivers must not return an error solely because the requested format doesn't match the device capabilities. They must instead modify the format to match what the hardware can provide.

So select default format code and return success in that case.

This is detected by v4l2-compliance.

Cc "Lad, Prabhakar" <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ov2659.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/i2c/ov2659.c +4 -2
index 799acce..a1e9a98 100644
@@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
 		if (ov2659_formats[index].code == mf->code)
 			break;
 
-	if (index < 0)
-		return -EINVAL;
+	if (index < 0) {
+		index = 0;
+		mf->code = ov2659_formats[index].code;
+	}
 
 	mf->colorspace = V4L2_COLORSPACE_SRGB;
 	mf->field = V4L2_FIELD_NONE;
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] media: ov2659: make S_FMT ioctl succeed even if requested format doesn't match

Hi Akinobu,

Thanks for the patch.

Quoted 14 lines · Akinobu Mita

This driver returns an error if unsupported media bus pixel code is requested by VIDIOC_SUBDEV_S_FMT.

But according to Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst,

Drivers must not return an error solely because the requested format doesn't match the device capabilities. They must instead modify the format to match what the hardware can provide.

So select default format code and return success in that case.

This is detected by v4l2-compliance.

Quoted 8 lines
Cc "Lad, Prabhakar" <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ov2659.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Cheers,
--Prabhakar Lad

Quoted 20 lines
drivers/media/i2c/ov2659.c +4 -3
index 799acce..a1e9a98 100644
@@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
                if (ov2659_formats[index].code == mf->code)
                        break;
 
-       if (index < 0)
-               return -EINVAL;
+       if (index < 0) {
+               index = 0;
+               mf->code = ov2659_formats[index].code;
+       }
 
        mf->colorspace = V4L2_COLORSPACE_SRGB;
        mf->field = V4L2_FIELD_NONE;
--

2.7.4

#3 lore raw

PATCH 2/2 media: ov2659: fix unbalanced mutex_lock/unlock

In reply to Akinobu Mita

Avoid returning with mutex locked.

Fixes fa8cb6444c32 ("[media] ov2659: Don't depend on subdev API")
Cc "Lad, Prabhakar" <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ov2659.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov2659.c +1 -1
index a1e9a98..5ed2413 100644
@@ -1132,7 +1132,7 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
 		mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
 		*mf = fmt->format;
 #else
-		return -ENOTTY;
+		ret = -ENOTTY;
 #endif
 	} else {
 		s64 val;
Signature · 1 line
2.7.4
maintainer Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] media: ov2659: fix unbalanced mutex_lock/unlock

Hi Akinobu,

Thanks for the patch.

Quoted 12 lines · Akinobu Mita

Avoid returning with mutex locked.

Fixes fa8cb6444c32 ("[media] ov2659: Don't depend on subdev API")
Cc "Lad, Prabhakar" <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ov2659.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Cheers,
--Prabhakar Lad

Quoted 16 lines
drivers/media/i2c/ov2659.c +1 -2
index a1e9a98..5ed2413 100644
@@ -1132,7 +1132,7 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
                mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
                *mf = fmt->format;
 #else
-               return -ENOTTY;
+               ret = -ENOTTY;
 #endif
        } else {
                s64 val;
--

2.7.4