From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9EB3C433B4 for ; Wed, 12 May 2021 06:28:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A73596193F for ; Wed, 12 May 2021 06:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbhELGaB (ORCPT ); Wed, 12 May 2021 02:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbhELGaB (ORCPT ); Wed, 12 May 2021 02:30:01 -0400 Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC05EC061574 for ; Tue, 11 May 2021 23:28:53 -0700 (PDT) Received: by mail-vs1-xe2b.google.com with SMTP id x17so7131545vsc.0 for ; Tue, 11 May 2021 23:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4UwPaiMvT71jZjZxQi+bCQNJCogOTLRNHtxmsH4BW50=; b=d7RU5qCrJDkEmIQMPHye1G5TVdNusfGm+NTUX5fTO4/eJOtrKm4FvEy+/5f94acZyl IuIdA/BinCUwI0yZUpfGK1vzwW1P7K4I4xMVqdf6iHuh97Jgn/mQ/TKVDZ3OBeyAJ32f g/rhQijVOHTYqFy2et4D1inpQO/415khcRiAWo+pxnUG3wtEMi3vmD2Fiwx7Ip77IHOn /X2K3X4ouu+cV27gxCg1ySUFMxsVTiuDZ0tO1T7oj5Onl7fVpoKCsVuzAkYn/tF/S3ii DQDYTv/kJGNpHFZNWAfctmz80ByQgXxzAjUAfQG5y+KMsGroeFkY4/T8H4JDFp0hg1Ga 2H/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4UwPaiMvT71jZjZxQi+bCQNJCogOTLRNHtxmsH4BW50=; b=LyYyaS4TYZ11lht6wWAkcCEkfDOxUE9LmYwQ3MxeBZwLHhAVNKB3xIoFjhLXz766JT f2cwu3aZb1jCxUrMDvqqdae2iddF32tbYbAYSvHYK9041dSRavudiZFUm8oS8WhPlRob miGqIeIY0YhqoNXnCyaqGQyxq7rrlDPT9tukaP02SmHfx6cURTTK2yB1O2/RZUJ3DzXv hOHMV6yxHwvhQaYYgPK8LDc6F6cc/k1Fw3No4MeqlrKHNbUFupiAB/kkQ0rWNrfqVWbY dWxYtFrGkDMfvBqf6zDDJdnIg/iHoeMQja6wZx2sDS5MwbCVbCoat8nGWHC/vSeOp0Ii iDMg== X-Gm-Message-State: AOAM531aXULlJDIIkKgNCeT5todwDiXJv+40sGPhHqC7aYWmUx7kyqHf OxTA0BIenwf0t+dyWceC1Lt+36wZDUOP3XAm+nvqaw== X-Google-Smtp-Source: ABdhPJxETzUBunSy7yLPByflWEIZ1igjsdrbkBYLFIdko5atRxzG9ECM7P7kgvmTAvzYG75JZq6WnS4SM0uOEIUWB6Y= X-Received: by 2002:a67:db91:: with SMTP id f17mr30048675vsk.47.1620800932800; Tue, 11 May 2021 23:28:52 -0700 (PDT) MIME-Version: 1.0 References: <20210511071831.576145-1-aardelean@deviqon.com> <20210511071831.576145-5-aardelean@deviqon.com> <20210511151323.30832207@jic23-huawei> In-Reply-To: <20210511151323.30832207@jic23-huawei> From: Alexandru Ardelean Date: Wed, 12 May 2021 09:28:41 +0300 Message-ID: Subject: Re: [PATCH v2 04/12] iio: adc: ad7192: handle zero Avdd regulator value as error To: Jonathan Cameron Cc: linux-iio , Linux Kernel Mailing List , Jonathan Cameron , alexandru.tachici@analog.com, linux@deviqon.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 11 May 2021 at 17:12, Jonathan Cameron wrote: > > 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) ? hmmm, you're right; i think had some narrow vision about this; will send a v3 > > 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; >