Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1205311lqj; Mon, 3 Jun 2024 13:34:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbuypW5kniaEAMQb0evFkPdKhCQ83O1lrUuUNwo7vK+i3hD9LH/qJ0LEAnU16f2N+ljEST49c0AgmbY50vrind+JPLncm4Wq+YKP0diQ== X-Google-Smtp-Source: AGHT+IH9wv4She+z33FNshxXDafrWPo1FwS74klTLBUUpXYTL+4NEbs8+dpeDPjgWCeFPUx+4BZu X-Received: by 2002:a17:902:d507:b0:1f4:7713:8f6 with SMTP id d9443c01a7336-1f6370a0cd6mr133835435ad.52.1717446854151; Mon, 03 Jun 2024 13:34:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717446854; cv=pass; d=google.com; s=arc-20160816; b=vEoX+X+ZkoqkWiLSM0y0sfgRQqQeTReQ6vZdWb5100gKHMg7CwAA9BTOqcxRLv50Nj bMwIxieZ5utENI5pwCWQo8pgp4iGmEoAO4sh84CE5sxx1dFt5Ba2UTtnrmAPcZc1Q4TF 4chaQB0evdUXmlBmbrx0x5o3E8iQp2SYMi4JtjIaK9i1qHuLsSJQlxRjIWWMUmS9zAz7 03cog5CWCCoMmcNmBfdzl4U3tKKjVW9jKQfZVY2npwf66Gv+7hP02G6yx/Srs/JAw0mG eRxOLdFovtjudYr+pb6NCSzRZp1wYSORl5O2DDJiswDP6loIeN3OUwzfRSdYOa2desl2 OZ+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=/umuwS7DeMhY43gAYWcogsFgXltkttsKQQMf9NClqDY=; fh=6JorulOQ42RRCQjQGyFk0ER8poxrwdLK8i+sQQg4vLg=; b=PaRG9Ob0rY7HvGWVdapqgNzOFJodRa4hxxYrRSL2BXBRGRsACvRgmhTWQc2ZsWuOpN uwrKaSjRNdxViCfpxx3YqP2EN6P3zZvDHpl3t6zbIaIBzk1B0pwZfOpxUMe1HA/JDR/M sbkGfPUaiz76gsxCPScIMTKBlC8XMDUZN0PwhzeanlasYcgN1dkJfstwoej9IqyQ7T5r TSbHL3AD+C8BWaB29jcHJvmbNkHfexVkhnv//RrFY6G+vpj21vjZd7rPwnjqNOp6uowu pfUBt3R9aXCsr9liPnKB+qzIO3HxdvSAHu5KJHPIugsx1JVP1Ay8WwKeCv1NZTQOpDWQ 0v6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NAUiB4zD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f6323dd6aasi70717895ad.258.2024.06.03.13.34.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 13:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NAUiB4zD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 54D92B24F63 for ; Mon, 3 Jun 2024 20:11:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7099B13B58C; Mon, 3 Jun 2024 20:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NAUiB4zD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9371946A4; Mon, 3 Jun 2024 20:11:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717445468; cv=none; b=KN4JLeqNzHVTR1t5x0pZi/R7kLqChtnIIjb2RkQ/Hn6RpeleYOuKbXzGxZHRHlf9avMVrQSCv0aqLNCdngb2fPGSgJIueQo/mkRkNOhFN5bLHFQI4ZPmmEZ1IPLfUOt1GSZgGuWTFk2hoRkAM1mYh8a2dT4d895SkulgjxBdup0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717445468; c=relaxed/simple; bh=ZUOP9PSrARPnDqbSPue2KgCqb/TojcCqEcsIYquZPWo=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TjeSjrK5V16fzS1bWXcie31oi4du647eS9t5FDI7b7fhk3vI8nUAX4fgVXq2Kv55nb9tGkdtm1shVJLo+oyN1AwqPrJIBag6AGQ/RAdJcvkPOMUyWLc8CBmQMeSG3WHbk1octhBT/roj4gSC3nGMonVKnj45WXso9cBYffDA7UY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NAUiB4zD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41FD4C2BD10; Mon, 3 Jun 2024 20:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717445468; bh=ZUOP9PSrARPnDqbSPue2KgCqb/TojcCqEcsIYquZPWo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NAUiB4zDMI/JVqLko9RJT0BZaqhKnNLIhwc191pw+phDUCvA8EIClHXBbG7kvvioj Xikw000YiDSr3hhtxMcwo8zd29d7C2Wk+f1OI8tKzdUf3Dkl4VhZHMeRHHl4ULXtS7 PL6eNZblfXPeeJn6lZyDprgpidbpP/dbj/85d+d/JPcjw+dqP1NeOD5L+JuLGmS23D YOLO7s6j+xtmIcx1ObRrvz/t2YODrh/7tKQWeC5PgqVGbmSJdymZ2fQBDSqUSGMNQH aGaZ0vUGZO3Bzk+l1fXlQBz1JJVYDrSE9Fwfdhtyrj1smnbEp9ph1POq0yXEcTKlSO 81QLlrBonkLHw== Date: Mon, 3 Jun 2024 21:10:56 +0100 From: Jonathan Cameron To: David Lechner Cc: Marcelo Schmitt , Nuno =?UTF-8?B?U8Oh?= , Michael Hennerich , Mark Brown , Liam Girdwood , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] iio: adc: ad7192: use devm_regulator_get_enable_read_voltage Message-ID: <20240603211056.3d297018@jic23-huawei> In-Reply-To: <9bcf9ed6-dcba-4e23-9845-a81cf39a3153@baylibre.com> References: <20240531-iio-adc-ref-supply-refactor-v1-0-4b313c0615ad@baylibre.com> <20240531-iio-adc-ref-supply-refactor-v1-1-4b313c0615ad@baylibre.com> <20240601134828.68c3acba@jic23-huawei> <9bcf9ed6-dcba-4e23-9845-a81cf39a3153@baylibre.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 3 Jun 2024 08:36:51 -0500 David Lechner wrote: > On 6/1/24 7:48 AM, Jonathan Cameron wrote: > > On Fri, 31 May 2024 16:19:32 -0500 > > David Lechner wrote: > > > >> This makes use of the new devm_regulator_get_enable_read_voltage() > >> function to reduce boilerplate code. > >> > >> Error messages have changed slightly since there are now fewer places > >> where we print an error. The rest of the logic of selecting which > >> supply to use as the reference voltage remains the same. > >> > >> Also 1000 is replaced by MILLI in a few places for consistency. > >> > >> Signed-off-by: David Lechner > > Ouch diff didn't like this one much and it is a bit hard to read. > > > > One case where I think this has an unintended side effect. > > See below. > > > > ... > > >> @@ -1219,74 +1211,54 @@ static int ad7192_probe(struct spi_device *spi) > >> * Newer firmware should provide a zero volt fixed supply if wired to > >> * ground. > >> */ > >> - aincom = devm_regulator_get_optional(&spi->dev, "aincom"); > >> - if (IS_ERR(aincom)) { > >> - if (PTR_ERR(aincom) != -ENODEV) > >> - return dev_err_probe(&spi->dev, PTR_ERR(aincom), > >> - "Failed to get AINCOM supply\n"); > >> - > >> + ret = devm_regulator_get_enable_read_voltage(&spi->dev, "aincom"); > >> + if (ret == -ENODEV) > >> st->aincom_mv = 0; > >> - } else { > >> - ret = regulator_enable(aincom); > >> - if (ret) > >> - return dev_err_probe(&spi->dev, ret, > >> - "Failed to enable specified AINCOM supply\n"); > >> + else if (ret < 0) > >> + return dev_err_probe(&spi->dev, ret, "Failed to get AINCOM voltage\n"); > >> + else > >> + st->aincom_mv = ret / MILLI; > >> > >> - ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, aincom); > >> + /* AVDD can optionally be used as reference voltage */ > >> + ret = devm_regulator_get_enable_read_voltage(&spi->dev, "avdd"); > >> + if (ret == -EINVAL) { > >> + /* > >> + * We get -EINVAL if avdd is a supply with unknown voltage. We > >> + * still need to enable it since it is also a power supply. > >> + */ > >> + ret = devm_regulator_get_enable(&spi->dev, "avdd"); > > > > What happens if the entry simply isn't there in the DT. > > Previously I think the regulator framework would supply a stub whereas > > the devm_regulator_get_enable_read_voltage() returns -ENODEV so isn't > > caught by the handling and I think it should be. > > Ah, yes so: > > if (ret == -EINVAL || ret == -ENODEV) { > Yes I think.