Commit 0f360d48 authored by Dumitru Ceclan's avatar Dumitru Ceclan Committed by Jonathan Cameron

iio: adc: ad7173: refactor device info structs

Drop setting .has_temp and .has_input_buf to false in device info struct.
Drop array of device info structs and use individual structs for all;
drop models enum as no longer needed. This improves readability as the
structs are pointed directly.
Reviewed-by: default avatarNuno Sa <nuno.sa@analog.com>
Signed-off-by: default avatarDumitru Ceclan <dumitru.ceclan@analog.com>
Reviewed-by: default avatarDavid Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240607-ad4111-v7-7-97e3855900a0@analog.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent ff05b4a8
......@@ -132,16 +132,6 @@
#define AD7173_FILTER_ODR0_MASK GENMASK(5, 0)
#define AD7173_MAX_CONFIGS 8
enum ad7173_ids {
ID_AD7172_2,
ID_AD7172_4,
ID_AD7173_8,
ID_AD7175_2,
ID_AD7175_8,
ID_AD7176_2,
ID_AD7177_2,
};
struct ad7173_device_info {
const unsigned int *sinc5_data_rates;
unsigned int num_sinc5_data_rates;
......@@ -214,8 +204,7 @@ static const unsigned int ad7175_sinc5_data_rates[] = {
5000, /* 20 */
};
static const struct ad7173_device_info ad7173_device_info[] = {
[ID_AD7172_2] = {
static const struct ad7173_device_info ad7172_2_device_info = {
.name = "ad7172-2",
.id = AD7172_2_ID,
.num_inputs = 5,
......@@ -229,23 +218,24 @@ static const struct ad7173_device_info ad7173_device_info[] = {
.clock = 2 * HZ_PER_MHZ,
.sinc5_data_rates = ad7173_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
},
[ID_AD7172_4] = {
};
static const struct ad7173_device_info ad7172_4_device_info = {
.name = "ad7172-4",
.id = AD7172_4_ID,
.num_inputs = 9,
.num_channels = 8,
.num_configs = 8,
.num_gpios = 4,
.has_temp = false,
.has_input_buf = true,
.has_ref2 = true,
.has_pow_supply_monitoring = true,
.clock = 2 * HZ_PER_MHZ,
.sinc5_data_rates = ad7173_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
},
[ID_AD7173_8] = {
};
static const struct ad7173_device_info ad7173_8_device_info = {
.name = "ad7173-8",
.id = AD7173_ID,
.num_inputs = 17,
......@@ -259,8 +249,9 @@ static const struct ad7173_device_info ad7173_device_info[] = {
.clock = 2 * HZ_PER_MHZ,
.sinc5_data_rates = ad7173_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
},
[ID_AD7175_2] = {
};
static const struct ad7173_device_info ad7175_2_device_info = {
.name = "ad7175-2",
.id = AD7175_2_ID,
.num_inputs = 5,
......@@ -274,8 +265,9 @@ static const struct ad7173_device_info ad7173_device_info[] = {
.clock = 16 * HZ_PER_MHZ,
.sinc5_data_rates = ad7175_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
},
[ID_AD7175_8] = {
};
static const struct ad7173_device_info ad7175_8_device_info = {
.name = "ad7175-8",
.id = AD7175_8_ID,
.num_inputs = 17,
......@@ -290,22 +282,22 @@ static const struct ad7173_device_info ad7173_device_info[] = {
.clock = 16 * HZ_PER_MHZ,
.sinc5_data_rates = ad7175_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
},
[ID_AD7176_2] = {
};
static const struct ad7173_device_info ad7176_2_device_info = {
.name = "ad7176-2",
.id = AD7176_ID,
.num_inputs = 5,
.num_channels = 4,
.num_configs = 4,
.num_gpios = 2,
.has_temp = false,
.has_input_buf = false,
.has_int_ref = true,
.clock = 16 * HZ_PER_MHZ,
.sinc5_data_rates = ad7175_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
},
[ID_AD7177_2] = {
};
static const struct ad7173_device_info ad7177_2_device_info = {
.name = "ad7177-2",
.id = AD7177_ID,
.num_inputs = 5,
......@@ -320,7 +312,6 @@ static const struct ad7173_device_info ad7173_device_info[] = {
.odr_start_value = AD7177_ODR_START_VALUE,
.sinc5_data_rates = ad7175_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
},
};
static const char *const ad7173_ref_sel_str[] = {
......@@ -1187,32 +1178,25 @@ static int ad7173_probe(struct spi_device *spi)
}
static const struct of_device_id ad7173_of_match[] = {
{ .compatible = "adi,ad7172-2",
.data = &ad7173_device_info[ID_AD7172_2]},
{ .compatible = "adi,ad7172-4",
.data = &ad7173_device_info[ID_AD7172_4]},
{ .compatible = "adi,ad7173-8",
.data = &ad7173_device_info[ID_AD7173_8]},
{ .compatible = "adi,ad7175-2",
.data = &ad7173_device_info[ID_AD7175_2]},
{ .compatible = "adi,ad7175-8",
.data = &ad7173_device_info[ID_AD7175_8]},
{ .compatible = "adi,ad7176-2",
.data = &ad7173_device_info[ID_AD7176_2]},
{ .compatible = "adi,ad7177-2",
.data = &ad7173_device_info[ID_AD7177_2]},
{ .compatible = "adi,ad7172-2", .data = &ad7172_2_device_info },
{ .compatible = "adi,ad7172-4", .data = &ad7172_4_device_info },
{ .compatible = "adi,ad7173-8", .data = &ad7173_8_device_info },
{ .compatible = "adi,ad7175-2", .data = &ad7175_2_device_info },
{ .compatible = "adi,ad7175-8", .data = &ad7175_8_device_info },
{ .compatible = "adi,ad7176-2", .data = &ad7176_2_device_info },
{ .compatible = "adi,ad7177-2", .data = &ad7177_2_device_info },
{ }
};
MODULE_DEVICE_TABLE(of, ad7173_of_match);
static const struct spi_device_id ad7173_id_table[] = {
{ "ad7172-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7172_2]},
{ "ad7172-4", (kernel_ulong_t)&ad7173_device_info[ID_AD7172_4]},
{ "ad7173-8", (kernel_ulong_t)&ad7173_device_info[ID_AD7173_8]},
{ "ad7175-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7175_2]},
{ "ad7175-8", (kernel_ulong_t)&ad7173_device_info[ID_AD7175_8]},
{ "ad7176-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7176_2]},
{ "ad7177-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7177_2]},
{ "ad7172-2", (kernel_ulong_t)&ad7172_2_device_info },
{ "ad7172-4", (kernel_ulong_t)&ad7172_4_device_info },
{ "ad7173-8", (kernel_ulong_t)&ad7173_8_device_info },
{ "ad7175-2", (kernel_ulong_t)&ad7175_2_device_info },
{ "ad7175-8", (kernel_ulong_t)&ad7175_8_device_info },
{ "ad7176-2", (kernel_ulong_t)&ad7176_2_device_info },
{ "ad7177-2", (kernel_ulong_t)&ad7177_2_device_info },
{ }
};
MODULE_DEVICE_TABLE(spi, ad7173_id_table);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment