From patchwork Wed Nov 28 17:19:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 10703019 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 876DC14BD for ; Wed, 28 Nov 2018 17:19:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69BB32D9A7 for ; Wed, 28 Nov 2018 17:19:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AB072D9B2; Wed, 28 Nov 2018 17:19:54 +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 F084A2D9A7 for ; Wed, 28 Nov 2018 17:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729262AbeK2EWI (ORCPT ); Wed, 28 Nov 2018 23:22:08 -0500 Received: from shell.v3.sk ([90.176.6.54]:39112 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729251AbeK2EWH (ORCPT ); Wed, 28 Nov 2018 23:22:07 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 412C9996A0; Wed, 28 Nov 2018 18:19:44 +0100 (CET) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id HJGPn88B5NSw; Wed, 28 Nov 2018 18:19:35 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 4AC4B85774; Wed, 28 Nov 2018 18:19:30 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id N-bYHvuFz9M8; Wed, 28 Nov 2018 18:19:27 +0100 (CET) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id 8AA3B996F1; Wed, 28 Nov 2018 18:19:26 +0100 (CET) From: Lubomir Rintel To: "Lad, Prabhakar" , Mauro Carvalho Chehab , Rui Miguel Silva , Shunqian Zheng , Jonathan Corbet , Wenyou Yang Cc: Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Lubomir Rintel Subject: [PATCH 5/6] media: ov5695: get rid of extra ifdefs Date: Wed, 28 Nov 2018 18:19:17 +0100 Message-Id: <20181128171918.160643-6-lkundrak@v3.sk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181128171918.160643-1-lkundrak@v3.sk> References: <20181128171918.160643-1-lkundrak@v3.sk> MIME-Version: 1.0 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 Stubbed v4l2_subdev_get_try_format() will return a correct error when configured without CONFIG_VIDEO_V4L2_SUBDEV_API. Signed-off-by: Lubomir Rintel --- 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);