Skip to content

Commit 8d05ffd

Browse files
l1kJonathan Cameron
authored andcommitted
iio: Add macro to populate struct iio_map array
The GPIO core provides a handy GPIO_LOOKUP() macro to populate a struct gpiod_lookup array without having to spell out attribute names (but still avoid breakage when attributes within the struct are rearranged or added). The axp288_adc.c driver uses a similar macro to populate a struct iio_map array. Make it available to others. Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent cccae60 commit 8d05ffd

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

‎drivers/iio/adc/axp288_adc.c‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,14 @@ static const struct iio_chan_spec axp288_adc_channels[] = {
9292
},
9393
};
9494

95-
#define AXP288_ADC_MAP(_adc_channel_label, _consumer_dev_name, \
96-
_consumer_channel) \
97-
{ \
98-
.adc_channel_label = _adc_channel_label, \
99-
.consumer_dev_name = _consumer_dev_name, \
100-
.consumer_channel = _consumer_channel, \
101-
}
102-
10395
/* for consumer drivers */
10496
static struct iio_map axp288_adc_default_maps[] = {
105-
AXP288_ADC_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
106-
AXP288_ADC_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
107-
AXP288_ADC_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
108-
AXP288_ADC_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
109-
AXP288_ADC_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
110-
AXP288_ADC_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
97+
IIO_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
98+
IIO_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
99+
IIO_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
100+
IIO_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
101+
IIO_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
102+
IIO_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
111103
{},
112104
};
113105

‎include/linux/iio/machine.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ struct iio_map {
2828
void *consumer_data;
2929
};
3030

31+
#define IIO_MAP(_provider_channel, _consumer_dev_name, _consumer_channel) \
32+
{ \
33+
.adc_channel_label = _provider_channel, \
34+
.consumer_dev_name = _consumer_dev_name, \
35+
.consumer_channel = _consumer_channel, \
36+
}
37+
3138
#endif

0 commit comments

Comments
 (0)