From patchwork Thu Apr 4 07:39:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10885181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E75B913B5 for ; Thu, 4 Apr 2019 07:40:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D185A2894E for ; Thu, 4 Apr 2019 07:40:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5C36289F8; Thu, 4 Apr 2019 07:40:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BD812894E for ; Thu, 4 Apr 2019 07:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727039AbfDDHkf (ORCPT ); Thu, 4 Apr 2019 03:40:35 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:33655 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbfDDHkf (ORCPT ); Thu, 4 Apr 2019 03:40:35 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBwyz-0007cx-OU; Thu, 04 Apr 2019 09:40:21 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hBwyv-00051Q-7C; Thu, 04 Apr 2019 09:40:17 +0200 From: Marco Felsch 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 1/6] media: v4l2-subdev: add stubs for v4l2_subdev_get_try_* Date: Thu, 4 Apr 2019 09:39:57 +0200 Message-Id: <20190404074002.18730-2-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190404074002.18730-1-m.felsch@pengutronix.de> References: <20190404074002.18730-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of missing CONFIG_VIDEO_V4L2_SUBDEV_API those helpers aren't available. So each driver have to add ifdefs around those helpers or add the CONFIG_VIDEO_V4L2_SUBDEV_API as dependcy. Make these helpers available in case of CONFIG_VIDEO_V4L2_SUBDEV_API isn't set to avoid ifdefs. This approach is less error prone too. Signed-off-by: Marco Felsch --- The patch was previously part of series [1]. Since I want to get series [1] merged in 5.2 I split this possible stopper out of the serie and prepared a own series for it. I applied Jacopos comments and switched to Lubomir's approach [2]. During discussion on series [2] Sakari pointed out Hans approach [3] which didn't got into the kernel due to Mauro's concerns. So I think this would be the smalles common dennominator. [1] https://patchwork.kernel.org/cover/10786553/ [2] https://patchwork.kernel.org/patch/10703029/ [3] https://patchwork.linuxtv.org/patch/53370/ --- include/media/v4l2-subdev.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index a7fa5b80915a..eea792757426 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -984,7 +984,34 @@ static inline struct v4l2_rect pad = 0; return &cfg[pad].try_compose; } -#endif + +#else /* !defined(CONFIG_VIDEO_V4L2_SUBDEV_API) */ + +static inline struct v4l2_mbus_framefmt +*v4l2_subdev_get_try_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad) +{ + return ERR_PTR(-ENOTTY); +} + +static inline struct v4l2_rect +*v4l2_subdev_get_try_crop(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad) +{ + return ERR_PTR(-ENOTTY); +} + +static inline struct v4l2_rect +*v4l2_subdev_get_try_compose(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad) +{ + return ERR_PTR(-ENOTTY); +} + +#endif /* defined(CONFIG_VIDEO_V4L2_SUBDEV_API) */ extern const struct v4l2_file_operations v4l2_subdev_fops; From patchwork Thu Apr 4 07:39:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10885179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C25F13B5 for ; Thu, 4 Apr 2019 07:40:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBD412894E for ; Thu, 4 Apr 2019 07:40:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E02A1289F8; Thu, 4 Apr 2019 07:40:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 878382894E for ; Thu, 4 Apr 2019 07:40:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbfDDHke (ORCPT ); Thu, 4 Apr 2019 03:40:34 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:51145 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbfDDHke (ORCPT ); Thu, 4 Apr 2019 03:40:34 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBwyz-0007cy-OW; Thu, 04 Apr 2019 09:40:21 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hBwyv-00051U-7g; Thu, 04 Apr 2019 09:40:17 +0200 From: Marco Felsch 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 2/6] media: ov2659: get rid of extra ifdefs Date: Thu, 4 Apr 2019 09:39:58 +0200 Message-Id: <20190404074002.18730-3-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190404074002.18730-1-m.felsch@pengutronix.de> References: <20190404074002.18730-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/media/i2c/ov2659.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c index 799acce803fe..1c9cbd43f903 100644 --- a/drivers/media/i2c/ov2659.c +++ b/drivers/media/i2c/ov2659.c @@ -1046,17 +1046,16 @@ static int ov2659_get_fmt(struct v4l2_subdev *sd, dev_dbg(&client->dev, "ov2659_get_fmt\n"); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API struct v4l2_mbus_framefmt *mf; mf = v4l2_subdev_get_try_format(sd, cfg, 0); + if (IS_ERR(mf)) + return PTR_ERR(mf); + mutex_lock(&ov2659->lock); fmt->format = *mf; mutex_unlock(&ov2659->lock); return 0; -#else - return -ENOTTY; -#endif } mutex_lock(&ov2659->lock); @@ -1126,12 +1125,12 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd, mutex_lock(&ov2659->lock); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); + if (IS_ERR(mf)) { + mutex_unlock(&ov2659->lock); + return PTR_ERR(mf); + } *mf = fmt->format; -#else - return -ENOTTY; -#endif } else { s64 val; From patchwork Thu Apr 4 07:39:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10885177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 770E41800 for ; Thu, 4 Apr 2019 07:40:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 613062894E for ; Thu, 4 Apr 2019 07:40:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55559289F7; Thu, 4 Apr 2019 07:40:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9419289FC for ; Thu, 4 Apr 2019 07:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726952AbfDDHke (ORCPT ); Thu, 4 Apr 2019 03:40:34 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:39765 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbfDDHkd (ORCPT ); Thu, 4 Apr 2019 03:40:33 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBwyz-0007cz-OR; Thu, 04 Apr 2019 09:40:21 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hBwyv-00051X-8L; Thu, 04 Apr 2019 09:40:17 +0200 From: Marco Felsch 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 3/6] media: ov2680: get rid of extra ifdefs Date: Thu, 4 Apr 2019 09:39:59 +0200 Message-Id: <20190404074002.18730-4-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190404074002.18730-1-m.felsch@pengutronix.de> References: <20190404074002.18730-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/media/i2c/ov2680.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index b10bcfabaeeb..ea750e8304fe 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -672,11 +672,11 @@ 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)) { + ret = PTR_ERR(fmt); + goto unlock; + } } else { fmt = &sensor->fmt; } @@ -684,6 +684,7 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd, if (fmt) format->format = *fmt; +unlock: mutex_unlock(&sensor->lock); return ret; @@ -695,9 +696,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; @@ -720,13 +719,12 @@ 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); + if (IS_ERR(try_fmt)) { + ret = PTR_ERR(try_fmt); + goto unlock; + } format->format = *try_fmt; -#else - ret = -ENOTTY; -#endif - goto unlock; } From patchwork Thu Apr 4 07:40:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10885185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E27331800 for ; Thu, 4 Apr 2019 07:40:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAA592894E for ; Thu, 4 Apr 2019 07:40:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE9B6289F8; Thu, 4 Apr 2019 07:40:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6773F2894E for ; Thu, 4 Apr 2019 07:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727044AbfDDHkg (ORCPT ); Thu, 4 Apr 2019 03:40:36 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:43327 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbfDDHke (ORCPT ); Thu, 4 Apr 2019 03:40:34 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBwyz-0007d0-OT; Thu, 04 Apr 2019 09:40:21 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hBwyv-00051b-93; Thu, 04 Apr 2019 09:40:17 +0200 From: Marco Felsch 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 Message-Id: <20190404074002.18730-5-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190404074002.18730-1-m.felsch@pengutronix.de> References: <20190404074002.18730-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; From patchwork Thu Apr 4 07:40:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10885187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69E0213B5 for ; Thu, 4 Apr 2019 07:40:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54D8A289F8 for ; Thu, 4 Apr 2019 07:40:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48E912894E; Thu, 4 Apr 2019 07:40:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E88C12894E for ; Thu, 4 Apr 2019 07:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbfDDHki (ORCPT ); Thu, 4 Apr 2019 03:40:38 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:43873 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726694AbfDDHke (ORCPT ); Thu, 4 Apr 2019 03:40:34 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBwyz-0007d2-OT; Thu, 04 Apr 2019 09:40:21 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hBwyv-00051n-AS; Thu, 04 Apr 2019 09:40:17 +0200 From: Marco Felsch 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 5/6] media: ov7670: get rid of extra ifdefs Date: Thu, 4 Apr 2019 09:40:01 +0200 Message-Id: <20190404074002.18730-6-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190404074002.18730-1-m.felsch@pengutronix.de> References: <20190404074002.18730-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/media/i2c/ov7670.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index 44c3eed8a858..7d6fd9842a75 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -1097,9 +1097,7 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *format) { struct ov7670_info *info = to_state(sd); -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API struct v4l2_mbus_framefmt *mbus_fmt; -#endif int ret; if (format->pad) @@ -1109,13 +1107,13 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd, ret = ov7670_try_fmt_internal(sd, &format->format, NULL, NULL); if (ret) return ret; -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API + mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); + if (IS_ERR(mbus_fmt)) + return PTR_ERR(mbus_fmt); + *mbus_fmt = format->format; return 0; -#else - return -ENOTTY; -#endif } ret = ov7670_try_fmt_internal(sd, &format->format, &info->fmt, &info->wsize); @@ -1138,18 +1136,15 @@ static int ov7670_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *format) { struct ov7670_info *info = to_state(sd); -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API struct v4l2_mbus_framefmt *mbus_fmt; -#endif if (format->which == V4L2_SUBDEV_FORMAT_TRY) { -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, 0); + if (IS_ERR(mbus_fmt)) + return PTR_ERR(mbus_fmt); + format->format = *mbus_fmt; return 0; -#else - return -ENOTTY; -#endif } else { format->format = info->format; } From patchwork Thu Apr 4 07:40:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10885183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DDF01708 for ; Thu, 4 Apr 2019 07:40:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 392982894E for ; Thu, 4 Apr 2019 07:40:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D7C5289F8; Thu, 4 Apr 2019 07:40:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBF862894E for ; Thu, 4 Apr 2019 07:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbfDDHkh (ORCPT ); Thu, 4 Apr 2019 03:40:37 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:39385 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726204AbfDDHke (ORCPT ); Thu, 4 Apr 2019 03:40:34 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBwyz-0007d3-OS; Thu, 04 Apr 2019 09:40:21 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hBwyv-00051s-BJ; Thu, 04 Apr 2019 09:40:17 +0200 From: Marco Felsch 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 6/6] media: ov7740: get rid of extra ifdefs Date: Thu, 4 Apr 2019 09:40:02 +0200 Message-Id: <20190404074002.18730-7-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190404074002.18730-1-m.felsch@pengutronix.de> References: <20190404074002.18730-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/media/i2c/ov7740.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c index 54e80a60aa57..58171f21d315 100644 --- a/drivers/media/i2c/ov7740.c +++ b/drivers/media/i2c/ov7740.c @@ -804,9 +804,7 @@ static int ov7740_set_fmt(struct v4l2_subdev *sd, struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev); const struct ov7740_pixfmt *ovfmt; const struct ov7740_framesize *fsize; -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API struct v4l2_mbus_framefmt *mbus_fmt; -#endif int ret; mutex_lock(&ov7740->mutex); @@ -819,16 +817,17 @@ static int ov7740_set_fmt(struct v4l2_subdev *sd, ret = ov7740_try_fmt_internal(sd, &format->format, NULL, NULL); if (ret) goto error; -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API + mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); + if (IS_ERR(mbus_fmt)) { + ret = PTR_ERR(mbus_fmt); + goto error; + } + *mbus_fmt = format->format; mutex_unlock(&ov7740->mutex); return 0; -#else - ret = -ENOTTY; - goto error; -#endif } ret = ov7740_try_fmt_internal(sd, &format->format, &ovfmt, &fsize); @@ -851,25 +850,25 @@ static int ov7740_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *format) { struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev); -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API struct v4l2_mbus_framefmt *mbus_fmt; -#endif int ret = 0; mutex_lock(&ov7740->mutex); if (format->which == V4L2_SUBDEV_FORMAT_TRY) { -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, 0); + if (IS_ERR(mbus_fmt)) { + ret = PTR_ERR(mbus_fmt); + goto error; + } + format->format = *mbus_fmt; ret = 0; -#else - ret = -ENOTTY; -#endif } else { format->format = ov7740->format; } - mutex_unlock(&ov7740->mutex); +error: + mutex_unlock(&ov7740->mutex); return ret; }