Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5880308pxb; Tue, 16 Feb 2021 09:44:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwn1RQ+vPlnz1mnoYTv+tKY7b0wZrLkkCqTOCVD/MIzHRHlnNi7oBe/XszWWa2Vp/cuQYY7 X-Received: by 2002:a17:906:3603:: with SMTP id q3mr20441664ejb.201.1613497495365; Tue, 16 Feb 2021 09:44:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613497495; cv=none; d=google.com; s=arc-20160816; b=P6rfxb/+NcYV+ZLwYesPdlD2WyL+veNq6Az6BwrrhgjvoPod0RX2jom5XJjpI5FNSD 8u4gg4+k5rDsB31WKajWF6Ty35E2MjGme52p/UPXvQk0Foq8sgKkQJe3CtbEiZ0opCLM 3f3HpbFzBaVtpL7A6et2EydPohGNACIW6o7D3Cpj/7JGKVyzC8fpQau4elFVvruNrRbR utNpwHMLjsaxHbfDRwkwkUbYJ0beiQAS6bfKcdX+NL8bx8QCXCVVDPLkFvB6DjMgx8PR lIw3fDrokXF4k6JDyYbvAOsyBmM5EWNQKWIZdt0AdX9B8JFuLpycIs0RNbYYwvSwznTK ZdFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IEMzilpS23MXtodnIoLqFt1I3boJGhOTBKNb4Evkkxs=; b=MWMVZhYVGolQ/czLpBD1rNt5jKjSOmLOvfQVeF7yzpg97L8BL7jlAqJs15Pk7XsgaK 8WGMMTdu/Z2jhmfAN/8YLat3FnK72OiSs9G5s66cpJHZEoDd2JI5VHje4sgqaPw7DSPd Ef8NMmI4IGMJFqMafSKXJtYkpNJXSp0873bIA0I8qLqIS+vg5WoKqP86Qpzb73pnNDP9 shocp7ZLBubbLVp/GSxdG7v0pFl2KlqvldPJR+342BOMFuNR+JAvSkxBapqFCSLWJjSV telQdsWitgpm+ADsdtQ0gWD0f5Q5h6NmsvaMlWiT2C9kU5bbqEdf5zJZ+q0VjQ0WaTwg sLuQ== ARC-Authentication-Results: i=1; mx.google.com; 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 g9si3573079edm.60.2021.02.16.09.44.08; Tue, 16 Feb 2021 09:44:55 -0800 (PST) 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; 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 S230402AbhBPRmz (ORCPT + 99 others); Tue, 16 Feb 2021 12:42:55 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:34421 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231151AbhBPRmU (ORCPT ); Tue, 16 Feb 2021 12:42:20 -0500 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id CDD21200009; Tue, 16 Feb 2021 17:41:31 +0000 (UTC) From: Jacopo Mondi To: kieran.bingham+renesas@ideasonboard.com, laurent.pinchart+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, geert@linux-m68k.org Cc: Jacopo Mondi , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/16] media: i2c: rdacm20: Replace goto with a loop Date: Tue, 16 Feb 2021 18:41:33 +0100 Message-Id: <20210216174146.106639-4-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210216174146.106639-1-jacopo+renesas@jmondi.org> References: <20210216174146.106639-1-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Jacopo Mondi --- drivers/media/i2c/rdacm20.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c index 4d9bac87cba8..6504ed0bd3bc 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; @@ -452,7 +454,7 @@ static const struct v4l2_subdev_ops rdacm20_subdev_ops = { static int rdacm20_initialize(struct rdacm20_device *dev) { - unsigned int retry = 3; + unsigned int i; int ret; /* Verify communication with the MAX9271: ping to wakeup. */ @@ -501,23 +503,14 @@ static int rdacm20_initialize(struct rdacm20_device *dev) return ret; usleep_range(10000, 15000); -again: - ret = ov10635_read16(dev, OV10635_PID); - if (ret < 0) { - if (retry--) - goto again; - - dev_err(dev->dev, "OV10635 ID read failed (%d)\n", - ret); - return -ENXIO; + for (i = 0; i < OV10635_PID_TIMEOUT; ++i) { + ret = ov10635_read16(dev, OV10635_PID); + if (ret == OV10635_VERSION) + break; + usleep_range(1000, 2000); } - - if (ret != OV10635_VERSION) { - if (retry--) - goto again; - - dev_err(dev->dev, "OV10635 ID mismatch (0x%04x)\n", - ret); + if (i == OV10635_PID_TIMEOUT) { + dev_err(dev->dev, "OV10635 ID read failed (%d)\n", ret); return -ENXIO; } -- 2.30.0