Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2259483pxf; Sat, 20 Mar 2021 09:22:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGDmwiqgehlZfCej1TUabd4zU6dlADbicUDvmp97y/SR42kgMid3ikeiKAkxGPxGinDner X-Received: by 2002:a17:906:72d1:: with SMTP id m17mr10412658ejl.118.1616257376908; Sat, 20 Mar 2021 09:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616257376; cv=none; d=google.com; s=arc-20160816; b=crArl3HLrCwfg9T+xwk5oD84kp3DpvkMaLvMRuYF2z5iqymo/GJBXC21PzCdhs6YUS JPqqM35dkbjtspVLP03RZgKOqeIiYfMqyr49/Vi28wdOF28ixi1NJKQ1WIZ/KGMkEy2N mSbRAyIme+HfLyWtLFlqQx1bL1KZqkiuQmiES/mBTB96KNJNqlL9OS5f0GXMesAo30gZ wFmXJy3sDovTQAsNlM+n8b2emnUYOLLOqsSmXPcugFuY3vGVN7+9b9zJ5dS+YdSmTvLe Yg9INMDR5akQDAIwq42VeqhzemjOShANZu4F+hPANeAMnG7J8RaulAEwbn9aYdnSozzj cYKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8+wfOTMoQI3NEFNN2VsTo4sfxTPm2oDmYxd260jouDE=; b=v7etg6CLVssYJtZ2w8Zj8GEi3jJeiFo0nNY6ETy/YaDtM8ZYdwRD2/32Y8X28gnqRp WHU+V6O1ET73Lqhsq1JKsXCs+RmP8LdCvyEknSvxke2Bf8lsvhnoJ/If2E3Q1yuz0bAa bPB1fI+EHdizHEEBKrgpcTrUXgASc6BOKxlUXY6dbOBJxciTDH8g7RX8AXKhwVXcpeOR sBxFb5IPdeaqjerkIjEnt4CK4DFF5fhsaZBK3gB8VS8kjyWSmLarAKxaXCNblimqKzo2 ja7SQegD2C8zoFbQ9NdPpu29JPO65LbWiOFrqevyOWTInL9YdbnBYwXV756vFnUQWH9I LDyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=d0SVlBQc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si6872126ejv.334.2021.03.20.09.22.34; Sat, 20 Mar 2021 09:22:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=d0SVlBQc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbhCTQSa (ORCPT + 99 others); Sat, 20 Mar 2021 12:18:30 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:47100 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhCTQS1 (ORCPT ); Sat, 20 Mar 2021 12:18:27 -0400 Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 35EF18D3; Sat, 20 Mar 2021 17:18:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1616257106; bh=9jcusMGa/y+S8wJ82CkMxUncDCQ1MlgmDfai7+e/V9g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d0SVlBQc7WxVJ9aP2eXyGwryzJmD70GZ4yQ40oB0pQly1IV9FGz5Pf49Ok9rH6a6+ 3U5jhIkcT8vfYIHKUDu9zJELsHiLTeTTGLHoQ6qT/T+ZaDz3tmYb1GOm1Ncr1Ov5BG AnaC0yjadPlK4mk0Ggt9OBCAqjkcbvmclZ23zMYk= Date: Sat, 20 Mar 2021 18:17:46 +0200 From: Laurent Pinchart To: Jacopo Mondi Cc: kieran.bingham+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, geert@linux-m68k.org, Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 16/19] media: i2c: rdacm20: Replace goto with a loop Message-ID: References: <20210319164148.199192-1-jacopo+renesas@jmondi.org> <20210319164148.199192-17-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210319164148.199192-17-jacopo+renesas@jmondi.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacopo, Thank you for the patch. On Fri, Mar 19, 2021 at 05:41:45PM +0100, Jacopo Mondi wrote: > During the camera module initialization the image sensor PID is read to > verify it can correctly be identified. The current implementation is > rather confused and uses a loop implemented with a label and a goto. > > Replace it with a more compact for() loop. > > No functional changes intended. > > Reviewed-by: Kieran Bingham > Reviewed-by: Laurent Pinchart > Signed-off-by: Jacopo Mondi > --- > drivers/media/i2c/rdacm20.c | 29 +++++++++++++---------------- > 1 file changed, 13 insertions(+), 16 deletions(-) > > diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c > index 7bdcfafa6c10..760705dd2918 100644 > --- a/drivers/media/i2c/rdacm20.c > +++ b/drivers/media/i2c/rdacm20.c > @@ -59,6 +59,8 @@ > */ > #define OV10635_PIXEL_RATE (44000000) > > +#define OV10635_PID_TIMEOUT 3 > + > static const struct ov10635_reg { > u16 reg; > u8 val; > @@ -438,7 +440,7 @@ static int rdacm20_get_fmt(struct v4l2_subdev *sd, > static int rdacm20_init(struct v4l2_subdev *sd, unsigned int val) > { > struct rdacm20_device *dev = sd_to_rdacm20(sd); > - unsigned int retry = 3; > + unsigned int i; > int ret; > > /* > @@ -478,23 +480,18 @@ static int rdacm20_init(struct v4l2_subdev *sd, unsigned int val) > return ret; > usleep_range(10000, 15000); > > -again: > - ret = ov10635_read16(dev, OV10635_PID); > - if (ret < 0) { > - if (retry--) > - goto again; > + for (i = 0; i < OV10635_PID_TIMEOUT; ++i) { As commented on a previous patch, this macro is used here only, I would have made it local. > + ret = ov10635_read16(dev, OV10635_PID); > + if (ret == OV10635_VERSION) > + break; > + else if (ret >= 0) > + /* Sometimes we get a successful read but a wrong ID. */ > + dev_dbg(dev->dev, "OV10635 ID mismatch (%d)\n", ret); > > - dev_err(dev->dev, "OV10635 ID read failed (%d)\n", > - ret); > - return -ENXIO; > + usleep_range(1000, 2000); > } > - > - if (ret != OV10635_VERSION) { > - if (retry--) > - goto again; > - > - dev_err(dev->dev, "OV10635 ID mismatch (0x%04x)\n", > - ret); Blank line ? > + if (i == OV10635_PID_TIMEOUT) { > + dev_err(dev->dev, "OV10635 ID read failed (%d)\n", ret); > return -ENXIO; > } > -- Regards, Laurent Pinchart