]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iio: adc: Convert to IIO_MAP()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 7 Sep 2024 17:24:47 +0000 (19:24 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 30 Sep 2024 08:21:02 +0000 (09:21 +0100)
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>
drivers/iio/adc/axp20x_adc.c
drivers/iio/adc/da9150-gpadc.c
drivers/iio/adc/lp8788_adc.c
drivers/iio/adc/sun4i-gpadc-iio.c

index 940c92f2792a5706f57b51f9bcbd54b5a9dad0e6..b2a22f4eb9e47e14f35f4b0d92e79abdd5d6b173 100644 (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[] = {
index 82628746ba8e8d0f3326451c383dc9c7c2f6eb2d..0290345ade84176addb53eae2c6d8630faa504f1 100644 (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"),
        {},
 };
 
index 0d49be0061a207f729c0410df108598d9f6e0a2d..33bf8aef79e36212594114625564ded781070be5 100644 (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"),
        { }
 };
 
index 5d459f0506349409c0ddc7d8ba9470e6ce801a47..00a3a4db0fe02fcd97f3ddb1608e13c90478a6af 100644 (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 */ },
 };