Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp970191lqj; Mon, 3 Jun 2024 06:38:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/udzJ0qeN19I13Qj86+6QeHQr5ehT5+Gdia9q2BS8NxQFckIiotwIZCg93vxlwKJQ2/S2ogsos45hSAbyBgerxW61J6I2/X0aZ4c1DQ== X-Google-Smtp-Source: AGHT+IGz8g7YMWexrpbmpoPS0c8vi9J5WJE6TZQZ3qbz7kRYQ7wKGGCC7DKGqvP3AMAUXLJ47HsE X-Received: by 2002:a05:6870:2308:b0:245:2ccf:becf with SMTP id 586e51a60fabf-2508bbd98camr10899169fac.37.1717421923847; Mon, 03 Jun 2024 06:38:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717421923; cv=pass; d=google.com; s=arc-20160816; b=D7h3PMJSc0042r8IxKbWkqp8ObN2ObRn9og5hViTu37t04z87hbx5FkI+gjkB1rl3z hhvCxhUDdHjzjHOi1WUYJJmF8Z5G1ZVndGMHAdPeCxyx5FE6Eo/H6AJOEAmhrbuTFbI4 NNy0xIzzKf3ZT3s7QY6luL52DY+gItb8M0Csrvc1nvaFIhLsf3Ff0EiWGFC0Bcq55z1X FiJaTmNqechNSjCokj84YaQpdywgwV0svS4TF/n3NAWWqsWOp/IdeIFr5rAWIDLRgAge QLuTQAI3XvJfTCRIQrlAX+prM+dh7h1jH8ngkjByj2KNZK4VGRvWk8W7uiytPeJeUxoV 3HXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=yi0mazzB+1gBreHBUe8h9eRnw4We/Z3jQeykzO1tsNI=; fh=MXnzqdxgH+5x6ipAd2mlJITlBkJAU3D+PyNMakh3+0I=; b=DKMsEHFDabqLWtmwFUX/Nnbq4FfpxPswT6aHtg12M+ygJ3qLHv3/mkCFOpv7SzYf3R p+DjzA1aZ4VudmwvR8gOB4Olf2ZrE6QRcaeCE9lZ2b+GqSxwBBqv9Y3ebW5Jj58TDwEK PKjrji3TwJxxx5RmHFfogR9VHPI/SjWtjW/5IdgJNxJ0zi1nfe+SvaEDYoCeh9YRlbv/ sc3ffxqw6yPuAQyS+IA+bK6pUDHP8T28UFTCfm7exJde3roYIT3rsmDJCFw83qMPQ6wM +MgcIxIR8naxZE+QOMpZ16tttpHnFx4WgvGJZiBxCgufvfmxhGlAGEurAO9vRsXYIGGr v3VQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=MFdnv7I5; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-199227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199227-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794f2f0501esi913428885a.104.2024.06.03.06.38.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:38:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=MFdnv7I5; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-199227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199227-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 81FE01C21A03 for ; Mon, 3 Jun 2024 13:38:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD46D12D76D; Mon, 3 Jun 2024 13:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="MFdnv7I5" Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 859F312BF3A for ; Mon, 3 Jun 2024 13:38:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717421918; cv=none; b=VLEqI0zbX7i+33CIVhUpb+pGW5jKgIiqpIY56fs5O/2dj9YaSUopV575nXwdbNImxhcM6wQBZm3S5ItexiiUuFgWg7FJHq8nmhzV2A1me9ocwMg8axn8wsq1R8u0/tnawtsPHZIxC8ysQCwhK2Dls2qJGMcGIAc5PcJOnOUM1j8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717421918; c=relaxed/simple; bh=vtWc8iVFqsvABRv79bFQ/v9WSZIoE8OBawLvKAFSD5M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fA0xhFaDjbPBGwQiRjquR9GD7yooyiNnyM1hr/i6T+PczoG/EcdwxbqG4vtt4BxV4vSMWBf7bhLZITflfxjnMvspJaH/+FiZcIkVmCh2igjnRfnVeYnlwT+Heq9+0hbB3biFta/t3JmpMLlIaG/saUPEzFytDRGVG7bb/wH58Ec= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=MFdnv7I5; arc=none smtp.client-ip=209.85.160.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-24c10207d15so2079075fac.2 for ; Mon, 03 Jun 2024 06:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1717421915; x=1718026715; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yi0mazzB+1gBreHBUe8h9eRnw4We/Z3jQeykzO1tsNI=; b=MFdnv7I591E91zbrvgkEbtOuEZp29WCU2YITuUqJzNNR5eTknblW/5S1n0whmj1tae eY92BcGPZhLCQwd3o5zchL+jD4bGBhTBrmvVhe9vArPthJm+KsHVeLLj77M1/AT+RLxc gcyyDQs4N97py134bA+4qhqTeO4Eh60CxbIMsXHtALs1giq7lewlzXdrkvTIbRo1fIPf Uh8CjchNgLUhhimLug4goz6HE/AbqIkT8etLSVGkqU6gKJTFZzZLG8c7meppUL9OyCoS DN+OURhlhFwiWhn5GPfjUpS8RGhHjccs/CpuyxdDJAr3saRBJgl7kxagq3CMwfl/fcFp fTaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717421915; x=1718026715; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yi0mazzB+1gBreHBUe8h9eRnw4We/Z3jQeykzO1tsNI=; b=S0dsiNykouzJahXPaXAteN+iIUEBD8I0UCAVvfRZNJ4FrhXX1YoicdnWMM7koilqE5 cka4cSWoJESjIzlGPMBe3iRhd0k0iYIbNBvET9m1o5fJ0KfCxmvBqxCAkRsNFeeWNwLq 7nqVcSd8ryeBgNp6l2LGMxRls5D84h/37gibZ+d2hvxOPsPVx+5lRHaX2cNuoExnzupD 1h2KWI8ofsqKymcgdUfiSgC3yHXrEqmHx3loUrEh0IMXoSrmceMEqwigi91FBpdfUJBy DHYEL+eYRs7RgTv89UrSSGw6eON70Dgqh4DPvQj3/0IqAZ0Bw51jugr8rGpYOKuLGMj0 QpDQ== X-Forwarded-Encrypted: i=1; AJvYcCVvviXSIzdE4b7sDh7HUiRqOhTGxgz6nkfUPYty4SOdU/LtKoyvLgGP1JbCMKLu5aP98r4Nsz/6PUT+H2HVmJKF6aN6Jg3Xtcc2I6Yn X-Gm-Message-State: AOJu0YwogwghQ/Cc3YYe3DDU7Gk3jo3jf2Z+ebsbnjD7N3PlCXy5u4wa IuYMcwJYOo1FadbWdqLJBfLHZZON6+/ejPltqARuQPeVP97tvA89HZ7vznNhqMc= X-Received: by 2002:a05:6871:54c:b0:24f:e09d:3c82 with SMTP id 586e51a60fabf-2508b7de2ecmr10411175fac.12.1717421915552; Mon, 03 Jun 2024 06:38:35 -0700 (PDT) Received: from [192.168.0.142] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-250852c97a8sm2442529fac.50.2024.06.03.06.38.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Jun 2024 06:38:35 -0700 (PDT) Message-ID: Date: Mon, 3 Jun 2024 08:38:34 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/5] iio: adc: ad7944: use devm_regulator_get_enable_read_voltage To: Jonathan Cameron Cc: Marcelo Schmitt , =?UTF-8?Q?Nuno_S=C3=A1?= , Michael Hennerich , Mark Brown , Liam Girdwood , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240531-iio-adc-ref-supply-refactor-v1-0-4b313c0615ad@baylibre.com> <20240531-iio-adc-ref-supply-refactor-v1-5-4b313c0615ad@baylibre.com> <20240601140139.3166dcaf@jic23-huawei> Content-Language: en-US From: David Lechner In-Reply-To: <20240601140139.3166dcaf@jic23-huawei> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/1/24 8:01 AM, Jonathan Cameron wrote: > On Fri, 31 May 2024 16:19:36 -0500 > David Lechner wrote: > >> This makes use of the new devm_regulator_get_enable_read_voltage() >> function to reduce boilerplate code. >> >> Signed-off-by: David Lechner > A possible corner case inline. > > Patches 2-4 lgtm. >> --- >> drivers/iio/adc/ad7944.c | 62 +++++++++++++++--------------------------------- >> 1 file changed, 19 insertions(+), 43 deletions(-) >> >> diff --git a/drivers/iio/adc/ad7944.c b/drivers/iio/adc/ad7944.c >> index e2cb64cef476..42bbcb904778 100644 >> --- a/drivers/iio/adc/ad7944.c >> +++ b/drivers/iio/adc/ad7944.c >> @@ -464,23 +464,16 @@ static const char * const ad7944_power_supplies[] = { >> "avdd", "dvdd", "bvdd", "vio" >> }; >> >> -static void ad7944_ref_disable(void *ref) >> -{ >> - regulator_disable(ref); >> -} >> - >> static int ad7944_probe(struct spi_device *spi) >> { >> const struct ad7944_chip_info *chip_info; >> struct device *dev = &spi->dev; >> struct iio_dev *indio_dev; >> struct ad7944_adc *adc; >> - bool have_refin = false; >> - struct regulator *ref; >> struct iio_chan_spec *chain_chan; >> unsigned long *chain_scan_masks; >> u32 n_chain_dev; >> - int ret; >> + int ret, ref_mv, refin_mv; >> >> indio_dev = devm_iio_device_alloc(dev, sizeof(*adc)); >> if (!indio_dev) >> @@ -531,47 +524,30 @@ static int ad7944_probe(struct spi_device *spi) >> * - external reference: REF is connected, REFIN is not connected >> */ >> >> - ref = devm_regulator_get_optional(dev, "ref"); >> - if (IS_ERR(ref)) { >> - if (PTR_ERR(ref) != -ENODEV) >> - return dev_err_probe(dev, PTR_ERR(ref), >> - "failed to get REF supply\n"); >> - >> - ref = NULL; >> - } >> + ret = devm_regulator_get_enable_read_voltage(dev, "ref"); >> + if (ret == -ENODEV) >> + ref_mv = 0; >> + else if (ret < 0) >> + return dev_err_probe(dev, ret, "failed to get REF voltage\n"); >> + else >> + ref_mv = ret / 1000; >> >> - ret = devm_regulator_get_enable_optional(dev, "refin"); >> - if (ret == 0) >> - have_refin = true; >> - else if (ret != -ENODEV) >> - return dev_err_probe(dev, ret, >> - "failed to get and enable REFIN supply\n"); >> + ret = devm_regulator_get_enable_read_voltage(dev, "refin"); >> + if (ret == -ENODEV) >> + refin_mv = 0; >> + else if (ret < 0) >> + return dev_err_probe(dev, ret, "failed to get REFIN voltage\n"); >> + else >> + refin_mv = ret / 1000; > How does refin_mv get used? Previously we never queried it's voltage (I assume > because it supplies an internal reference? > > Are there any regulators that are real enough to enable but for which a voltage > can't be queried? I think fixed regulators with gpio control are in this > category... > Hmm... don't remember why I did it that way (was a while ago). I will bring back the have_refin flag instead.