Re: [PATCH 2/2] iio: dac: mcp47a1: add support for new device

From: Joshua Crofts

Date: Wed Jul 22 2026 - 02:36:14 EST


On Tue, 21 Jul 2026 23:47:58 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Tue, Jul 21, 2026 at 08:24:39PM +0200, Joshua Crofts wrote:
> > The Microchip MCP47A1 is a 6-bit volatile Digital-to-Analog converted
> > which communicates via I2C.
>
> ...
>
> > +#include <linux/array_size.h>
> > +#include <linux/err.h>
> > +#include <linux/i2c.h>
> > +#include <linux/module.h>
> > +#include <linux/regmap.h>
> > +#include <linux/regulator/consumer.h>
> > +#include <linux/types.h>
> > +#include <linux/units.h>
>
>
> > +struct mcp47a1_data {
> > + struct regmap *regmap;
> > + int vref_mv;
>
> _mV

ACK.

>
> ...
>
> > +static const struct regmap_config mcp47a1_regmap_config = {
> > + .name = "mcp47a1",
> > + .reg_bits = 8,
> > + .val_bits = 8,
> > + .max_register = MCP47A1_CMD_CODE,
> > +};
>
> No cache?

Hmmm, could you elaborate a bit more? I assume you're talking about
regcache but I'm not sure on how to use it here.

>
> ...
>
> > +static int mcp47a1_probe(struct i2c_client *client)
> > +{
> > + struct device *dev = &client->dev;
> > + struct mcp47a1_data *data;
> > + struct iio_dev *indio_dev;
> > + int reg_val;
> > + int ret;
> > +
> > + indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> > + if (!indio_dev)
> > + return -ENOMEM;
> > +
> > + data = iio_priv(indio_dev);
>
> > + i2c_set_clientdata(client, indio_dev);
>
> Is it used?

Nope, it isn't, good catch.

>
> > + data->regmap = devm_regmap_init_i2c(client, &mcp47a1_regmap_config);
> > + if (IS_ERR(data->regmap))
> > + return dev_err_probe(dev, PTR_ERR(data->regmap),
> > + "Failed to initialize regmap\n");
> > +
> > + ret = devm_regulator_get_enable(dev, "vdd");
> > + if (ret)
> > + return dev_err_probe(dev, ret, "Failed to enable regulator\n");
> > +
> > + ret = devm_regulator_get_enable_read_voltage(dev, "vref");
> > + if (ret < 0)
> > + return dev_err_probe(dev, ret, "Failed to read vref\n");
> > +
> > + data->vref_mv = ret / MILLI;
>
> (MICRO / MILLI)

ACK.

--
Kind regards,
Joshua Crofts