From patchwork Mon Jul 10 15:52:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 701398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 547C6EB64DC for ; Mon, 10 Jul 2023 15:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233674AbjGJPyy (ORCPT ); Mon, 10 Jul 2023 11:54:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233679AbjGJPyu (ORCPT ); Mon, 10 Jul 2023 11:54:50 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0AF135 for ; Mon, 10 Jul 2023 08:54:26 -0700 (PDT) Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BB6E932D2; Mon, 10 Jul 2023 17:51:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1689004293; bh=lEFVKKW37iKSybKu8oGE2XTUJnZv6OibFkc2bij6VSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rTgcmqsePVh3mC62ton5OUubCAmI8Wb92Mo7aALBgIQCTWxe6tbZeYyzVapHfTCIQ AZqBtOI7OjWFEueMJaShPp2oPOMmBgAPgp3/qn2U7oO19ZSqbALzZbdiiKF82qoqYI gRRR1Ay/eiCkOzcYd4DVzB5XmzDqA5OvX0JBYOeU= From: Jacopo Mondi To: linux-media@vger.kernel.org Cc: Jacopo Mondi , Dave Stevenson , Hans Verkuil , Sakari Ailus , Laurent Pinchart , Tomi Valkeinen , Jean-Michel Hautbois Subject: [PATCH v2 7/7] media: i2c: imx219: Simplify code handling in s_fmt Date: Mon, 10 Jul 2023 17:52:03 +0200 Message-Id: <20230710155203.92366-8-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230710155203.92366-1-jacopo.mondi@ideasonboard.com> References: <20230710155203.92366-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The imx219_set_pad_format() function adjusts the media bus code provided through the v4l2_subdev_format parameter to a media bus code known to be supported by the sensor. The same exact operation is performed by the imx219_get_format_code() function which called by imx219_update_pad_format(), which is in the imx219_set_pad_format() call path. Remove the duplicated operation and simplify imx219_set_pad_format(). Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- drivers/media/i2c/imx219.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 4f214f10846c..a1136fdfbed2 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -750,21 +750,13 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, const struct imx219_mode *mode; int exposure_max, exposure_def, hblank; struct v4l2_mbus_framefmt *format; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(imx219_mbus_formats); i++) - if (imx219_mbus_formats[i] == fmt->format.code) - break; - if (i >= ARRAY_SIZE(imx219_mbus_formats)) - i = 0; mode = v4l2_find_nearest_size(supported_modes, ARRAY_SIZE(supported_modes), width, height, fmt->format.width, fmt->format.height); - imx219_update_pad_format(imx219, mode, &fmt->format, - imx219_mbus_formats[i]); + imx219_update_pad_format(imx219, mode, &fmt->format, fmt->format.code); format = v4l2_subdev_get_pad_format(sd, sd_state, 0); if (imx219->mode == mode && format->code == fmt->format.code)