iio: dac: ltc2632: drop enum and use individual chip_info objects

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.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: David Marinovic <david.marinovic@pupin.rs>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
David Marinovic 2026-03-20 16:09:46 +01:00 committed by Jonathan Cameron
parent 8a75ac8f0a
commit 19045d89e4

View File

@ -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);