Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp466078pxj; Wed, 16 Jun 2021 06:36:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLgUQvCU1zPwLNi4DjPquIWY/K+8Srj/nm8YkvQ1ZwFyaUwYci6SVDeKd7Pf1IH0hkgPIi X-Received: by 2002:a05:6602:2203:: with SMTP id n3mr31148ion.1.1623850598130; Wed, 16 Jun 2021 06:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623850598; cv=none; d=google.com; s=arc-20160816; b=iyxHTCF0DDhoE6CHECWJTa8jHn2awVAQs7RuP3Wf3KlVzUGGXyaaG8EjWDUaVG9JXC OvBmqaBlNs8HBO98OB/RqEsUzLXU9+hBCer8qYeXFUksN9/7+y+TPm3PKK3JNhhb68G9 TUt8s7iHiGrq/dgvTeIWfuMMhglfFklofXBRcON5rAhOPSIVXae9YzGRS0+p3Znz4OeB oKfh0BRfSX02rAWfumyHEGSQyDgi85+4bQy6PlPMTp72fOo2AkMGLsxRyNsCooLljIjp uSErD86vzG3TR0msTKcDyMkUfcuG2+prh0+utgAb2NQe8zIH1axgHnr5JBWmIHGZ77Jr 6GgQ== 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=BnjDc49jltXOosJqy/zIm4ZUqZYblhcDCEHAntgESJ0=; b=MTPWRRPTPfJlcTo9NPJKgHjiSUEnCt/1wvT5Orsh0F4S1LCRrDH4cOLFfszUCnb7fq +DSk97fQIGk8/s7dmQ6SJ+nXIfErQMHmP+fpU6stRKtDU9BHTwInu5BF/j32rCgXJwO1 qR9MC5d6XtxYKZ10U/LNdq9bD8XowEaKt7N9jQ/pBOErn75AAsnexDWmtrsbAVKFNU9B dwUk5gm0DhdAu/zc43bCnTQGcHAmNJqQbqixMHCxMKkPNtu3ZNIFtHYR78RJtxIoB890 tzjQ8Bw103KeAzapeyVQgMoByv+3bZNTtyhD1Fd4OFC1YRiDd72C9uQ4l8EdtiggUMAZ sxHw== 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 i13si2644466ilm.156.2021.06.16.06.36.24; Wed, 16 Jun 2021 06:36:38 -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; 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 S232641AbhFPMsG (ORCPT + 99 others); Wed, 16 Jun 2021 08:48:06 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:55241 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232925AbhFPMr6 (ORCPT ); Wed, 16 Jun 2021 08:47:58 -0400 Received: (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id C78F81C0015; Wed, 16 Jun 2021 12:45:49 +0000 (UTC) From: Jacopo Mondi To: Hans Verkuil , 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, Laurent Pinchart Subject: [PATCH v5 06/15] media: i2c: max9271: Check max9271_write() return Date: Wed, 16 Jun 2021 14:46:07 +0200 Message-Id: <20210616124616.49249-7-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616124616.49249-1-jacopo+renesas@jmondi.org> References: <20210616124616.49249-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 Check the return value of the max9271_write() function in the max9271 library driver. While at it, modify an existing condition to be made identical to other checks. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- drivers/media/i2c/max9271.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/max9271.c b/drivers/media/i2c/max9271.c index c495582dcff6..2c7dc7fb9846 100644 --- a/drivers/media/i2c/max9271.c +++ b/drivers/media/i2c/max9271.c @@ -106,7 +106,10 @@ int max9271_set_serial_link(struct max9271_device *dev, bool enable) * Short delays here appear to show bit-errors in the writes following. * Therefore a conservative delay seems best here. */ - max9271_write(dev, 0x04, val); + ret = max9271_write(dev, 0x04, val); + if (ret < 0) + return ret; + usleep_range(5000, 8000); return 0; @@ -118,7 +121,7 @@ int max9271_configure_i2c(struct max9271_device *dev, u8 i2c_config) int ret; ret = max9271_write(dev, 0x0d, i2c_config); - if (ret) + if (ret < 0) return ret; /* The delay required after an I2C bus configuration change is not @@ -143,7 +146,10 @@ int max9271_set_high_threshold(struct max9271_device *dev, bool enable) * Enable or disable reverse channel high threshold to increase * immunity to power supply noise. */ - max9271_write(dev, 0x08, enable ? ret | BIT(0) : ret & ~BIT(0)); + ret = max9271_write(dev, 0x08, enable ? ret | BIT(0) : ret & ~BIT(0)); + if (ret < 0) + return ret; + usleep_range(2000, 2500); return 0; @@ -152,6 +158,8 @@ EXPORT_SYMBOL_GPL(max9271_set_high_threshold); int max9271_configure_gmsl_link(struct max9271_device *dev) { + int ret; + /* * Configure the GMSL link: * @@ -162,16 +170,24 @@ int max9271_configure_gmsl_link(struct max9271_device *dev) * * TODO: Make the GMSL link configuration parametric. */ - max9271_write(dev, 0x07, MAX9271_DBL | MAX9271_HVEN | - MAX9271_EDC_1BIT_PARITY); + ret = max9271_write(dev, 0x07, MAX9271_DBL | MAX9271_HVEN | + MAX9271_EDC_1BIT_PARITY); + if (ret < 0) + return ret; + usleep_range(5000, 8000); /* * Adjust spread spectrum to +4% and auto-detect pixel clock * and serial link rate. */ - max9271_write(dev, 0x02, MAX9271_SPREAD_SPECT_4 | MAX9271_R02_RES | - MAX9271_PCLK_AUTODETECT | MAX9271_SERIAL_AUTODETECT); + ret = max9271_write(dev, 0x02, + MAX9271_SPREAD_SPECT_4 | MAX9271_R02_RES | + MAX9271_PCLK_AUTODETECT | + MAX9271_SERIAL_AUTODETECT); + if (ret < 0) + return ret; + usleep_range(5000, 8000); return 0; -- 2.31.1