From nobody Tue Nov 26 00:40:41 2024 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 0C81D200C8C for ; Wed, 23 Oct 2024 23:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729727693; cv=none; b=Q/dte3FAUUrZsFKlEVHFeF/caytG4chvTPaF14M2W4gH6pqYFgnFAU52yjK1BA2ZAHRNaeChAq+Ole2Esg6AjychyoYbi6AlHvgkLrOGgrRQrRaShJbSbfrVTAaSlFpycvVvseM4JKie5wh3FoUbB0P+VnBuxY0nhGqeptjiQPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729727693; c=relaxed/simple; bh=nUH5txR4P/Bv9EVLN478VLSNk/BVSj4cf6PubYC2e5w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E60riSF5hsJVnJQHSdbcWxilnzJG1gscJXI3QQmEZ7L7EcdgmJ3Eta6xGyWDbJi6sLTHSqfuSrVadYd3rzX7Pffc5YnRdp4D8SyU7WfbVTEVMeHoR/TK4zr7Hd2+b3yIuKsWEAslO7MiQKC22s4QgojiISSpwiyyBoozUOvTBe8= 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=Iw4fq07Y; arc=none smtp.client-ip=209.85.161.46 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="Iw4fq07Y" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-5e98bfea0ceso159689eaf.0 for ; Wed, 23 Oct 2024 16:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729727690; x=1730332490; 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=hYgkvqv4R1HU1dFN4HvN+5+Sd8/gJpr63Hs53U7tMP4=; b=Iw4fq07Yn/4+23EI13rcBmkximnUVWcPNnb0goK6aBcK1nd+Ja3gRArRp3vsnpLkyu EwnMp1XIUGcF6C6eAoVPFxsPnPNkH+CbHPHNvlQufgomsCSNFRG9LuDVA8wCbHTU4bV6 CHGX9d692RLVFadGvThGFFe7uKynMheHuSwfwwP8KbMG5a6rPDxfh35ZtlD0Zf/oVbhH oqm4xH0ZLvNKyLw++GD2ssFt1AHcdZ8suU0nO+QkrHCJGvV6JPHFELLSTj0TlA+nORjn EouAW7MXJmiI+3C7xvqRyb/RnM0CZWf9fSqiKpsfii9EjKXPws60lYKpE/NuRVFgjdQI EbQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729727690; x=1730332490; 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=hYgkvqv4R1HU1dFN4HvN+5+Sd8/gJpr63Hs53U7tMP4=; b=syghiUyMVbihKh4TjPYJV4J6VLvNCrBxqCjB8rub29W2PsSOrLoh5Wv735kbwP3g4s 8mCH0RegLdbkUA/g5Rq8LReAn4GUJXdu0V4lod5jYltn30EhtTz1CJoV7bxPByV6/vjs /nuOz3EEzqLLjt2AK2gJYO99+s5WvN2jeOMjWRitrSiv4Ili+0LRVIn27q2XVldBxRfL rBGtzSv2sVCtNkColPyrmOumVc1LTHYVObgCdZz5CZS9evn5usDKYamt+gAEVUuTzYWf i262ElLRBtC1jQZKbG96Oeq6lcu/I47DkA3hsLIlhNw3s8jp/hLofXCMi+JZTQUC45xt Plgg== X-Forwarded-Encrypted: i=1; AJvYcCV6FQgTgfB0Yaapj4ce0Cwu8eT/8SOYElZnNp2ljTOA7Vk2kiSDcrJJLVLo4cpM8yjfI5rlEe7gnzGha6Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1LglVlkyH6rpNcYFU1HHmW4/+COZHag1s0NNMIJHtMkleKX41 kXzW8JqqZR407bO4QyJMC4mhuEsUX86WTs4TmcN+9fZdt5VBseTY4AxYO8bdseI= X-Google-Smtp-Source: AGHT+IHcCxKyS2mmLHC5MPxm7YFL188H9iZp31keASBRo+Q1y9yvvaWEd8aS9jAZNjM885evSN5LsA== X-Received: by 2002:a05:6820:1c9a:b0:5e5:7086:ebe8 with SMTP id 006d021491bc7-5ebee308838mr3087385eaf.0.1729727690124; Wed, 23 Oct 2024 16:54:50 -0700 (PDT) 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 006d021491bc7-5ec02c2b25bsm132002eaf.39.2024.10.23.16.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 16:54:49 -0700 (PDT) From: David Lechner Date: Wed, 23 Oct 2024 18:54:09 -0500 Subject: [PATCH 05/11] iio: dac: ad5504: 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: <20241023-iio-regulator-refactor-round-5-v1-5-d0bd396b3f50@baylibre.com> References: <20241023-iio-regulator-refactor-round-5-v1-0-d0bd396b3f50@baylibre.com> In-Reply-To: <20241023-iio-regulator-refactor-round-5-v1-0-d0bd396b3f50@baylibre.com> To: Jonathan Cameron Cc: Michael Hennerich , Liam Girdwood , Mark Brown , 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/ad5504.c | 52 ++++++++++++++------------------------------= ---- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c index 305cd58cd257..f1717955ddcf 100644 --- a/drivers/iio/dac/ad5504.c +++ b/drivers/iio/dac/ad5504.c @@ -273,35 +273,27 @@ static int ad5504_probe(struct spi_device *spi) const struct ad5504_platform_data *pdata =3D dev_get_platdata(&spi->dev); struct iio_dev *indio_dev; struct ad5504_state *st; - struct regulator *reg; - int ret, voltage_uv =3D 0; + int ret; =20 indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; - reg =3D devm_regulator_get(&spi->dev, "vcc"); - if (!IS_ERR(reg)) { - ret =3D regulator_enable(reg); - if (ret) - return ret; - - ret =3D regulator_get_voltage(reg); - if (ret < 0) - goto error_disable_reg; - - voltage_uv =3D ret; - } =20 spi_set_drvdata(spi, indio_dev); st =3D iio_priv(indio_dev); - if (voltage_uv) - st->vref_mv =3D voltage_uv / 1000; - else if (pdata) - st->vref_mv =3D pdata->vref_mv; - else - dev_warn(&spi->dev, "reference voltage unspecified\n"); =20 - st->reg =3D reg; + ret =3D devm_regulator_get_enable_read_voltage(&spi->dev, "vcc"); + if (ret < 0 && ret !=3D -ENODEV) + return ret; + if (ret =3D=3D -ENODEV) { + if (pdata->vref_mv) + st->vref_mv =3D pdata->vref_mv; + else + dev_warn(&spi->dev, "reference voltage unspecified\n"); + } else { + st->vref_mv =3D ret / 1000; + } + st->spi =3D spi; indio_dev->name =3D spi_get_device_id(st->spi)->name; indio_dev->info =3D &ad5504_info; @@ -320,31 +312,17 @@ static int ad5504_probe(struct spi_device *spi) spi_get_device_id(st->spi)->name, indio_dev); if (ret) - goto error_disable_reg; + return ret; } =20 - ret =3D iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - - return 0; - -error_disable_reg: - if (!IS_ERR(reg)) - regulator_disable(reg); - - return ret; + return iio_device_register(indio_dev); } =20 static void ad5504_remove(struct spi_device *spi) { struct iio_dev *indio_dev =3D spi_get_drvdata(spi); - struct ad5504_state *st =3D iio_priv(indio_dev); =20 iio_device_unregister(indio_dev); - - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); } =20 static const struct spi_device_id ad5504_id[] =3D { --=20 2.43.0