From nobody Thu Jan 30 14:52:40 2025 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (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 D05251BD513 for ; Wed, 20 Nov 2024 21:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732138457; cv=none; b=Prw1FPC7hEC/K5u/+BEo+N1ZVvYdLLvn4P5DM9/o/Il6KuhXEnfKTPNnPGxATc/cv+fXXuxNwHQCq7ee7JfH6m8nqc/+nt2171S2MLz4GC63q+Z4vy/+/0DsdlK02aiABUvB3DCzbmimEDEvHak0CmC7TGaqrafj66C9xo4+FM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732138457; c=relaxed/simple; bh=p+nS5eNSFSea7wrSjxxVMVpqrYPjYIH7CARSb8ahoso=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YLqLkPMie3ZgwmDTJF4y7zuOncfDpP97zie6pHK38F8CPWlnFcKn2/OcvDlEE0n7UwmX9Lkdqy8m5OLgC4w3NJflTk2MLCCTNrX0EnGLE8ZaSuCQyRz3r+EHbLDySUBEuD8/L82iY9s2Wl1Qrh9TEYBPN2CPwADsx5WAzBNqUnU= 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=eWdCakaS; arc=none smtp.client-ip=209.85.160.54 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 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="eWdCakaS" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-27b7a1480bdso192587fac.2 for ; Wed, 20 Nov 2024 13:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1732138455; x=1732743255; 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=Iu7aDJGbDBdHDN9nX/nWmhMIbwEvqk3RBRXOi7f/0Bs=; b=eWdCakaS1yWEa5IIT34PgY74OenRfeKe7SngSBN+gJZGVnplvScAZ/YtU2GcygfrP7 75AitbXoNAEZ7mgrzy9+XuQDoocSLYs6s8wWEmIWAIrLGfcw62x9ylZTvZJ4Vgx/5ATz TSH7a6DG9SgNnIIL0za2EbIZmt0wVNdis6zTGz1fqPzYETcDjAGyRKLrl0RwnTrl1YOl dNBoDqZFemnek89qCiEsDRje/kWKcK5ERg+7xDLkq1++7IA96AnBlitDJk+Lgaz2/Tw+ TL+VudG+xWeI64sOouOyv5ff7cFxBHyLg1tBX/tg28qAodkgzI7djI2+z4PnDRT+MU7y 7GZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732138455; x=1732743255; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Iu7aDJGbDBdHDN9nX/nWmhMIbwEvqk3RBRXOi7f/0Bs=; b=u65eZjPOUFJdpsJj/9ZOqNUrP6EJSMelDyQcNT+DKQXh+hsX+MOlxV8/1ICDpdA0OD 1IIFY5eRbYZtS403f95TrWJLWZgk7+sZjfgy/A9jMzDUEONFkKMEomhD+ZKkwWKHi3gE kNh6VtOjSU1LZ1dlUff/fz7ciZrdRqF2YLHaMZSuq29sMqN1wJhj9EYDfVz61oJpZuKK HBQvt/MlS5w+ZAfSnNM/hTIBtOGh8oSsfKec+hPj643odwBLpV05ZZy/6p4XSccfn76Y qFqRbJgU0/ZJ4ML9XT9yU2EupV+xDJfQsoiK8T9GTdRLg8qjUD3xKMzaVVfk4FpAECUC jsFw== X-Forwarded-Encrypted: i=1; AJvYcCXP4EnkdnxDyVr8BKDbtqGT129rihQoZrkZcFT/IbcC2Qp7ut9leYlfqkRdYhv/AdPad6wmMS8a7lGJ+Ps=@vger.kernel.org X-Gm-Message-State: AOJu0Yz97JY5thFFcitjjLyiehlYOH+NOfkoZE1H1T2Y6xhloMtSgefG u+KSeOjyznjus8gZxUdl5wnpi4zI+RGLxmgfAdjGzQM6z9K39ziBZnfEps7ltdA= X-Google-Smtp-Source: AGHT+IHXx6o3MNspetZNr4gTo1mEHeioI28P55Eo6Nd/3JODlVCwxdabASABo8ThWmfyi+yvZviiTw== X-Received: by 2002:a05:6871:4b12:b0:295:d711:f12d with SMTP id 586e51a60fabf-296d9ae33ecmr3788154fac.15.1732138455002; Wed, 20 Nov 2024 13:34:15 -0800 (PST) Received: from [127.0.1.1] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-29651852c27sm4487365fac.2.2024.11.20.13.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:34:14 -0800 (PST) From: David Lechner Date: Wed, 20 Nov 2024 15:33:33 -0600 Subject: [PATCH 10/11] iio: dac: ltc2688: use 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: <20241120-iio-regulator-cleanup-round-6-v1-10-d5a5360f7ec3@baylibre.com> References: <20241120-iio-regulator-cleanup-round-6-v1-0-d5a5360f7ec3@baylibre.com> In-Reply-To: <20241120-iio-regulator-cleanup-round-6-v1-0-d5a5360f7ec3@baylibre.com> To: Jonathan Cameron Cc: Michael Hennerich , Liam Girdwood , Mark Brown , Antoniu Miclaus , =?utf-8?q?Nuno_S=C3=A1?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, David Lechner X-Mailer: b4 0.14.1 Simplify the code by using devm_regulator_get_enable_read_voltage(). Signed-off-by: David Lechner --- drivers/iio/dac/ltc2688.c | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/drivers/iio/dac/ltc2688.c b/drivers/iio/dac/ltc2688.c index 376dca163c91..bdc857c7fa6d 100644 --- a/drivers/iio/dac/ltc2688.c +++ b/drivers/iio/dac/ltc2688.c @@ -842,7 +842,7 @@ static int ltc2688_channel_config(struct ltc2688_state = *st) return 0; } =20 -static int ltc2688_setup(struct ltc2688_state *st, struct regulator *vref) +static int ltc2688_setup(struct ltc2688_state *st, bool has_external_vref) { struct device *dev =3D &st->spi->dev; struct gpio_desc *gpio; @@ -881,18 +881,13 @@ static int ltc2688_setup(struct ltc2688_state *st, st= ruct regulator *vref) if (ret) return ret; =20 - if (!vref) + if (!has_external_vref) return 0; =20 return regmap_set_bits(st->regmap, LTC2688_CMD_CONFIG, LTC2688_CONFIG_EXT_REF); } =20 -static void ltc2688_disable_regulator(void *regulator) -{ - regulator_disable(regulator); -} - static bool ltc2688_reg_readable(struct device *dev, unsigned int reg) { switch (reg) { @@ -947,8 +942,8 @@ static int ltc2688_probe(struct spi_device *spi) static const char * const regulators[] =3D { "vcc", "iovcc" }; struct ltc2688_state *st; struct iio_dev *indio_dev; - struct regulator *vref_reg; struct device *dev =3D &spi->dev; + bool has_external_vref; int ret; =20 indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); @@ -973,34 +968,15 @@ static int ltc2688_probe(struct spi_device *spi) if (ret) return dev_err_probe(dev, ret, "Failed to enable regulators\n"); =20 - vref_reg =3D devm_regulator_get_optional(dev, "vref"); - if (IS_ERR(vref_reg)) { - if (PTR_ERR(vref_reg) !=3D -ENODEV) - return dev_err_probe(dev, PTR_ERR(vref_reg), - "Failed to get vref regulator"); - - vref_reg =3D NULL; - /* internal reference */ - st->vref =3D 4096; - } else { - ret =3D regulator_enable(vref_reg); - if (ret) - return dev_err_probe(dev, ret, - "Failed to enable vref regulators\n"); - - ret =3D devm_add_action_or_reset(dev, ltc2688_disable_regulator, - vref_reg); - if (ret) - return ret; - - ret =3D regulator_get_voltage(vref_reg); - if (ret < 0) - return dev_err_probe(dev, ret, "Failed to get vref\n"); + ret =3D devm_regulator_get_enable_read_voltage(dev, "vref"); + if (ret < 0 && ret !=3D -ENODEV) + return dev_err_probe(dev, ret, + "Failed to get vref regulator voltage\n"); =20 - st->vref =3D ret / 1000; - } + has_external_vref =3D ret !=3D -ENODEV; + st->vref =3D has_external_vref ? ret / 1000 : 0; =20 - ret =3D ltc2688_setup(st, vref_reg); + ret =3D ltc2688_setup(st, has_external_vref); if (ret) return ret; =20 --=20 2.43.0