Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3398566rdb; Sun, 10 Dec 2023 04:22:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKPMWQurVS0hDeIJtPRtWPbgAIptzrCFJFgJS3o5Is9DKgv7eNGKRWRBGRnqwzN/rmc9d4 X-Received: by 2002:a17:90a:4306:b0:286:6cc1:3f0b with SMTP id q6-20020a17090a430600b002866cc13f0bmr1984319pjg.66.1702210959227; Sun, 10 Dec 2023 04:22:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702210959; cv=none; d=google.com; s=arc-20160816; b=roT32KG8/CNUlmCn7tKiEDMM3HMGCR7ic9qb0Hv0xvdlUMryam4wEYulsUSR/nZMA0 1cYuggqAOu4rEyvX2kZo2zoRXDeTaXSlJZH99uCuX5MFWK5Gr3lJA3Eq0hXhuwY0y9D/ w2lgIaYQSMaMCId4CuE1S91plTEeZy9j4rIRuvBIzr9k+jalw0uvwiiTyDExE6rMqO1v +Lfr3P5VEdo7F0NfPatg2rGw86KOi5rw1bzZHMijk8vySPKVeWo68q5HZ0TZcVWNeGYw kuj5vnSdXX7LiMIYHrAM4CRTxjSdaYPuI10YnbYUqDMIT6iNuH6sg/1MANQ6uCbli0/B +rpQ== 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 :dkim-signature; bh=Rzx3IEhFnpRxdzk/yNB59hobM2z5l+AumIzX79K0f4I=; fh=WD/63rbd+kqN9ItFJmOtMPp0c5kgjUIaSO4QQPqWfy8=; b=nwcDWP953XLTYhrsN3djLKXmx+nJYAOa5Q05iaCleP3NO5dhqCSP1d+zUL7OQ0P16N 6bnAMC6w4DQZ43SM/l0WnMiiz/DM3A5ihJhpm0rgDM/H2CPpISVJ2ZJP3az8uQG0SllC 0gwkLbZYfqAjd0GX9UE4zeMJ0cUG7yvNyM1uMdgteeOY81vzLnCURUmFlWegNjvNuaEn K7C5A1/uDJDW8W5xLjNbQv9IMa5D/S4YYlUCC2FYhJWPWqwDEWul0OukDD1gH1Cu0DTO mlAe1YfKdaynDgsn/XHe0V/s49nfDBfOD26h9A0CzXR+qoLfv4DITXWTdEofJWwtXfqe IKtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g7pb7o+T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b3-20020a17090a9bc300b0028686137ba6si4511558pjw.90.2023.12.10.04.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 04:22:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g7pb7o+T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9FD008097A5F; Sun, 10 Dec 2023 04:22:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231778AbjLJMWV (ORCPT + 99 others); Sun, 10 Dec 2023 07:22:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjLJMWU (ORCPT ); Sun, 10 Dec 2023 07:22:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D444EFF for ; Sun, 10 Dec 2023 04:22:26 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DDD5C433C8; Sun, 10 Dec 2023 12:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702210946; bh=soHpppCx2/0tcuziKrSgy12+x/XFsaso6RhP5ZsXMGE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=g7pb7o+TXb3k5qiipbQOoYvEPmYh4Nv7Y+N2wxjgjdXT8U+JIMUgKiLODex7rl9jv tNS2bupApGOy/Y6W1fi4d4RbletRkIp4bGLAaXr/djNWY+h64bGXB6411qYxwTI1Qn 3VbjNjhTOgSjlEUJCdgK3K4lrlpa06s86pXXqIPeTonDijFqFFpIFUuK8olNHkggtP /5vLkrwPSxGtghhmYS8MNWWKPVgE4nG9/SCXD+ouwzeDS0B8KHZEnIwEfAKCrRFf7F vOU+jISiSDBoZvl3iETiFvOtsbXbdWmRQjHEjSHnNboEN0qtVNi9IMGHZbyfBGFaJf +Eiz2HedbvWdQ== Date: Sun, 10 Dec 2023 12:22:18 +0000 From: Jonathan Cameron To: Marcelo Schmitt Cc: , , , , , , , , , , , , , , Subject: Re: [PATCH v3 08/13] iio: adc: ad7091r: Enable internal vref if external vref is not supplied Message-ID: <20231210122218.6c0c1d19@jic23-huawei> In-Reply-To: <0c71001f4c1eba169230caee6640661cec4b979b.1701971344.git.marcelo.schmitt1@gmail.com> References: <0c71001f4c1eba169230caee6640661cec4b979b.1701971344.git.marcelo.schmitt1@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 10 Dec 2023 04:22:36 -0800 (PST) On Thu, 7 Dec 2023 15:41:25 -0300 Marcelo Schmitt wrote: > The ADC needs a voltage reference to work correctly. > Enable AD7091R internal voltage reference if no external vref is > supplied. > > Signed-off-by: Marcelo Schmitt > --- > drivers/iio/adc/ad7091r-base.c | 9 ++++++--- > drivers/iio/adc/ad7091r-base.h | 1 + > 2 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c > index f2cb638b8d77..59a7ec44955d 100644 > --- a/drivers/iio/adc/ad7091r-base.c > +++ b/drivers/iio/adc/ad7091r-base.c > @@ -215,10 +215,13 @@ int ad7091r_probe(struct device *dev, const char *name, > iio_dev->channels = st->chip_info->channels; > > st->vref = devm_regulator_get_optional(dev, "vref"); This does not return NULL, only a valid regulator or an error code. > - if (IS_ERR(st->vref)) { > - if (PTR_ERR(st->vref) == -EPROBE_DEFER) > - return -EPROBE_DEFER; > + if (IS_ERR_OR_NULL(st->vref)) { You still need to explicitly handle deferal here. There might be a perfectly good regulator that just isn't ready yet and if that happens we want to try probing this driver again later rather than papering over it. > + /* Enable internal vref */ > st->vref = NULL; > + ret = regmap_update_bits(st->map, AD7091R_REG_CONF, > + AD7091R_REG_CONF_INT_VREF, BIT(0)); > + if (ret) > + return ret; > } else { > ret = regulator_enable(st->vref); > if (ret) > diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h > index 9546d0bf1da7..e153c2d7deb5 100644 > --- a/drivers/iio/adc/ad7091r-base.h > +++ b/drivers/iio/adc/ad7091r-base.h > @@ -20,6 +20,7 @@ > #define AD7091R_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6) > > /* AD7091R_REG_CONF */ > +#define AD7091R_REG_CONF_INT_VREF BIT(0) > #define AD7091R_REG_CONF_ALERT_EN BIT(4) > #define AD7091R_REG_CONF_AUTO BIT(8) > #define AD7091R_REG_CONF_CMD BIT(10)