[PATCH 1/3] iio: dac: ltc2632: drop enum and use individual chip_info objects

From: David Marinović

Date: Wed Mar 18 2026 - 10:18:35 EST


From: David Marinovic <david.marinovic@xxxxxxxx>

Remove the ltc2632_chip_info_tbl[] array and related
ltc2632_supported_device_ids enum used for looking up chip-specific
information. Instead, use separate static const struct
ltc2632_chip_info objects for each supported chip variant.

Signed-off-by: David Marinovic <david.marinovic@xxxxxxxx>
---
drivers/iio/dac/ltc2632.c | 327 +++++++++++++++++---------------------
1 file changed, 142 insertions(+), 185 deletions(-)

diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c
index 105f939f7e54..ca0b88285ce5 100644
--- a/drivers/iio/dac/ltc2632.c
+++ b/drivers/iio/dac/ltc2632.c
@@ -48,27 +48,6 @@ struct ltc2632_state {
int vref_mv;
};

-enum ltc2632_supported_device_ids {
- ID_LTC2632L12,
- ID_LTC2632L10,
- ID_LTC2632L8,
- ID_LTC2632H12,
- ID_LTC2632H10,
- ID_LTC2632H8,
- ID_LTC2634L12,
- ID_LTC2634L10,
- ID_LTC2634L8,
- ID_LTC2634H12,
- ID_LTC2634H10,
- ID_LTC2634H8,
- ID_LTC2636L12,
- ID_LTC2636L10,
- ID_LTC2636L8,
- ID_LTC2636H12,
- ID_LTC2636H10,
- ID_LTC2636H8,
-};
-
static int ltc2632_spi_write(struct spi_device *spi,
u8 cmd, u8 addr, u16 val, u8 shift)
{
@@ -210,97 +189,112 @@ static DECLARE_LTC2632_CHANNELS(ltc2632x12, 12);
static DECLARE_LTC2632_CHANNELS(ltc2632x10, 10);
static DECLARE_LTC2632_CHANNELS(ltc2632x8, 8);

-static const struct ltc2632_chip_info ltc2632_chip_info_tbl[] = {
- [ID_LTC2632L12] = {
- .channels = ltc2632x12_channels,
- .num_channels = 2,
- .vref_mv = 2500,
- },
- [ID_LTC2632L10] = {
- .channels = ltc2632x10_channels,
- .num_channels = 2,
- .vref_mv = 2500,
- },
- [ID_LTC2632L8] = {
- .channels = ltc2632x8_channels,
- .num_channels = 2,
- .vref_mv = 2500,
- },
- [ID_LTC2632H12] = {
- .channels = ltc2632x12_channels,
- .num_channels = 2,
- .vref_mv = 4096,
- },
- [ID_LTC2632H10] = {
- .channels = ltc2632x10_channels,
- .num_channels = 2,
- .vref_mv = 4096,
- },
- [ID_LTC2632H8] = {
- .channels = ltc2632x8_channels,
- .num_channels = 2,
- .vref_mv = 4096,
- },
- [ID_LTC2634L12] = {
- .channels = ltc2632x12_channels,
- .num_channels = 4,
- .vref_mv = 2500,
- },
- [ID_LTC2634L10] = {
- .channels = ltc2632x10_channels,
- .num_channels = 4,
- .vref_mv = 2500,
- },
- [ID_LTC2634L8] = {
- .channels = ltc2632x8_channels,
- .num_channels = 4,
- .vref_mv = 2500,
- },
- [ID_LTC2634H12] = {
- .channels = ltc2632x12_channels,
- .num_channels = 4,
- .vref_mv = 4096,
- },
- [ID_LTC2634H10] = {
- .channels = ltc2632x10_channels,
- .num_channels = 4,
- .vref_mv = 4096,
- },
- [ID_LTC2634H8] = {
- .channels = ltc2632x8_channels,
- .num_channels = 4,
- .vref_mv = 4096,
- },
- [ID_LTC2636L12] = {
- .channels = ltc2632x12_channels,
- .num_channels = 8,
- .vref_mv = 2500,
- },
- [ID_LTC2636L10] = {
- .channels = ltc2632x10_channels,
- .num_channels = 8,
- .vref_mv = 2500,
- },
- [ID_LTC2636L8] = {
- .channels = ltc2632x8_channels,
- .num_channels = 8,
- .vref_mv = 2500,
- },
- [ID_LTC2636H12] = {
- .channels = ltc2632x12_channels,
- .num_channels = 8,
- .vref_mv = 4096,
- },
- [ID_LTC2636H10] = {
- .channels = ltc2632x10_channels,
- .num_channels = 8,
- .vref_mv = 4096,
- },
- [ID_LTC2636H8] = {
- .channels = ltc2632x8_channels,
- .num_channels = 8,
- .vref_mv = 4096,
- },
+static const struct ltc2632_chip_info ltc2632l12_chip_info = {
+ .channels = ltc2632x12_channels,
+ .num_channels = 2,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2632l10_chip_info = {
+ .channels = ltc2632x10_channels,
+ .num_channels = 2,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2632l8_chip_info = {
+ .channels = ltc2632x8_channels,
+ .num_channels = 2,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2632h12_chip_info = {
+ .channels = ltc2632x12_channels,
+ .num_channels = 2,
+ .vref_mv = 4096,
+};
+
+static const struct ltc2632_chip_info ltc2632h10_chip_info = {
+ .channels = ltc2632x10_channels,
+ .num_channels = 2,
+ .vref_mv = 4096,
+};
+
+static const struct ltc2632_chip_info ltc2632h8_chip_info = {
+ .channels = ltc2632x8_channels,
+ .num_channels = 2,
+ .vref_mv = 4096,
+};
+
+static const struct ltc2632_chip_info ltc2634l12_chip_info = {
+ .channels = ltc2632x12_channels,
+ .num_channels = 4,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2634l10_chip_info = {
+ .channels = ltc2632x10_channels,
+ .num_channels = 4,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2634l8_chip_info = {
+ .channels = ltc2632x8_channels,
+ .num_channels = 4,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2634h12_chip_info = {
+ .channels = ltc2632x12_channels,
+ .num_channels = 4,
+ .vref_mv = 4096,
+};
+
+static const struct ltc2632_chip_info ltc2634h10_chip_info = {
+ .channels = ltc2632x10_channels,
+ .num_channels = 4,
+ .vref_mv = 4096,
+};
+
+static const struct ltc2632_chip_info ltc2634h8_chip_info = {
+ .channels = ltc2632x8_channels,
+ .num_channels = 4,
+ .vref_mv = 4096,
+};
+
+static const struct ltc2632_chip_info ltc2636l12_chip_info = {
+ .channels = ltc2632x12_channels,
+ .num_channels = 8,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2636l10_chip_info = {
+ .channels = ltc2632x10_channels,
+ .num_channels = 8,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2636l8_chip_info = {
+ .channels = ltc2632x8_channels,
+ .num_channels = 8,
+ .vref_mv = 2500,
+};
+
+static const struct ltc2632_chip_info ltc2636h12_chip_info = {
+ .channels = ltc2632x12_channels,
+ .num_channels = 8,
+ .vref_mv = 4096,
+};
+
+static const struct ltc2632_chip_info ltc2636h10_chip_info = {
+ .channels = ltc2632x10_channels,
+ .num_channels = 8,
+ .vref_mv = 4096,
+};
+
+static const struct ltc2632_chip_info ltc2636h8_chip_info = {
+ .channels = ltc2632x8_channels,
+ .num_channels = 8,
+ .vref_mv = 4096,
};

static int ltc2632_probe(struct spi_device *spi)
@@ -354,84 +348,47 @@ static int ltc2632_probe(struct spi_device *spi)
}

static const struct spi_device_id ltc2632_id[] = {
- { "ltc2632-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L12] },
- { "ltc2632-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L10] },
- { "ltc2632-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L8] },
- { "ltc2632-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H12] },
- { "ltc2632-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H10] },
- { "ltc2632-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H8] },
- { "ltc2634-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L12] },
- { "ltc2634-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L10] },
- { "ltc2634-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L8] },
- { "ltc2634-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H12] },
- { "ltc2634-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H10] },
- { "ltc2634-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H8] },
- { "ltc2636-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L12] },
- { "ltc2636-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L10] },
- { "ltc2636-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L8] },
- { "ltc2636-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H12] },
- { "ltc2636-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H10] },
- { "ltc2636-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H8] },
+ { "ltc2632-l12", (kernel_ulong_t)&ltc2632l12_chip_info },
+ { "ltc2632-l10", (kernel_ulong_t)&ltc2632l10_chip_info },
+ { "ltc2632-l8", (kernel_ulong_t)&ltc2632l8_chip_info },
+ { "ltc2632-h12", (kernel_ulong_t)&ltc2632h12_chip_info },
+ { "ltc2632-h10", (kernel_ulong_t)&ltc2632h10_chip_info },
+ { "ltc2632-h8", (kernel_ulong_t)&ltc2632h8_chip_info },
+ { "ltc2634-l12", (kernel_ulong_t)&ltc2634l12_chip_info },
+ { "ltc2634-l10", (kernel_ulong_t)&ltc2634l10_chip_info },
+ { "ltc2634-l8", (kernel_ulong_t)&ltc2634l8_chip_info },
+ { "ltc2634-h12", (kernel_ulong_t)&ltc2634h12_chip_info },
+ { "ltc2634-h10", (kernel_ulong_t)&ltc2634h10_chip_info },
+ { "ltc2634-h8", (kernel_ulong_t)&ltc2634h8_chip_info },
+ { "ltc2636-l12", (kernel_ulong_t)&ltc2636l12_chip_info },
+ { "ltc2636-l10", (kernel_ulong_t)&ltc2636l10_chip_info },
+ { "ltc2636-l8", (kernel_ulong_t)&ltc2636l8_chip_info },
+ { "ltc2636-h12", (kernel_ulong_t)&ltc2636h12_chip_info },
+ { "ltc2636-h10", (kernel_ulong_t)&ltc2636h10_chip_info },
+ { "ltc2636-h8", (kernel_ulong_t)&ltc2636h8_chip_info },
{ }
};
MODULE_DEVICE_TABLE(spi, ltc2632_id);

static const struct of_device_id ltc2632_of_match[] = {
- {
- .compatible = "lltc,ltc2632-l12",
- .data = &ltc2632_chip_info_tbl[ID_LTC2632L12]
- }, {
- .compatible = "lltc,ltc2632-l10",
- .data = &ltc2632_chip_info_tbl[ID_LTC2632L10]
- }, {
- .compatible = "lltc,ltc2632-l8",
- .data = &ltc2632_chip_info_tbl[ID_LTC2632L8]
- }, {
- .compatible = "lltc,ltc2632-h12",
- .data = &ltc2632_chip_info_tbl[ID_LTC2632H12]
- }, {
- .compatible = "lltc,ltc2632-h10",
- .data = &ltc2632_chip_info_tbl[ID_LTC2632H10]
- }, {
- .compatible = "lltc,ltc2632-h8",
- .data = &ltc2632_chip_info_tbl[ID_LTC2632H8]
- }, {
- .compatible = "lltc,ltc2634-l12",
- .data = &ltc2632_chip_info_tbl[ID_LTC2634L12]
- }, {
- .compatible = "lltc,ltc2634-l10",
- .data = &ltc2632_chip_info_tbl[ID_LTC2634L10]
- }, {
- .compatible = "lltc,ltc2634-l8",
- .data = &ltc2632_chip_info_tbl[ID_LTC2634L8]
- }, {
- .compatible = "lltc,ltc2634-h12",
- .data = &ltc2632_chip_info_tbl[ID_LTC2634H12]
- }, {
- .compatible = "lltc,ltc2634-h10",
- .data = &ltc2632_chip_info_tbl[ID_LTC2634H10]
- }, {
- .compatible = "lltc,ltc2634-h8",
- .data = &ltc2632_chip_info_tbl[ID_LTC2634H8]
- }, {
- .compatible = "lltc,ltc2636-l12",
- .data = &ltc2632_chip_info_tbl[ID_LTC2636L12]
- }, {
- .compatible = "lltc,ltc2636-l10",
- .data = &ltc2632_chip_info_tbl[ID_LTC2636L10]
- }, {
- .compatible = "lltc,ltc2636-l8",
- .data = &ltc2632_chip_info_tbl[ID_LTC2636L8]
- }, {
- .compatible = "lltc,ltc2636-h12",
- .data = &ltc2632_chip_info_tbl[ID_LTC2636H12]
- }, {
- .compatible = "lltc,ltc2636-h10",
- .data = &ltc2632_chip_info_tbl[ID_LTC2636H10]
- }, {
- .compatible = "lltc,ltc2636-h8",
- .data = &ltc2632_chip_info_tbl[ID_LTC2636H8]
- },
+ { .compatible = "lltc,ltc2632-l12", .data = &ltc2632l12_chip_info },
+ { .compatible = "lltc,ltc2632-l10", .data = &ltc2632l10_chip_info },
+ { .compatible = "lltc,ltc2632-l8", .data = &ltc2632l8_chip_info },
+ { .compatible = "lltc,ltc2632-h12", .data = &ltc2632h12_chip_info },
+ { .compatible = "lltc,ltc2632-h10", .data = &ltc2632h10_chip_info },
+ { .compatible = "lltc,ltc2632-h8", .data = &ltc2632h8_chip_info },
+ { .compatible = "lltc,ltc2634-l12", .data = &ltc2634l12_chip_info },
+ { .compatible = "lltc,ltc2634-l10", .data = &ltc2634l10_chip_info },
+ { .compatible = "lltc,ltc2634-l8", .data = &ltc2634l8_chip_info },
+ { .compatible = "lltc,ltc2634-h12", .data = &ltc2634h12_chip_info },
+ { .compatible = "lltc,ltc2634-h10", .data = &ltc2634h10_chip_info },
+ { .compatible = "lltc,ltc2634-h8", .data = &ltc2634h8_chip_info },
+ { .compatible = "lltc,ltc2636-l12", .data = &ltc2636l12_chip_info },
+ { .compatible = "lltc,ltc2636-l10", .data = &ltc2636l10_chip_info },
+ { .compatible = "lltc,ltc2636-l8", .data = &ltc2636l8_chip_info },
+ { .compatible = "lltc,ltc2636-h12", .data = &ltc2636h12_chip_info },
+ { .compatible = "lltc,ltc2636-h10", .data = &ltc2636h10_chip_info },
+ { .compatible = "lltc,ltc2636-h8", .data = &ltc2636h8_chip_info },
{ }
};
MODULE_DEVICE_TABLE(of, ltc2632_of_match);
--
2.50.1