linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: mchehab@kernel.org, rmfrfs@gmail.com, zhengsq@rock-chips.com,
	prabhakar.csengg@gmail.com, corbet@lwn.net,
	wenyou.yang@microchip.com, lkundrak@v3.sk,
	hverkuil-cisco@xs4all.nl, sakari.ailus@linux.intel.com,
	jacopo+renesas@jmondi.org
Cc: linux-media@vger.kernel.org, kernel@pengutronix.de
Subject: [PATCH 4/6] media: ov5695: get rid of extra ifdefs
Date: Thu,  4 Apr 2019 09:40:00 +0200	[thread overview]
Message-ID: <20190404074002.18730-5-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20190404074002.18730-1-m.felsch@pengutronix.de>

We can drop the ifdef dance since the v4l2_subdev_get_try_format
return the correct value in both cases with or without
CONFIG_VIDEO_V4L2_SUBDEV_API is enabled.

The patch is based on Lubomir's series [1].

[1] https://patchwork.kernel.org/cover/10703017/

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/media/i2c/ov5695.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
index 5d107c53364d..83fea416c75e 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;
@@ -848,16 +849,17 @@ static int ov5695_get_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 = 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
+		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);
+		}
+		fmt->format = *try_fmt;
 	} else {
 		fmt->format.width = mode->width;
 		fmt->format.height = mode->height;
-- 
2.20.1


  parent reply	other threads:[~2019-04-04  7:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04  7:39 [PATCH 0/6] Avoid v4l2_subdev_get_try_ ifdef dance Marco Felsch
2019-04-04  7:39 ` [PATCH 1/6] media: v4l2-subdev: add stubs for v4l2_subdev_get_try_* Marco Felsch
2019-04-04  8:39   ` Sakari Ailus
2019-04-04 14:39     ` Jacopo Mondi
2019-04-05  7:26       ` Marco Felsch
2019-05-29 17:45         ` Mauro Carvalho Chehab
2019-04-04  7:39 ` [PATCH 2/6] media: ov2659: get rid of extra ifdefs Marco Felsch
2019-04-04  7:39 ` [PATCH 3/6] media: ov2680: " Marco Felsch
2019-04-04  7:40 ` Marco Felsch [this message]
2019-04-04  7:40 ` [PATCH 5/6] media: ov7670: " Marco Felsch
2019-04-04  7:40 ` [PATCH 6/6] media: ov7740: " Marco Felsch
2019-05-31 11:51 ` [PATCH 0/6] Avoid v4l2_subdev_get_try_ ifdef dance Sakari Ailus

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=20190404074002.18730-5-m.felsch@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=corbet@lwn.net \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-media@vger.kernel.org \
    --cc=lkundrak@v3.sk \
    --cc=mchehab@kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=rmfrfs@gmail.com \
    --cc=sakari.ailus@linux.intel.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).