From nobody Thu Apr 2 10:39:19 2026 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (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 F214238228A for ; Sun, 29 Mar 2026 22:47:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824438; cv=none; b=B506qgDffzsSJ2hOP2UMyUoZBaeqLGQWO0ZGt95ewo2NDI9u1N22iDoqDmJ7BdqUCDWB72cwNn/8Fw6filBqA3SfdfjzZLOKoaxRpzInZeRMbsphfiBxFq3gcgcqRdsodc2UA+jjDBKKGVo3jRxow5BuokW1TKuQsoLf44j99Go= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774824438; c=relaxed/simple; bh=qKG/Dk+YwmU5YXsCQA9AtevlFGr051QfNe264bDQuZg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M8z5HJ83jL9kKr71HLFJu94Qb/282X4VGvKjMT13dtkvw+I9wCn5/UC6FJ1aMGkKJstO4QSltuaXo5es/hdWB2l906sAkb2SuL6o5HjmroTRsxRxg7fCKsC4md+pvAHP78P1QLvB4QitbQa6EmPyovZ/L/6rN5HaKTl361j/aCc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=opsU/Xj2; arc=none smtp.client-ip=74.125.82.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="opsU/Xj2" Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-2c66eafc1easo349248eec.1 for ; Sun, 29 Mar 2026 15:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774824436; x=1775429236; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xjnte4r6ScLiwT0fTQiZsZDg6SDDULG2OwlHg75Fmwg=; b=opsU/Xj2tS3Jtx/E3effpQYBTOCbK/HGgoMi2CjbHvYhmU12HfqKIb1076Xs7nvqmV 25U4n1hjBReW14UkhTupn+c66972mwi0iQZD4OmQD4THPqwcvwUwEOte+psWpM/+V/8y x2vU/6aVW/23PReohDfzD4d2EwNz6zAgzcTFt4rl5ZvE48WfSp5mU5bdt3XwHG9qHUtw adc6dlnOG2GInLtiNf2YSFVlS2IQ906qdyRLWac/IDYyNOVl1RKjHs6o9Ku/SQ51nxVO h4VUIOkD0b6O2V0NGUlBjIuInlqqJ6NsZVZuxWRVya9kyGkBohZer4CobqYvS9bGcFNE /RRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774824436; x=1775429236; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=xjnte4r6ScLiwT0fTQiZsZDg6SDDULG2OwlHg75Fmwg=; b=MRrIEm0EouDBrLOXZliQ9zZH4u62e+ZJEtUtBaLOxA90Z1RE8CrAWhQfymZDc18Zov Jeg1sVoPaAyPSCtfwyFI2D3MhNphLr+WnKXUAndNaKwKaUoTRxY9q2kALGjUyJAhluet HDA3I+NLN0wCxp4Xy0wbmVznNCfKclm7e4dk0gdX3kV7mt17GUGLkI6FVSwQwEeG1vj2 l9HTKVfRSKHyO1Up3X1XrEZtpY8E5bgMws1ZiHPy2ghTOacMejieIZ2/7R91ZoXKEL6V xA1xRQC6ccyw/QBjvg9k+4M2r5ICF/LXW0QRlMnFFM47IpRvp4lYrmcbIL9oRuU7KvEG t73g== X-Forwarded-Encrypted: i=1; AJvYcCWirWUC5KNe0BZSj3PUWyvAK1legcNLZWdI33nVR9+0MK9AbOWgDh8EmpLkBmu0cniXRLFxwGdTeRxolGU=@vger.kernel.org X-Gm-Message-State: AOJu0YyNzMGYjH3yMsRBbVPaAREglyEUkhChBvpNvuOEOJMaXwUXAxu5 aZAYikkgVvjhsQa91XLgsFWk9kjHzuLquf+zxGFkBRpfx1plmrhbpiEb X-Gm-Gg: ATEYQzz7IyPp5I9geZ1T2vtkInZA6c3I81s7bu00X5ge7VOZGZ1p0vUGy2Tv/+NlUEK +RU4gnodvGRY+tytNaWpoAe7dG5rcM+OfhoeMmB6b1kQmlTnUWrJ7oQQMl8oAHSymMdVIxqzP+m +b0gWTg3+92hp7JwvGz/Rjtq11ZbJMV0ULIENEzvanEV0MmDzQV1ZWOQhQk5IL8XsO4khGRedHm QOeBhd06VGQVSpDySCm9ukn4c1IjLYL6jwNTRL5u5rpGAKEZH01j34JS8ORd7pRSViSPror5kmp KEQIPjkf7c0U1MxmxGwynJkw+bqNeGAJP050+zc0IAkPxkPqknjWZRbHrwefQ4ivz324asPb0zv MYWZ46KfdF5ZURNhLC48/NYgDs5fotuxggJLIrCJTzMqgJ9qcSTfu+oUdCHhEqJxiVMTSb3zQvP EihDhufg2eSnXeMU5lgfn5m4dUPW6J0fmRgzfseRE0tIRnKRV8disb6kRemeaw7ILlQGalX2Gg6 lHtcjqye5e8nKf/iH4GoAmYXg== X-Received: by 2002:a05:7300:1489:b0:2c5:220c:5673 with SMTP id 5a478bee46e88-2c5220c616bmr2019888eec.5.1774824436043; Sun, 29 Mar 2026 15:47:16 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:7265:773a:8e51:c62f]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c3c7971d97sm5840295eec.30.2026.03.29.15.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 15:47:15 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 29 Mar 2026 15:47:08 -0700 Subject: [PATCH v4 3/4] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage() 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 Message-Id: <20260329-ti-ads7950-facelift-v4-3-c568c508c49a@gmail.com> References: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> In-Reply-To: <20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com> To: Jonathan Cameron , David Lechner Cc: =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Jonathan Cameron X-Mailer: b4 0.15-dev-a6826 The regulator is enabled for the entire time the driver is bound to the device, and we only need to access it to fetch voltage, which can be done at probe time. Switch to using devm_regulator_get_enable_read_voltage() which simplifies probing and unbinding code. Suggested-by: David Lechner Signed-off-by: Dmitry Torokhov Reviewed-by: Bartosz Golaszewski --- drivers/iio/adc/ti-ads7950.c | 48 ++++++++++++----------------------------= ---- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index c31c706c92a9..0b98c8e7385d 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -334,19 +334,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indi= o_dev, unsigned int ch) return st->single_rx; } =20 -static int ti_ads7950_get_range(struct ti_ads7950_state *st) +static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st) { - int vref; - - if (st->vref_mv) { - vref =3D st->vref_mv; - } else { - vref =3D regulator_get_voltage(st->reg); - if (vref < 0) - return vref; - - vref /=3D 1000; - } + unsigned int vref =3D st->vref_mv; =20 if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V) vref *=3D 2; @@ -375,11 +365,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_d= ev, =20 return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - ret =3D ti_ads7950_get_range(st); - if (ret < 0) - return ret; - - *val =3D ret; + *val =3D ti_ads7950_get_range(st); *val2 =3D (1 << chan->scan_type.realbits) - 1; =20 return IIO_VAL_FRACTIONAL; @@ -573,30 +559,25 @@ static int ti_ads7950_probe(struct spi_device *spi) spi_message_init_with_transfers(&st->scan_single_msg, st->scan_single_xfer, 3); =20 - /* Use hard coded value for reference voltage in ACPI case */ - if (ACPI_COMPANION(&spi->dev)) - st->vref_mv =3D TI_ADS7950_VA_MV_ACPI_DEFAULT; - mutex_init(&st->slock); =20 - st->reg =3D devm_regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) { - ret =3D dev_err_probe(&spi->dev, PTR_ERR(st->reg), - "Failed to get regulator \"vref\"\n"); - goto error_destroy_mutex; - } + /* Use hard coded value for reference voltage in ACPI case */ + if (ACPI_COMPANION(&spi->dev)) { + st->vref_mv =3D TI_ADS7950_VA_MV_ACPI_DEFAULT; + } else { + ret =3D devm_regulator_get_enable_read_voltage(&spi->dev, "vref"); + if (ret < 0) + return dev_err_probe(&spi->dev, ret, + "Failed to get regulator \"vref\"\n"); =20 - ret =3D regulator_enable(st->reg); - if (ret) { - dev_err(&spi->dev, "Failed to enable regulator \"vref\"\n"); - goto error_destroy_mutex; + st->vref_mv =3D ret / 1000; } =20 ret =3D iio_triggered_buffer_setup(indio_dev, NULL, &ti_ads7950_trigger_handler, NULL); if (ret) { dev_err(&spi->dev, "Failed to setup triggered buffer\n"); - goto error_disable_reg; + goto error_destroy_mutex; } =20 ret =3D ti_ads7950_init_hw(st); @@ -636,8 +617,6 @@ static int ti_ads7950_probe(struct spi_device *spi) iio_device_unregister(indio_dev); error_cleanup_ring: iio_triggered_buffer_cleanup(indio_dev); -error_disable_reg: - regulator_disable(st->reg); error_destroy_mutex: mutex_destroy(&st->slock); =20 @@ -652,7 +631,6 @@ static void ti_ads7950_remove(struct spi_device *spi) gpiochip_remove(&st->chip); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); - regulator_disable(st->reg); mutex_destroy(&st->slock); } =20 --=20 2.53.0.1018.g2bb0e51243-goog