From patchwork Thu Nov 4 11:09:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12602879 X-Patchwork-Delegate: kieran@bingham.xyz 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E48ADC433F5 for ; Thu, 4 Nov 2021 11:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5DEE611C9 for ; Thu, 4 Nov 2021 11:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231340AbhKDLMX (ORCPT ); Thu, 4 Nov 2021 07:12:23 -0400 Received: from mslow1.mail.gandi.net ([217.70.178.240]:51993 "EHLO mslow1.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231371AbhKDLMW (ORCPT ); Thu, 4 Nov 2021 07:12:22 -0400 Received: from relay9-d.mail.gandi.net (unknown [217.70.183.199]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 61FA0D06A2 for ; Thu, 4 Nov 2021 11:09:02 +0000 (UTC) Received: (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 83ACFFF809; Thu, 4 Nov 2021 11:08:39 +0000 (UTC) From: Jacopo Mondi To: Kieran Bingham , Laurent Pinchart , =?utf-8?q?Nik?= =?utf-8?q?las_S=C3=B6derlund?= Cc: Jacopo Mondi , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 1/2] media: max9271: Ignore busy loop read errors Date: Thu, 4 Nov 2021 12:09:23 +0100 Message-Id: <20211104110924.248444-2-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211104110924.248444-1-jacopo+renesas@jmondi.org> References: <20211104110924.248444-1-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Valid pixel clock detection is performed by spinning on a register read which if repeated too frequently might fail. As the error is not fatal ignore it instead of bailing out to continue spinning until the timeout completion. Also relax the time between bus transactions and slightly increase the wait interval to mitigate the failure risk. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- v1->v2: - Do not continue but jump to a label to respect the sleep timout after a failed read Niklas I kept your tag anyway, hope it's ok. Thanks j --- drivers/media/i2c/max9271.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.33.1 diff --git a/drivers/media/i2c/max9271.c b/drivers/media/i2c/max9271.c index ff86c8c4ea61..aa4add473716 100644 --- a/drivers/media/i2c/max9271.c +++ b/drivers/media/i2c/max9271.c @@ -55,7 +55,7 @@ static int max9271_write(struct max9271_device *dev, u8 reg, u8 val) /* * max9271_pclk_detect() - Detect valid pixel clock from image sensor * - * Wait up to 10ms for a valid pixel clock. + * Wait up to 15ms for a valid pixel clock. * * Returns 0 for success, < 0 for pixel clock not properly detected */ @@ -64,15 +64,16 @@ static int max9271_pclk_detect(struct max9271_device *dev) unsigned int i; int ret; - for (i = 0; i < 100; i++) { + for (i = 0; i < 10; i++) { ret = max9271_read(dev, 0x15); if (ret < 0) - return ret; + goto skip; if (ret & MAX9271_PCLKDET) return 0; - usleep_range(50, 100); +skip: + usleep_range(1000, 1500); } dev_err(&dev->client->dev, "Unable to detect valid pixel clock\n");