Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1629632pxb; Mon, 12 Apr 2021 02:53:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKcifuYbmDX+KJIlS2ChAgyAsrXk5/hDHJGiwhg98WfHoiieAHD2hvNy1KHyanlS0nY+5i X-Received: by 2002:a17:90b:3b43:: with SMTP id ot3mr8158919pjb.100.1618221180816; Mon, 12 Apr 2021 02:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618221180; cv=none; d=google.com; s=arc-20160816; b=Dl7tCB6ZmzZREt+wZNJdYUer0R9pNkAcCMs82myCfwQ6+4nRyc1myzIfyq+FvqFTmi EKl1VvTWRWEdn57JwmSAfg/4NCqkwDV7rvWgqOYF26cfGyzBo3kVe7hb/qfRuC8McLQE simq4GszzQBC//2j91rFYHIL4wobp7yHvP+Vd/XCbpQ7jYAXRgrD/lyysJEaNBaj/G15 HijSB/e4Of6VMOyEe3jtnvLHbXQyUA+3BYXs0nKnMkxce5+gxAAqFzAujZqWPu+PLd9w ZlUYeX/b9erBh2TDjiY9qh/GJr5Fhi5TBSl6bdMrATxnv7oI3bE5AbLDhkI+puC8eZwy RImw== 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=40UXmmaWrchW3AmEhX4oACB+MS0MocfBe+8D0fctQPI=; b=qI5n8AFhbrq1xSxrexEY0aCYEGSrw3Dcipph8akr+T+38WvYBdq5gw/VOJuzqEW+KU oC8hMXkz9EtQjbNlohQcUNr5sTUHdcweXjN36qbS5bui4Vfa/4JyrkKJK5D29pkK2sM7 zG7pXAAx9RG+WxPTq1lfFeLjbs/SxreRWAJUGWD1UbFf2SSY/1NOiD52aOyMBBbvV9N2 TCTCrgj+WWs2pDAEx3sPPqzwlKAArpYJI3C5UEVTZmlf5Sko8RpvF4KdXT/izkCRmlqb IszcU1q46y3SBbj9pXQKi2VbmmFSSQZkAAjxd4XwO1M9MiBRgHlddDBqUoJj3e0kRbO3 mKrQ== 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 n15si9849037plc.267.2021.04.12.02.52.37; Mon, 12 Apr 2021 02:53:00 -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 S241407AbhDLJso (ORCPT + 99 others); Mon, 12 Apr 2021 05:48:44 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:41995 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240665AbhDLJez (ORCPT ); Mon, 12 Apr 2021 05:34:55 -0400 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 9701B200006; Mon, 12 Apr 2021 09:34:30 +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, Laurent Pinchart Subject: [PATCH v4 06/17] media: i2c: max9271: Check max9271_write() return Date: Mon, 12 Apr 2021 11:34:40 +0200 Message-Id: <20210412093451.14198-7-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412093451.14198-1-jacopo+renesas@jmondi.org> References: <20210412093451.14198-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. Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- 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