Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: Convert to IIO_MAP()

Use IIO_MAP() instead of hand-writing it. It is much less verbose.

The change has been do with the following coccinelle script:

@@
identifier STRUCT_NAME;
constant NAME, CHANNEL, LABEL;
@@

static const struct iio_map STRUCT_NAME[] = {
...,
- {
- .consumer_dev_name = NAME,
- .consumer_channel = CHANNEL,
- .adc_channel_label = LABEL,
- },
+ IIO_MAP(LABEL, NAME, CHANNEL),
...
};

@@
identifier STRUCT_NAME;
constant NAME, LABEL;
@@

static const struct iio_map STRUCT_NAME[] = {
...,
- {
- .consumer_dev_name = NAME,
- .adc_channel_label = LABEL,
- },
+ IIO_MAP(LABEL, NAME, NULL),
...
};

--
Compile tested only

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/48f08224fab5a7595f650dbcef012d7cac3f972b.1725729801.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Christophe JAILLET and committed by
Jonathan Cameron
51bedd7b faf17860

+19 -76
+12 -42
drivers/iio/adc/axp20x_adc.c
··· 156 156 }; 157 157 158 158 static const struct iio_map axp20x_maps[] = { 159 - { 160 - .consumer_dev_name = "axp20x-usb-power-supply", 161 - .consumer_channel = "vbus_v", 162 - .adc_channel_label = "vbus_v", 163 - }, { 164 - .consumer_dev_name = "axp20x-usb-power-supply", 165 - .consumer_channel = "vbus_i", 166 - .adc_channel_label = "vbus_i", 167 - }, { 168 - .consumer_dev_name = "axp20x-ac-power-supply", 169 - .consumer_channel = "acin_v", 170 - .adc_channel_label = "acin_v", 171 - }, { 172 - .consumer_dev_name = "axp20x-ac-power-supply", 173 - .consumer_channel = "acin_i", 174 - .adc_channel_label = "acin_i", 175 - }, { 176 - .consumer_dev_name = "axp20x-battery-power-supply", 177 - .consumer_channel = "batt_v", 178 - .adc_channel_label = "batt_v", 179 - }, { 180 - .consumer_dev_name = "axp20x-battery-power-supply", 181 - .consumer_channel = "batt_chrg_i", 182 - .adc_channel_label = "batt_chrg_i", 183 - }, { 184 - .consumer_dev_name = "axp20x-battery-power-supply", 185 - .consumer_channel = "batt_dischrg_i", 186 - .adc_channel_label = "batt_dischrg_i", 187 - }, { /* sentinel */ } 159 + IIO_MAP("vbus_v", "axp20x-usb-power-supply", "vbus_v"), 160 + IIO_MAP("vbus_i", "axp20x-usb-power-supply", "vbus_i"), 161 + IIO_MAP("acin_v", "axp20x-ac-power-supply", "acin_v"), 162 + IIO_MAP("acin_i", "axp20x-ac-power-supply", "acin_i"), 163 + IIO_MAP("batt_v", "axp20x-battery-power-supply", "batt_v"), 164 + IIO_MAP("batt_chrg_i", "axp20x-battery-power-supply", "batt_chrg_i"), 165 + IIO_MAP("batt_dischrg_i", "axp20x-battery-power-supply", "batt_dischrg_i"), 166 + { /* sentinel */ } 188 167 }; 189 168 190 169 static const struct iio_map axp22x_maps[] = { 191 - { 192 - .consumer_dev_name = "axp20x-battery-power-supply", 193 - .consumer_channel = "batt_v", 194 - .adc_channel_label = "batt_v", 195 - }, { 196 - .consumer_dev_name = "axp20x-battery-power-supply", 197 - .consumer_channel = "batt_chrg_i", 198 - .adc_channel_label = "batt_chrg_i", 199 - }, { 200 - .consumer_dev_name = "axp20x-battery-power-supply", 201 - .consumer_channel = "batt_dischrg_i", 202 - .adc_channel_label = "batt_dischrg_i", 203 - }, { /* sentinel */ } 170 + IIO_MAP("batt_v", "axp20x-battery-power-supply", "batt_v"), 171 + IIO_MAP("batt_chrg_i", "axp20x-battery-power-supply", "batt_chrg_i"), 172 + IIO_MAP("batt_dischrg_i", "axp20x-battery-power-supply", "batt_dischrg_i"), 173 + { /* sentinel */ } 204 174 }; 205 175 206 176 static struct iio_map axp717_maps[] = {
+4 -20
drivers/iio/adc/da9150-gpadc.c
··· 292 292 293 293 /* Default maps used by da9150-charger */ 294 294 static const struct iio_map da9150_gpadc_default_maps[] = { 295 - { 296 - .consumer_dev_name = "da9150-charger", 297 - .consumer_channel = "CHAN_IBUS", 298 - .adc_channel_label = "IBUS", 299 - }, 300 - { 301 - .consumer_dev_name = "da9150-charger", 302 - .consumer_channel = "CHAN_VBUS", 303 - .adc_channel_label = "VBUS", 304 - }, 305 - { 306 - .consumer_dev_name = "da9150-charger", 307 - .consumer_channel = "CHAN_TJUNC", 308 - .adc_channel_label = "TJUNC_CORE", 309 - }, 310 - { 311 - .consumer_dev_name = "da9150-charger", 312 - .consumer_channel = "CHAN_VBAT", 313 - .adc_channel_label = "VBAT", 314 - }, 295 + IIO_MAP("IBUS", "da9150-charger", "CHAN_IBUS"), 296 + IIO_MAP("VBUS", "da9150-charger", "CHAN_VBUS"), 297 + IIO_MAP("TJUNC_CORE", "da9150-charger", "CHAN_TJUNC"), 298 + IIO_MAP("VBAT", "da9150-charger", "CHAN_VBAT"), 315 299 {}, 316 300 }; 317 301
+2 -10
drivers/iio/adc/lp8788_adc.c
··· 150 150 151 151 /* default maps used by iio consumer (lp8788-charger driver) */ 152 152 static const struct iio_map lp8788_default_iio_maps[] = { 153 - { 154 - .consumer_dev_name = "lp8788-charger", 155 - .consumer_channel = "lp8788_vbatt_5p0", 156 - .adc_channel_label = "VBATT_5P0", 157 - }, 158 - { 159 - .consumer_dev_name = "lp8788-charger", 160 - .consumer_channel = "lp8788_adc1", 161 - .adc_channel_label = "ADC1", 162 - }, 153 + IIO_MAP("VBATT_5P0", "lp8788-charger", "lp8788_vbatt_5p0"), 154 + IIO_MAP("ADC1", "lp8788-charger", "lp8788_adc1"), 163 155 { } 164 156 }; 165 157
+1 -4
drivers/iio/adc/sun4i-gpadc-iio.c
··· 115 115 } 116 116 117 117 static const struct iio_map sun4i_gpadc_hwmon_maps[] = { 118 - { 119 - .adc_channel_label = "temp_adc", 120 - .consumer_dev_name = "iio_hwmon.0", 121 - }, 118 + IIO_MAP("temp_adc", "iio_hwmon.0", NULL), 122 119 { /* sentinel */ }, 123 120 }; 124 121