Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3562245pxj; Tue, 11 May 2021 07:14:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxId6p6wnT0uTszO+PMn1kj7TuPnzD7Sh3DgmoDxFx5MU5p9j06CG6SDNnYunHgpXhuz9/t X-Received: by 2002:a2e:9549:: with SMTP id t9mr24887716ljh.292.1620742478599; Tue, 11 May 2021 07:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620742478; cv=none; d=google.com; s=arc-20160816; b=L+l+mcFoRb7/uuOIfjxfZIsSiRw/pyhUuoUOLHWL2kY02m8BxKJ7o9yZhYPzfT0ZeS gsz8FYorcNJpg3RZyujGXWmbupg/kwT2blGPPtT5phccESetm+oyzQ5gX1/Vv4DP7ZqM qXl9dmB1opGM8TidTW2XQqcgbmrQF5QiEH/8H77fQy+QbClVN6lftR43mVjjqdYQ/Mdc E4jx6v6V0WUsDL9B99OByB5TqpeTabJZpmYPOrJu6Tvp8EK3YiTsudixSKqTEsvfM3bb fNDxGxWV3teQ0DtPf1DOlO+xbqngEMCeyFrrlc2qa5YYkpA0eij4jyip6tR5OLh/+l1n 2zBQ== 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:subject:cc:to:from:date; bh=le3vyG3cDXV+DthsEfytIHRPovCVET/naTk4eatdmIA=; b=qNA2L0HOHPm8W840Vu9HyL1ifA0i4PWbdDg7YZrg9CNewldAMoJ0qGzjd3unvfjV0V EHYhpuhAZDr9h8nbewr7JQy3WFibr+H9rsAmdAb8W5B6zmC4h2Zs186OiWCGTS5/RxjE gZTOmyHtzdaXC0dFuh1oUFYcbeKDk5C2O0on+LEx+RH6qoFSXzaz/qz1TXTwdILvP9Lw TXWR1cRKVZ+mR236jITWalXbMkNiXcIxcoGGYZaOEK6ijKiGrWT5pGFZ9ccGn+xh2xPD LgrN8Gs9NmG8ogdfR61tLg+s+V5imtPj8dG3sWKDOu9+VmdntjKr6hlLyMFmptXjgPJE 8ZSg== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si684130lji.387.2021.05.11.07.14.07; Tue, 11 May 2021 07:14: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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231787AbhEKONf (ORCPT + 99 others); Tue, 11 May 2021 10:13:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:51150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbhEKONZ (ORCPT ); Tue, 11 May 2021 10:13:25 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 59F72613F7; Tue, 11 May 2021 14:12:17 +0000 (UTC) Date: Tue, 11 May 2021 15:13:23 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan.Cameron@huawei.com, alexandru.tachici@analog.com, linux@deviqon.com Subject: Re: [PATCH v2 04/12] iio: adc: ad7192: handle zero Avdd regulator value as error Message-ID: <20210511151323.30832207@jic23-huawei> In-Reply-To: <20210511071831.576145-5-aardelean@deviqon.com> References: <20210511071831.576145-1-aardelean@deviqon.com> <20210511071831.576145-5-aardelean@deviqon.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 11 May 2021 10:18:23 +0300 Alexandru Ardelean wrote: > This change fixes a corner-case, where the returned voltage is actually > zero. This is also what patch ab0afa65bbc7 ("staging: iio: adc: ad7192: > fail probe on get_voltage") was trying to do. > > But as Jonathan pointed out, a zero-value would signal that the probe has > succeeded, putting the driver is a semi-initialized state. > > Fixes: ab0afa65bbc7 ("staging: iio: adc: ad7192: fail probe on get_voltage") > Cc: Alexandru Tachici > Signed-off-by: Alexandru Ardelean Given that voltage_uv == 1 would result in a situation no worse than for voltage_uv == 0 perhaps we should just change the following condition to if (voltage_uv >= 0) ? Jonathan > --- > drivers/iio/adc/ad7192.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c > index d3be67aa0522..79df54e0dc96 100644 > --- a/drivers/iio/adc/ad7192.c > +++ b/drivers/iio/adc/ad7192.c > @@ -950,6 +950,11 @@ static int ad7192_probe(struct spi_device *spi) > } > > voltage_uv = regulator_get_voltage(st->avdd); > + if (voltage_uv == 0) { > + ret = -EINVAL; > + dev_err(&spi->dev, "Zero value provided for AVdd supply\n"); > + goto error_disable_avdd; > + } > > if (voltage_uv > 0) { > st->int_vref_mv = voltage_uv / 1000;