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

Jonathan Cameron <[email protected]> Sat, 1 Aug 2026 03:31:12 +0100
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <20260801033112.43169ed1@jic23-huawei>
> diff --git a/drivers/iio/dac/mcp47a1.c b/drivers/iio/dac/mcp47a1.c
> new file mode 100644
> index 000000000000..140e93ff2ba0
> --- /dev/null
> +++ b/drivers/iio/dac/mcp47a1.c
> @@ -0,0 +1,169 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Microchip MCP47A1 DAC driver
> + *
> + * Copyright (c) 2026 Joshua Crofts <[email protected]>
> + *
> + * Datasheet: https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/25154A.pdf
> + */
> +
> +#include <linux/array_size.h>
> +#include <linux/delay.h>
> +#include <linux/err.h>
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/types.h>
> +#include <linux/units.h>
> +
> +#include <linux/iio/iio.h>
> +
> +#define MCP47A1_REG_MAX		0x40
> +#define MCP47A1_CMD_CODE	0x00
> +#define MCP47A1_MAX_STEP	63
> +
> +struct mcp47a1_data {
> +	struct i2c_client *client;
> +	int vref_mV;
> +};
> +
> +static const int mcp47a1_raw_avail[] = { 0, 1, MCP47A1_MAX_STEP };
> +
> +static const struct iio_chan_spec mcp47a1_channels[] = {
> +	{
> +		.type = IIO_VOLTAGE,
> +		.indexed = 1,
> +		.output = 1,
> +		.channel = 0,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +		.info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW),
> +		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
> +	},

Given you are doing a v3 anyway, drop the array.  A single channel
is fine - just use &mc47a1_channel when referring to it and provide
channel count of 1 directly (obviously correct as it is clear you
aren't pointing to an array).

> +};