[PATCH v2 4/6] iio: potentiometer: mcp4018: Turn on the vdd supply

From: Joseph Telaak

Date: Wed Nov 25 2026 - 15:22:49 EST


Get and enable the vdd supply at probe, so a board that switches the
potentiometer's supply gets it powered before the wiper is used. On
boards that describe no supply, this gets the dummy regulator.

Signed-off-by: Joseph Telaak <joseph@xxxxxxxxxx>
---
drivers/iio/potentiometer/mcp4018.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
index d6387645853d..6ca6cd7cbf71 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -14,11 +14,13 @@

#include <linux/array_size.h>
#include <linux/bits.h>
+#include <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/module.h>
#include <linux/property.h>
+#include <linux/regulator/consumer.h>

#define MCP4018_WIPER_MAX 127

@@ -169,6 +171,7 @@ static int mcp4018_probe(struct i2c_client *client)
struct device *dev = &client->dev;
struct mcp4018_data *data;
struct iio_dev *indio_dev;
+ int ret;

if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_BYTE)) {
@@ -176,6 +179,10 @@ static int mcp4018_probe(struct i2c_client *client)
return -EOPNOTSUPP;
}

+ ret = devm_regulator_get_enable(dev, "vdd");
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to enable vdd supply\n");
+
indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;

--
Git-155)