Skip to content

Commit 0f360d4

Browse files
dumitruceclanjic23
authored andcommitted
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: Nuno Sa <nuno.sa@analog.com> Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20240607-ad4111-v7-7-97e3855900a0@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent ff05b4a commit 0f360d4

File tree

1 file changed

+122
-138
lines changed

1 file changed

+122
-138
lines changed

drivers/iio/adc/ad7173.c

Lines changed: 122 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,6 @@
132132
#define AD7173_FILTER_ODR0_MASK GENMASK(5, 0)
133133
#define AD7173_MAX_CONFIGS 8
134134

135-
enum ad7173_ids {
136-
ID_AD7172_2,
137-
ID_AD7172_4,
138-
ID_AD7173_8,
139-
ID_AD7175_2,
140-
ID_AD7175_8,
141-
ID_AD7176_2,
142-
ID_AD7177_2,
143-
};
144-
145135
struct ad7173_device_info {
146136
const unsigned int *sinc5_data_rates;
147137
unsigned int num_sinc5_data_rates;
@@ -214,113 +204,114 @@ static const unsigned int ad7175_sinc5_data_rates[] = {
214204
5000, /* 20 */
215205
};
216206

217-
static const struct ad7173_device_info ad7173_device_info[] = {
218-
[ID_AD7172_2] = {
219-
.name = "ad7172-2",
220-
.id = AD7172_2_ID,
221-
.num_inputs = 5,
222-
.num_channels = 4,
223-
.num_configs = 4,
224-
.num_gpios = 2,
225-
.has_temp = true,
226-
.has_input_buf = true,
227-
.has_int_ref = true,
228-
.has_pow_supply_monitoring = true,
229-
.clock = 2 * HZ_PER_MHZ,
230-
.sinc5_data_rates = ad7173_sinc5_data_rates,
231-
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
232-
},
233-
[ID_AD7172_4] = {
234-
.name = "ad7172-4",
235-
.id = AD7172_4_ID,
236-
.num_inputs = 9,
237-
.num_channels = 8,
238-
.num_configs = 8,
239-
.num_gpios = 4,
240-
.has_temp = false,
241-
.has_input_buf = true,
242-
.has_ref2 = true,
243-
.has_pow_supply_monitoring = true,
244-
.clock = 2 * HZ_PER_MHZ,
245-
.sinc5_data_rates = ad7173_sinc5_data_rates,
246-
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
247-
},
248-
[ID_AD7173_8] = {
249-
.name = "ad7173-8",
250-
.id = AD7173_ID,
251-
.num_inputs = 17,
252-
.num_channels = 16,
253-
.num_configs = 8,
254-
.num_gpios = 4,
255-
.has_temp = true,
256-
.has_input_buf = true,
257-
.has_int_ref = true,
258-
.has_ref2 = true,
259-
.clock = 2 * HZ_PER_MHZ,
260-
.sinc5_data_rates = ad7173_sinc5_data_rates,
261-
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
262-
},
263-
[ID_AD7175_2] = {
264-
.name = "ad7175-2",
265-
.id = AD7175_2_ID,
266-
.num_inputs = 5,
267-
.num_channels = 4,
268-
.num_configs = 4,
269-
.num_gpios = 2,
270-
.has_temp = true,
271-
.has_input_buf = true,
272-
.has_int_ref = true,
273-
.has_pow_supply_monitoring = true,
274-
.clock = 16 * HZ_PER_MHZ,
275-
.sinc5_data_rates = ad7175_sinc5_data_rates,
276-
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
277-
},
278-
[ID_AD7175_8] = {
279-
.name = "ad7175-8",
280-
.id = AD7175_8_ID,
281-
.num_inputs = 17,
282-
.num_channels = 16,
283-
.num_configs = 8,
284-
.num_gpios = 4,
285-
.has_temp = true,
286-
.has_input_buf = true,
287-
.has_int_ref = true,
288-
.has_ref2 = true,
289-
.has_pow_supply_monitoring = true,
290-
.clock = 16 * HZ_PER_MHZ,
291-
.sinc5_data_rates = ad7175_sinc5_data_rates,
292-
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
293-
},
294-
[ID_AD7176_2] = {
295-
.name = "ad7176-2",
296-
.id = AD7176_ID,
297-
.num_inputs = 5,
298-
.num_channels = 4,
299-
.num_configs = 4,
300-
.num_gpios = 2,
301-
.has_temp = false,
302-
.has_input_buf = false,
303-
.has_int_ref = true,
304-
.clock = 16 * HZ_PER_MHZ,
305-
.sinc5_data_rates = ad7175_sinc5_data_rates,
306-
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
307-
},
308-
[ID_AD7177_2] = {
309-
.name = "ad7177-2",
310-
.id = AD7177_ID,
311-
.num_inputs = 5,
312-
.num_channels = 4,
313-
.num_configs = 4,
314-
.num_gpios = 2,
315-
.has_temp = true,
316-
.has_input_buf = true,
317-
.has_int_ref = true,
318-
.has_pow_supply_monitoring = true,
319-
.clock = 16 * HZ_PER_MHZ,
320-
.odr_start_value = AD7177_ODR_START_VALUE,
321-
.sinc5_data_rates = ad7175_sinc5_data_rates,
322-
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
323-
},
207+
static const struct ad7173_device_info ad7172_2_device_info = {
208+
.name = "ad7172-2",
209+
.id = AD7172_2_ID,
210+
.num_inputs = 5,
211+
.num_channels = 4,
212+
.num_configs = 4,
213+
.num_gpios = 2,
214+
.has_temp = true,
215+
.has_input_buf = true,
216+
.has_int_ref = true,
217+
.has_pow_supply_monitoring = true,
218+
.clock = 2 * HZ_PER_MHZ,
219+
.sinc5_data_rates = ad7173_sinc5_data_rates,
220+
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
221+
};
222+
223+
static const struct ad7173_device_info ad7172_4_device_info = {
224+
.name = "ad7172-4",
225+
.id = AD7172_4_ID,
226+
.num_inputs = 9,
227+
.num_channels = 8,
228+
.num_configs = 8,
229+
.num_gpios = 4,
230+
.has_input_buf = true,
231+
.has_ref2 = true,
232+
.has_pow_supply_monitoring = true,
233+
.clock = 2 * HZ_PER_MHZ,
234+
.sinc5_data_rates = ad7173_sinc5_data_rates,
235+
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
236+
};
237+
238+
static const struct ad7173_device_info ad7173_8_device_info = {
239+
.name = "ad7173-8",
240+
.id = AD7173_ID,
241+
.num_inputs = 17,
242+
.num_channels = 16,
243+
.num_configs = 8,
244+
.num_gpios = 4,
245+
.has_temp = true,
246+
.has_input_buf = true,
247+
.has_int_ref = true,
248+
.has_ref2 = true,
249+
.clock = 2 * HZ_PER_MHZ,
250+
.sinc5_data_rates = ad7173_sinc5_data_rates,
251+
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
252+
};
253+
254+
static const struct ad7173_device_info ad7175_2_device_info = {
255+
.name = "ad7175-2",
256+
.id = AD7175_2_ID,
257+
.num_inputs = 5,
258+
.num_channels = 4,
259+
.num_configs = 4,
260+
.num_gpios = 2,
261+
.has_temp = true,
262+
.has_input_buf = true,
263+
.has_int_ref = true,
264+
.has_pow_supply_monitoring = true,
265+
.clock = 16 * HZ_PER_MHZ,
266+
.sinc5_data_rates = ad7175_sinc5_data_rates,
267+
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
268+
};
269+
270+
static const struct ad7173_device_info ad7175_8_device_info = {
271+
.name = "ad7175-8",
272+
.id = AD7175_8_ID,
273+
.num_inputs = 17,
274+
.num_channels = 16,
275+
.num_configs = 8,
276+
.num_gpios = 4,
277+
.has_temp = true,
278+
.has_input_buf = true,
279+
.has_int_ref = true,
280+
.has_ref2 = true,
281+
.has_pow_supply_monitoring = true,
282+
.clock = 16 * HZ_PER_MHZ,
283+
.sinc5_data_rates = ad7175_sinc5_data_rates,
284+
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
285+
};
286+
287+
static const struct ad7173_device_info ad7176_2_device_info = {
288+
.name = "ad7176-2",
289+
.id = AD7176_ID,
290+
.num_inputs = 5,
291+
.num_channels = 4,
292+
.num_configs = 4,
293+
.num_gpios = 2,
294+
.has_int_ref = true,
295+
.clock = 16 * HZ_PER_MHZ,
296+
.sinc5_data_rates = ad7175_sinc5_data_rates,
297+
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
298+
};
299+
300+
static const struct ad7173_device_info ad7177_2_device_info = {
301+
.name = "ad7177-2",
302+
.id = AD7177_ID,
303+
.num_inputs = 5,
304+
.num_channels = 4,
305+
.num_configs = 4,
306+
.num_gpios = 2,
307+
.has_temp = true,
308+
.has_input_buf = true,
309+
.has_int_ref = true,
310+
.has_pow_supply_monitoring = true,
311+
.clock = 16 * HZ_PER_MHZ,
312+
.odr_start_value = AD7177_ODR_START_VALUE,
313+
.sinc5_data_rates = ad7175_sinc5_data_rates,
314+
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
324315
};
325316

326317
static const char *const ad7173_ref_sel_str[] = {
@@ -1187,32 +1178,25 @@ static int ad7173_probe(struct spi_device *spi)
11871178
}
11881179

11891180
static const struct of_device_id ad7173_of_match[] = {
1190-
{ .compatible = "adi,ad7172-2",
1191-
.data = &ad7173_device_info[ID_AD7172_2]},
1192-
{ .compatible = "adi,ad7172-4",
1193-
.data = &ad7173_device_info[ID_AD7172_4]},
1194-
{ .compatible = "adi,ad7173-8",
1195-
.data = &ad7173_device_info[ID_AD7173_8]},
1196-
{ .compatible = "adi,ad7175-2",
1197-
.data = &ad7173_device_info[ID_AD7175_2]},
1198-
{ .compatible = "adi,ad7175-8",
1199-
.data = &ad7173_device_info[ID_AD7175_8]},
1200-
{ .compatible = "adi,ad7176-2",
1201-
.data = &ad7173_device_info[ID_AD7176_2]},
1202-
{ .compatible = "adi,ad7177-2",
1203-
.data = &ad7173_device_info[ID_AD7177_2]},
1181+
{ .compatible = "adi,ad7172-2", .data = &ad7172_2_device_info },
1182+
{ .compatible = "adi,ad7172-4", .data = &ad7172_4_device_info },
1183+
{ .compatible = "adi,ad7173-8", .data = &ad7173_8_device_info },
1184+
{ .compatible = "adi,ad7175-2", .data = &ad7175_2_device_info },
1185+
{ .compatible = "adi,ad7175-8", .data = &ad7175_8_device_info },
1186+
{ .compatible = "adi,ad7176-2", .data = &ad7176_2_device_info },
1187+
{ .compatible = "adi,ad7177-2", .data = &ad7177_2_device_info },
12041188
{ }
12051189
};
12061190
MODULE_DEVICE_TABLE(of, ad7173_of_match);
12071191

12081192
static const struct spi_device_id ad7173_id_table[] = {
1209-
{ "ad7172-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7172_2]},
1210-
{ "ad7172-4", (kernel_ulong_t)&ad7173_device_info[ID_AD7172_4]},
1211-
{ "ad7173-8", (kernel_ulong_t)&ad7173_device_info[ID_AD7173_8]},
1212-
{ "ad7175-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7175_2]},
1213-
{ "ad7175-8", (kernel_ulong_t)&ad7173_device_info[ID_AD7175_8]},
1214-
{ "ad7176-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7176_2]},
1215-
{ "ad7177-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7177_2]},
1193+
{ "ad7172-2", (kernel_ulong_t)&ad7172_2_device_info },
1194+
{ "ad7172-4", (kernel_ulong_t)&ad7172_4_device_info },
1195+
{ "ad7173-8", (kernel_ulong_t)&ad7173_8_device_info },
1196+
{ "ad7175-2", (kernel_ulong_t)&ad7175_2_device_info },
1197+
{ "ad7175-8", (kernel_ulong_t)&ad7175_8_device_info },
1198+
{ "ad7176-2", (kernel_ulong_t)&ad7176_2_device_info },
1199+
{ "ad7177-2", (kernel_ulong_t)&ad7177_2_device_info },
12161200
{ }
12171201
};
12181202
MODULE_DEVICE_TABLE(spi, ad7173_id_table);

0 commit comments

Comments
 (0)