From patchwork Tue Nov 22 22:32:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 627829 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 CCD77C433FE for ; Tue, 22 Nov 2022 22:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235104AbiKVWda (ORCPT ); Tue, 22 Nov 2022 17:33:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235216AbiKVWd3 (ORCPT ); Tue, 22 Nov 2022 17:33:29 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9BC09DBA6 for ; Tue, 22 Nov 2022 14:33:28 -0800 (PST) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 682611381; Tue, 22 Nov 2022 23:33:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669156407; bh=c3ggw/yTbh55ye89FplO8fY9/IYd+XC5xzEpZnLCh9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nThI42J4L+oBfZwRI1fD1BIvc7C65MOdlZsLYfXmT6ltKqG6gmydWXMj8OGg2PfiH 0USoqn/KFl/Be5d4yYPDiSLPSDOEAzBtVZIt+o+FANQ4iXcY5/ufifD/mdlg8jc2Xe 6PulN84x8tF0VLrYiiDZvisyhmbnTcd1Cya7baCI= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Sakari Ailus , Manivannan Sadhasivam Subject: [PATCH v1 15/15] media: i2c: imx290: Simplify imx290_set_data_lanes() Date: Wed, 23 Nov 2022 00:32:50 +0200 Message-Id: <20221122223250.21233-16-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221122223250.21233-1-laurent.pinchart@ideasonboard.com> References: <20221122223250.21233-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There's no need to check for an incorrect number of data lanes in imx290_set_data_lanes() as the value is validated at probe() time. Drop the check. The PHY_LANE_NUM and CSI_LANE_MODE registers are programmed with a value equal to the number of lanes minus one. Compute it instead of handling it in the switch/case. Signed-off-by: Laurent Pinchart --- drivers/media/i2c/imx290.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 4dfa090f918d..369db35a7afd 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -512,28 +512,21 @@ static int imx290_set_register_array(struct imx290 *imx290, static int imx290_set_data_lanes(struct imx290 *imx290) { - int ret = 0, laneval, frsel; + int ret = 0; + u32 frsel; switch (imx290->nlanes) { case 2: - laneval = 0x01; + default: frsel = 0x02; break; case 4: - laneval = 0x03; frsel = 0x01; break; - default: - /* - * We should never hit this since the data lane count is - * validated in probe itself - */ - dev_err(imx290->dev, "Lane configuration not supported\n"); - return -EINVAL; } - imx290_write(imx290, IMX290_PHY_LANE_NUM, laneval, &ret); - imx290_write(imx290, IMX290_CSI_LANE_MODE, laneval, &ret); + imx290_write(imx290, IMX290_PHY_LANE_NUM, imx290->nlanes - 1, &ret); + imx290_write(imx290, IMX290_CSI_LANE_MODE, imx290->nlanes - 1, &ret); imx290_write(imx290, IMX290_FR_FDG_SEL, frsel, &ret); return ret;