Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: dac: mcp4922: add support to mcp4921

Add support to mcp4921 which has only one output channel.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20220624095619.1415614-1-kory.maincent@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Kory Maincent and committed by
Jonathan Cameron
1c8dbb5b 53bee458

+9 -2
+9 -2
drivers/iio/dac/mcp4922.c
··· 17 17 #include <linux/bitops.h> 18 18 19 19 #define MCP4922_NUM_CHANNELS 2 20 + #define MCP4921_NUM_CHANNELS 1 20 21 21 22 enum mcp4922_supported_device_ids { 22 23 ID_MCP4902, 23 24 ID_MCP4912, 25 + ID_MCP4921, 24 26 ID_MCP4922, 25 27 }; 26 28 ··· 107 105 } 108 106 } 109 107 110 - static const struct iio_chan_spec mcp4922_channels[3][MCP4922_NUM_CHANNELS] = { 108 + static const struct iio_chan_spec mcp4922_channels[4][MCP4922_NUM_CHANNELS] = { 111 109 [ID_MCP4902] = { MCP4922_CHAN(0, 8), MCP4922_CHAN(1, 8) }, 112 110 [ID_MCP4912] = { MCP4922_CHAN(0, 10), MCP4922_CHAN(1, 10) }, 111 + [ID_MCP4921] = { MCP4922_CHAN(0, 12), {} }, 113 112 [ID_MCP4922] = { MCP4922_CHAN(0, 12), MCP4922_CHAN(1, 12) }, 114 113 }; 115 114 ··· 157 154 indio_dev->info = &mcp4922_info; 158 155 indio_dev->modes = INDIO_DIRECT_MODE; 159 156 indio_dev->channels = mcp4922_channels[id->driver_data]; 160 - indio_dev->num_channels = MCP4922_NUM_CHANNELS; 157 + if (id->driver_data == ID_MCP4921) 158 + indio_dev->num_channels = MCP4921_NUM_CHANNELS; 159 + else 160 + indio_dev->num_channels = MCP4922_NUM_CHANNELS; 161 161 indio_dev->name = id->name; 162 162 163 163 ret = iio_device_register(indio_dev); ··· 191 185 static const struct spi_device_id mcp4922_id[] = { 192 186 {"mcp4902", ID_MCP4902}, 193 187 {"mcp4912", ID_MCP4912}, 188 + {"mcp4921", ID_MCP4921}, 194 189 {"mcp4922", ID_MCP4922}, 195 190 {} 196 191 };