Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1347167lqs; Sat, 15 Jun 2024 05:18:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVD4DCYBsLy5aWMwQHd6nzlCiwGfxxCVk7/gUtkVrtWdzsajMmz3A/Xi9ZPIhsBwCCI3z0V3ygomsJPUkECODoDDTFm8r9WuVZ14V9YYQ== X-Google-Smtp-Source: AGHT+IEySD/fUC5Zt70rxNHnmzqMYkQGbOAGM7sLgJKxWUdkzWgP0Mb5vYpzP+xJYkXPlFqy0aHV X-Received: by 2002:a05:6a20:3d8a:b0:1b6:dc30:c28f with SMTP id adf61e73a8af0-1bae7f0088dmr5714637637.33.1718453901695; Sat, 15 Jun 2024 05:18:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718453901; cv=pass; d=google.com; s=arc-20160816; b=YtkLw6j8GCGzj2mbZZl/eSj4ScgmOKZi1pDNgvK4yhaxQlax+d2bLsY+v9QlbpwLno ve8aGlWchSFEgiX/LcxzTCno+MFPmZvdCQSt/SShShH3uA1RMHCRd0vrcRScodsdsFmW 4jvJsXAbnW059H+/nx0d79prZf35ui2c9NmmYW4sob12RjKi9+3SnPd2O0pYab7rBe1i 6PFIb0uPY8P3NsrTv9mnElVteb2Viqsx6wKHhmZ3W0ZM0B7ntiAWudzpLcOwbYQDfC1D odtp85Nh/vt4+oWiWl5W0tHqbDvm8ZlrKJhOolaQKhGm93dT+8T8E7HAt+zRjAyt5FeQ 6Skg== 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=6BWbBJ3SAwF1x20J1GMMCN6uyZOelnODZdxNgj6W2s8=; fh=ioarvT0aICOMJTSXjkqdp3rfMvQMFJk2WqX2NB7kZxI=; b=kZ1T7rq0WuD1lqQ0A1ShfWhei/UL/5Tf3VOstFPDm2CI7pkgIKYoS4CJiKjuQjY9Wq lcT3AMJ3MJ9EtNGdgIuvkOYdWBe+lTvCdM1j4g/sPYUO+ddANo9uwC5BwvysLx7MbTpL HWJPL3+U9OIJb45pxkI1CIKVgbljrDN0XvMwyr8oTBpjFxagwT2Fi5wjKcbDD4yGDtb1 hUjkyWPhobGwJthFWH8wkkst92ZVjwf6tMhjl9cv1uWvy7S2R0k4XEh4lum+muKPtdLN goQtK9CwMhU7uYy/uRzHamb+cOdFrbAxMCpM0nMdq88CDNp96bvUoihLSdHw1VBlqw6i UUPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CY9cHTAb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-215876-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215876-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a76e4583si7684589a91.136.2024.06.15.05.18.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jun 2024 05:18:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215876-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CY9cHTAb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-215876-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215876-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 17331B20BAD for ; Sat, 15 Jun 2024 12:18:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B0B84597F; Sat, 15 Jun 2024 12:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CY9cHTAb" 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 73E0E45020; Sat, 15 Jun 2024 12:18:12 +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=1718453892; cv=none; b=RUQcWDz3+O1N9fNTWJ5+UZtXrDtY0sHewBzayN+4znX0ZQMvF6sfUqlkofO0TgcT4T/FowqS4XFYl34LZUbzQXiy6ykrGsSIwak5ZC0oVgQUpdjtBCg/nRCH03aoW8eriWGfdUvF4/qe/XpKDXqp+1to3DL0ZibOLJfKP3vFACw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718453892; c=relaxed/simple; bh=PAmHyt7Df6oYdQZUf6lZ39aqd5apsf+H+9AsntTxOlE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ro5EiTqTlafFC01pM2GtObzoqmyNYKwnYY1gCOGmbyOIqdepUvB6lhzG3UV3fG3tt8MX3zj595H4S6dxlrLXW3cIQcIPlCdZ0eBpo5b4eEywzB6gx/QNkqsglCUfPkIPC/CLwXHUMAYufgtZe71tF6zmlJazVyNpI509cTqRNZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CY9cHTAb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1234C116B1; Sat, 15 Jun 2024 12:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718453892; bh=PAmHyt7Df6oYdQZUf6lZ39aqd5apsf+H+9AsntTxOlE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CY9cHTAbujXGslZop/tmUqibAFS/x88HYKyDVbIt9Pr+fQ5ZUkktCsSYraecu1E3V GgyAKgudMMZEJE2SPSvYtW+t9Eiy7m17YqRZOvX876O2IzS7hm0aQWrXRwDt/Ul/Kw j6YCgKJCEaq63yrAg+mLP8hExtuG/6yOQg+U7Pp7PjZT6qNM4XyAnCLP315W+kM/Nb HwK5rgPmRixG9ue8+zDIzLLAo18SlESm7oCyOIkw3cqIxe2ooHI76jDBtu5J5/ST2y QEzm2I3WV3Dj+EgPX5azsyjcGodR3lT28tNFdlDxws9G8zL7FN3otGBrfJvPeu5yRR IuUG18+1lFbKA== Date: Sat, 15 Jun 2024 13:18:04 +0100 From: Jonathan Cameron To: David Lechner Cc: Nuno =?UTF-8?B?U8Oh?= , 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 v2 5/5] iio: adc: ad7944: use devm_regulator_get_enable_read_voltage Message-ID: <20240615131804.7865d878@jic23-huawei> In-Reply-To: <1f02200d-e38f-47f1-a6dd-def7225e5426@baylibre.com> References: <20240612-iio-adc-ref-supply-refactor-v2-0-fa622e7354e9@baylibre.com> <20240612-iio-adc-ref-supply-refactor-v2-5-fa622e7354e9@baylibre.com> <6f607e60a781f74b3cde2405c8c6659d0e304c96.camel@gmail.com> <1f02200d-e38f-47f1-a6dd-def7225e5426@baylibre.com> X-Mailer: Claws Mail 4.3.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=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 14 Jun 2024 10:19:43 -0500 David Lechner wrote: > On 6/14/24 10:16 AM, Nuno S=C3=A1 wrote: > > On Wed, 2024-06-12 at 16:03 -0500, David Lechner wrote: =20 > >> This makes use of the new devm_regulator_get_enable_read_voltage() > >> function to reduce boilerplate code. > >> > >> Signed-off-by: David Lechner > >> --- > >> > >> v2 changes: > >> - don't read voltage from refin regulator > >> - avoid else in return value checks > >> --- > >> =C2=A0drivers/iio/adc/ad7944.c | 54 +++++++++++-----------------------= -------------- > >> =C2=A01 file changed, 12 insertions(+), 42 deletions(-) > >> > >> diff --git a/drivers/iio/adc/ad7944.c b/drivers/iio/adc/ad7944.c > >> index e2cb64cef476..f8bf03feba07 100644 > >> --- a/drivers/iio/adc/ad7944.c > >> +++ b/drivers/iio/adc/ad7944.c > >> @@ -464,23 +464,17 @@ static const char * const ad7944_power_supplies[= ] =3D { > >> =C2=A0 "avdd", "dvdd", "bvdd", "vio" > >> =C2=A0}; > >> =C2=A0 > >> -static void ad7944_ref_disable(void *ref) > >> -{ > >> - regulator_disable(ref); > >> -} > >> - > >> =C2=A0static int ad7944_probe(struct spi_device *spi) > >> =C2=A0{ > >> =C2=A0 const struct ad7944_chip_info *chip_info; > >> =C2=A0 struct device *dev =3D &spi->dev; > >> =C2=A0 struct iio_dev *indio_dev; > >> =C2=A0 struct ad7944_adc *adc; > >> - bool have_refin =3D false; > >> - struct regulator *ref; > >> + bool have_refin; > >> =C2=A0 struct iio_chan_spec *chain_chan; > >> =C2=A0 unsigned long *chain_scan_masks; > >> =C2=A0 u32 n_chain_dev; > >> - int ret; > >> + int ret, ref_mv; > >> =C2=A0 > >> =C2=A0 indio_dev =3D devm_iio_device_alloc(dev, sizeof(*adc)); > >> =C2=A0 if (!indio_dev) > >> @@ -531,47 +525,23 @@ static int ad7944_probe(struct spi_device *spi) > >> =C2=A0 * - external reference: REF is connected, REFIN is not connect= ed > >> =C2=A0 */ > >> =C2=A0 > >> - ref =3D devm_regulator_get_optional(dev, "ref"); > >> - if (IS_ERR(ref)) { > >> - if (PTR_ERR(ref) !=3D -ENODEV) > >> - return dev_err_probe(dev, PTR_ERR(ref), > >> - =C2=A0=C2=A0=C2=A0=C2=A0 "failed to get REF supply\n"); > >> + ret =3D devm_regulator_get_enable_read_voltage(dev, "ref"); > >> + if (ret < 0 && ret !=3D -ENODEV) > >> + return dev_err_probe(dev, ret, "failed to get REF voltage\n"); > >> =C2=A0 > >> - ref =3D NULL; > >> - } > >> + ref_mv =3D ret =3D=3D -ENODEV ? 0 : ret / 1000; > >> =C2=A0 > >> =C2=A0 ret =3D devm_regulator_get_enable_optional(dev, "refin"); > >> - if (ret =3D=3D 0) > >> - have_refin =3D true; > >> - else if (ret !=3D -ENODEV) > >> - return dev_err_probe(dev, ret, > >> - =C2=A0=C2=A0=C2=A0=C2=A0 "failed to get and enable REFIN supply\n= "); > >> + if (ret < 0 && ret =3D=3D -ENODEV) > >> + return dev_err_probe(dev, ret, "failed to get REFIN voltage\n"); > >> + =20 > >=20 > > ret !=3D -ENODEV right? =20 >=20 > oof, yeah messed that one too >=20 Fixed up as well and applied. Enough patches bouncing around that I'd rather clear these little things by hand than see the patch again :) Jonathan > >=20 > > - Nuno S=C3=A1 > >=20 > > =20 >=20