diff mbox series

[4/6] media: ov2680: get rid of extra ifdefs

Message ID 20181128171918.160643-5-lkundrak@v3.sk (mailing list archive)
State New, archived
Headers show
Series media: don't ifdef v4l2_subdev_get_try_format() any more | expand

Commit Message

Lubomir Rintel Nov. 28, 2018, 5:19 p.m. UTC
Stubbed v4l2_subdev_get_try_format() will return a correct error when
configured without CONFIG_VIDEO_V4L2_SUBDEV_API.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/media/i2c/ov2680.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

Comments

Dan Carpenter Dec. 3, 2018, 10:43 a.m. UTC | #1
Hi Lubomir,

url:    https://github.com/0day-ci/linux/commits/Lubomir-Rintel/media-don-t-ifdef-v4l2_subdev_get_try_format-any-more/20181129-205631
base:   git://linuxtv.org/media_tree.git master

smatch warnings:
drivers/media/i2c/ov2680.c:687 ov2680_get_fmt() warn: inconsistent returns 'mutex:&sensor->lock'.
  Locked on:   line 677
  Unlocked on: line 670

# https://github.com/0day-ci/linux/commit/45699a2f04294ea9ca96a3d178232ecae7f607ed
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 45699a2f04294ea9ca96a3d178232ecae7f607ed
vim +687 drivers/media/i2c/ov2680.c

3ee47cad Rui Miguel Silva 2018-07-03  660  
3ee47cad Rui Miguel Silva 2018-07-03  661  static int ov2680_get_fmt(struct v4l2_subdev *sd,
3ee47cad Rui Miguel Silva 2018-07-03  662  			  struct v4l2_subdev_pad_config *cfg,
3ee47cad Rui Miguel Silva 2018-07-03  663  			  struct v4l2_subdev_format *format)
3ee47cad Rui Miguel Silva 2018-07-03  664  {
3ee47cad Rui Miguel Silva 2018-07-03  665  	struct ov2680_dev *sensor = to_ov2680_dev(sd);
3ee47cad Rui Miguel Silva 2018-07-03  666  	struct v4l2_mbus_framefmt *fmt = NULL;
3ee47cad Rui Miguel Silva 2018-07-03  667  	int ret = 0;
3ee47cad Rui Miguel Silva 2018-07-03  668  
3ee47cad Rui Miguel Silva 2018-07-03  669  	if (format->pad != 0)
3ee47cad Rui Miguel Silva 2018-07-03  670  		return -EINVAL;
3ee47cad Rui Miguel Silva 2018-07-03  671  
3ee47cad Rui Miguel Silva 2018-07-03  672  	mutex_lock(&sensor->lock);
3ee47cad Rui Miguel Silva 2018-07-03  673  
3ee47cad Rui Miguel Silva 2018-07-03  674  	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
3ee47cad Rui Miguel Silva 2018-07-03  675  		fmt = v4l2_subdev_get_try_format(&sensor->sd, cfg, format->pad);
45699a2f Lubomir Rintel   2018-11-28  676  		if (IS_ERR(fmt))
45699a2f Lubomir Rintel   2018-11-28  677  			return PTR_ERR(fmt);
                                                                ^^^^^^^^^^^^^^^^^^^
goto unlock;

3ee47cad Rui Miguel Silva 2018-07-03  678  	} else {
3ee47cad Rui Miguel Silva 2018-07-03  679  		fmt = &sensor->fmt;
3ee47cad Rui Miguel Silva 2018-07-03  680  	}
3ee47cad Rui Miguel Silva 2018-07-03  681  
3ee47cad Rui Miguel Silva 2018-07-03  682  	if (fmt)
3ee47cad Rui Miguel Silva 2018-07-03  683  		format->format = *fmt;
3ee47cad Rui Miguel Silva 2018-07-03  684  
3ee47cad Rui Miguel Silva 2018-07-03  685  	mutex_unlock(&sensor->lock);
3ee47cad Rui Miguel Silva 2018-07-03  686  
3ee47cad Rui Miguel Silva 2018-07-03 @687  	return ret;
3ee47cad Rui Miguel Silva 2018-07-03  688  }
3ee47cad Rui Miguel Silva 2018-07-03  689  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 0e34e15b67b3..f8b873aaacec 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -680,11 +680,9 @@  static int ov2680_get_fmt(struct v4l2_subdev *sd,
 	mutex_lock(&sensor->lock);
 
 	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
 		fmt = v4l2_subdev_get_try_format(&sensor->sd, cfg, format->pad);
-#else
-		ret = -ENOTTY;
-#endif
+		if (IS_ERR(fmt))
+			return PTR_ERR(fmt);
 	} else {
 		fmt = &sensor->fmt;
 	}
@@ -703,9 +701,7 @@  static int ov2680_set_fmt(struct v4l2_subdev *sd,
 {
 	struct ov2680_dev *sensor = to_ov2680_dev(sd);
 	struct v4l2_mbus_framefmt *fmt = &format->format;
-#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
 	struct v4l2_mbus_framefmt *try_fmt;
-#endif
 	const struct ov2680_mode_info *mode;
 	int ret = 0;
 
@@ -728,12 +724,11 @@  static int ov2680_set_fmt(struct v4l2_subdev *sd,
 	}
 
 	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
 		try_fmt = v4l2_subdev_get_try_format(sd, cfg, 0);
-		format->format = *try_fmt;
-#else
-		ret = -ENOTTY;
-#endif
+		if (IS_ERR(try_fmt))
+			ret = PTR_ERR(try_fmt);
+		else
+			format->format = *try_fmt;
 
 		goto unlock;
 	}