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>
This commit is contained in:
Christophe JAILLET 2024-09-07 19:24:47 +02:00 committed by Jonathan Cameron
parent faf1786077
commit 51bedd7b98
4 changed files with 19 additions and 76 deletions

View File

@ -156,51 +156,21 @@ enum axp813_adc_channel_v {
};
static const struct iio_map axp20x_maps[] = {
{
.consumer_dev_name = "axp20x-usb-power-supply",
.consumer_channel = "vbus_v",
.adc_channel_label = "vbus_v",
}, {
.consumer_dev_name = "axp20x-usb-power-supply",
.consumer_channel = "vbus_i",
.adc_channel_label = "vbus_i",
}, {
.consumer_dev_name = "axp20x-ac-power-supply",
.consumer_channel = "acin_v",
.adc_channel_label = "acin_v",
}, {
.consumer_dev_name = "axp20x-ac-power-supply",
.consumer_channel = "acin_i",
.adc_channel_label = "acin_i",
}, {
.consumer_dev_name = "axp20x-battery-power-supply",
.consumer_channel = "batt_v",
.adc_channel_label = "batt_v",
}, {
.consumer_dev_name = "axp20x-battery-power-supply",
.consumer_channel = "batt_chrg_i",
.adc_channel_label = "batt_chrg_i",
}, {
.consumer_dev_name = "axp20x-battery-power-supply",
.consumer_channel = "batt_dischrg_i",
.adc_channel_label = "batt_dischrg_i",
}, { /* sentinel */ }
IIO_MAP("vbus_v", "axp20x-usb-power-supply", "vbus_v"),
IIO_MAP("vbus_i", "axp20x-usb-power-supply", "vbus_i"),
IIO_MAP("acin_v", "axp20x-ac-power-supply", "acin_v"),
IIO_MAP("acin_i", "axp20x-ac-power-supply", "acin_i"),
IIO_MAP("batt_v", "axp20x-battery-power-supply", "batt_v"),
IIO_MAP("batt_chrg_i", "axp20x-battery-power-supply", "batt_chrg_i"),
IIO_MAP("batt_dischrg_i", "axp20x-battery-power-supply", "batt_dischrg_i"),
{ /* sentinel */ }
};
static const struct iio_map axp22x_maps[] = {
{
.consumer_dev_name = "axp20x-battery-power-supply",
.consumer_channel = "batt_v",
.adc_channel_label = "batt_v",
}, {
.consumer_dev_name = "axp20x-battery-power-supply",
.consumer_channel = "batt_chrg_i",
.adc_channel_label = "batt_chrg_i",
}, {
.consumer_dev_name = "axp20x-battery-power-supply",
.consumer_channel = "batt_dischrg_i",
.adc_channel_label = "batt_dischrg_i",
}, { /* sentinel */ }
IIO_MAP("batt_v", "axp20x-battery-power-supply", "batt_v"),
IIO_MAP("batt_chrg_i", "axp20x-battery-power-supply", "batt_chrg_i"),
IIO_MAP("batt_dischrg_i", "axp20x-battery-power-supply", "batt_dischrg_i"),
{ /* sentinel */ }
};
static struct iio_map axp717_maps[] = {

View File

@ -292,26 +292,10 @@ static const struct iio_chan_spec da9150_gpadc_channels[] = {
/* Default maps used by da9150-charger */
static const struct iio_map da9150_gpadc_default_maps[] = {
{
.consumer_dev_name = "da9150-charger",
.consumer_channel = "CHAN_IBUS",
.adc_channel_label = "IBUS",
},
{
.consumer_dev_name = "da9150-charger",
.consumer_channel = "CHAN_VBUS",
.adc_channel_label = "VBUS",
},
{
.consumer_dev_name = "da9150-charger",
.consumer_channel = "CHAN_TJUNC",
.adc_channel_label = "TJUNC_CORE",
},
{
.consumer_dev_name = "da9150-charger",
.consumer_channel = "CHAN_VBAT",
.adc_channel_label = "VBAT",
},
IIO_MAP("IBUS", "da9150-charger", "CHAN_IBUS"),
IIO_MAP("VBUS", "da9150-charger", "CHAN_VBUS"),
IIO_MAP("TJUNC_CORE", "da9150-charger", "CHAN_TJUNC"),
IIO_MAP("VBAT", "da9150-charger", "CHAN_VBAT"),
{},
};

View File

@ -150,16 +150,8 @@ static const struct iio_chan_spec lp8788_adc_channels[] = {
/* default maps used by iio consumer (lp8788-charger driver) */
static const struct iio_map lp8788_default_iio_maps[] = {
{
.consumer_dev_name = "lp8788-charger",
.consumer_channel = "lp8788_vbatt_5p0",
.adc_channel_label = "VBATT_5P0",
},
{
.consumer_dev_name = "lp8788-charger",
.consumer_channel = "lp8788_adc1",
.adc_channel_label = "ADC1",
},
IIO_MAP("VBATT_5P0", "lp8788-charger", "lp8788_vbatt_5p0"),
IIO_MAP("ADC1", "lp8788-charger", "lp8788_adc1"),
{ }
};

View File

@ -115,10 +115,7 @@ struct sun4i_gpadc_iio {
}
static const struct iio_map sun4i_gpadc_hwmon_maps[] = {
{
.adc_channel_label = "temp_adc",
.consumer_dev_name = "iio_hwmon.0",
},
IIO_MAP("temp_adc", "iio_hwmon.0", NULL),
{ /* sentinel */ },
};