linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lubomir Rintel <lkundrak@v3.sk>
To: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rui Miguel Silva <rmfrfs@gmail.com>,
	Shunqian Zheng <zhengsq@rock-chips.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Wenyou Yang <wenyou.yang@microchip.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Lubomir Rintel <lkundrak@v3.sk>
Subject: [PATCH 5/6] media: ov5695: get rid of extra ifdefs
Date: Wed, 28 Nov 2018 18:19:17 +0100	[thread overview]
Message-ID: <20181128171918.160643-6-lkundrak@v3.sk> (raw)
In-Reply-To: <20181128171918.160643-1-lkundrak@v3.sk>

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/ov5695.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
index 5d107c53364d..1469e8b90e1a 100644
--- a/drivers/media/i2c/ov5695.c
+++ b/drivers/media/i2c/ov5695.c
@@ -810,6 +810,7 @@ static int ov5695_set_fmt(struct v4l2_subdev *sd,
 			  struct v4l2_subdev_format *fmt)
 {
 	struct ov5695 *ov5695 = to_ov5695(sd);
+	struct v4l2_mbus_framefmt *try_fmt;
 	const struct ov5695_mode *mode;
 	s64 h_blank, vblank_def;
 
@@ -821,12 +822,12 @@ static int ov5695_set_fmt(struct v4l2_subdev *sd,
 	fmt->format.height = mode->height;
 	fmt->format.field = V4L2_FIELD_NONE;
 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
-#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
-		*v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format;
-#else
-		mutex_unlock(&ov5695->mutex);
-		return -ENOTTY;
-#endif
+		try_fmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
+		if (IS_ERR(try_fmt)) {
+			mutex_unlock(&ov5695->mutex);
+			return PTR_ERR(try_fmt);
+		}
+		*try_fmt = fmt->format;
 	} else {
 		ov5695->cur_mode = mode;
 		h_blank = mode->hts_def - mode->width;
@@ -845,24 +846,25 @@ static int ov5695_set_fmt(struct v4l2_subdev *sd,
 
 static int ov5695_get_fmt(struct v4l2_subdev *sd,
 			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *fmt)
+			  struct v4l2_subdev_format *format)
 {
 	struct ov5695 *ov5695 = to_ov5695(sd);
+	struct v4l2_mbus_framefmt *fmt;
 	const struct ov5695_mode *mode = ov5695->cur_mode;
 
 	mutex_lock(&ov5695->mutex);
-	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
-#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
-		fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
-#else
-		mutex_unlock(&ov5695->mutex);
-		return -ENOTTY;
-#endif
+	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+		fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
+		if (IS_ERR(fmt)) {
+			mutex_unlock(&ov5695->mutex);
+			return PTR_ERR(fmt);
+		}
+		format->format = *fmt;
 	} else {
-		fmt->format.width = mode->width;
-		fmt->format.height = mode->height;
-		fmt->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
-		fmt->format.field = V4L2_FIELD_NONE;
+		format->format.width = mode->width;
+		format->format.height = mode->height;
+		format->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
+		format->format.field = V4L2_FIELD_NONE;
 	}
 	mutex_unlock(&ov5695->mutex);
 
-- 
2.19.1

  parent reply	other threads:[~2018-11-29  4:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28 17:19 [PATCH 0/6] media: don't ifdef v4l2_subdev_get_try_format() any more Lubomir Rintel
2018-11-28 17:19 ` [PATCH 1/6] media: v4l2-subdev: stub v4l2_subdev_get_try_format() Lubomir Rintel
2018-12-03 13:48   ` [PATCH 1/6] media: v4l2-subdev: stub v4l2_subdev_get_try_format() ^[^[ jacopo mondi
2018-12-04 15:01     ` Lubomir Rintel
2018-12-06  8:30       ` [PATCH 1/6] media: v4l2-subdev: stub v4l2_subdev_get_try_format() ?? jacopo mondi
2018-12-07  8:57         ` Hans Verkuil
2018-12-09 21:17       ` sakari.ailus
2018-11-28 17:19 ` [PATCH 2/6] media: ov7740: get rid of extra ifdefs Lubomir Rintel
2019-01-15  9:25   ` Sakari Ailus
2018-11-28 17:19 ` [PATCH 3/6] media: ov2659: " Lubomir Rintel
2018-12-03 10:42   ` Dan Carpenter
2018-11-28 17:19 ` [PATCH 4/6] media: ov2680: " Lubomir Rintel
2018-12-03 10:43   ` Dan Carpenter
2018-11-28 17:19 ` Lubomir Rintel [this message]
2018-11-28 17:19 ` [PATCH 6/6] media: ov7670: " Lubomir Rintel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181128171918.160643-6-lkundrak@v3.sk \
    --to=lkundrak@v3.sk \
    --cc=corbet@lwn.net \
    --cc=jacopo@jmondi.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=rmfrfs@gmail.com \
    --cc=wenyou.yang@microchip.com \
    --cc=zhengsq@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).