* [PATCH] iio: Add macro to populate struct iio_map array
@ 2017-11-25 8:38 Lukas Wunner
2017-11-25 15:46 ` Chen-Yu Tsai
2017-11-25 15:50 ` Jonathan Cameron
0 siblings, 2 replies; 4+ messages in thread
From: Lukas Wunner @ 2017-11-25 8:38 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
Mathias Duckeck, linux-iio, Chen-Yu Tsai, Jacob Pan
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: Chen-Yu Tsai <wens@csie.org>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
The motivation for this change is that we're using it in a module which
is currently out-of-tree. I'm only converting axp288_adc.c here as it
already has such a macro, and not all the other drivers which declare
iio_map arrays because such trivial refactoring is not always welcome.
I could convert these other drivers as well if desired. If so, please
let me know if this should all be put in a single patch or split per
driver.
Note that I've replaced _adc_channel_label with _provider_channel,
which is more apt in my opinion. Please shout if you disagree.
Thanks!
drivers/iio/adc/axp288_adc.c | 20 ++++++--------------
include/linux/iio/machine.h | 7 +++++++
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
index 60c9e853dd81..031d568b4972 100644
--- a/drivers/iio/adc/axp288_adc.c
+++ b/drivers/iio/adc/axp288_adc.c
@@ -92,22 +92,14 @@ static const struct iio_chan_spec axp288_adc_channels[] = {
},
};
-#define AXP288_ADC_MAP(_adc_channel_label, _consumer_dev_name, \
- _consumer_channel) \
- { \
- .adc_channel_label = _adc_channel_label, \
- .consumer_dev_name = _consumer_dev_name, \
- .consumer_channel = _consumer_channel, \
- }
-
/* for consumer drivers */
static struct iio_map axp288_adc_default_maps[] = {
- AXP288_ADC_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
- AXP288_ADC_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
- AXP288_ADC_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
- AXP288_ADC_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
- AXP288_ADC_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
- AXP288_ADC_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
+ IIO_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
+ IIO_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
+ IIO_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
+ IIO_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
+ IIO_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
+ IIO_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
{},
};
diff --git a/include/linux/iio/machine.h b/include/linux/iio/machine.h
index 1601a2a63a72..5e1cfa75f652 100644
--- a/include/linux/iio/machine.h
+++ b/include/linux/iio/machine.h
@@ -28,4 +28,11 @@ struct iio_map {
void *consumer_data;
};
+#define IIO_MAP(_provider_channel, _consumer_dev_name, _consumer_channel) \
+{ \
+ .adc_channel_label = _provider_channel, \
+ .consumer_dev_name = _consumer_dev_name, \
+ .consumer_channel = _consumer_channel, \
+}
+
#endif
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: Add macro to populate struct iio_map array
2017-11-25 8:38 [PATCH] iio: Add macro to populate struct iio_map array Lukas Wunner
@ 2017-11-25 15:46 ` Chen-Yu Tsai
2017-11-25 15:50 ` Jonathan Cameron
1 sibling, 0 replies; 4+ messages in thread
From: Chen-Yu Tsai @ 2017-11-25 15:46 UTC (permalink / raw)
To: Lukas Wunner
Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
Peter Meerwald-Stadler, Mathias Duckeck, linux-iio, Chen-Yu Tsai,
Jacob Pan
On Sat, Nov 25, 2017 at 4:38 PM, Lukas Wunner <lukas@wunner.de> wrote:
> 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: Chen-Yu Tsai <wens@csie.org>
> 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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: Add macro to populate struct iio_map array
2017-11-25 8:38 [PATCH] iio: Add macro to populate struct iio_map array Lukas Wunner
2017-11-25 15:46 ` Chen-Yu Tsai
@ 2017-11-25 15:50 ` Jonathan Cameron
2017-12-02 13:29 ` Jonathan Cameron
1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2017-11-25 15:50 UTC (permalink / raw)
To: Lukas Wunner
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
Mathias Duckeck, linux-iio, Chen-Yu Tsai, Jacob Pan
On Sat, 25 Nov 2017 09:38:17 +0100
Lukas Wunner <lukas@wunner.de> wrote:
> 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: Chen-Yu Tsai <wens@csie.org>
> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
Seems reasonable to me but I'll let it sit for a few days in case
anyone wants to comment.
Jonathan
> ---
> The motivation for this change is that we're using it in a module which
> is currently out-of-tree. I'm only converting axp288_adc.c here as it
> already has such a macro, and not all the other drivers which declare
> iio_map arrays because such trivial refactoring is not always welcome.
> I could convert these other drivers as well if desired. If so, please
> let me know if this should all be put in a single patch or split per
> driver.
>
> Note that I've replaced _adc_channel_label with _provider_channel,
> which is more apt in my opinion. Please shout if you disagree.
>
> Thanks!
>
> drivers/iio/adc/axp288_adc.c | 20 ++++++--------------
> include/linux/iio/machine.h | 7 +++++++
> 2 files changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
> index 60c9e853dd81..031d568b4972 100644
> --- a/drivers/iio/adc/axp288_adc.c
> +++ b/drivers/iio/adc/axp288_adc.c
> @@ -92,22 +92,14 @@ static const struct iio_chan_spec axp288_adc_channels[] = {
> },
> };
>
> -#define AXP288_ADC_MAP(_adc_channel_label, _consumer_dev_name, \
> - _consumer_channel) \
> - { \
> - .adc_channel_label = _adc_channel_label, \
> - .consumer_dev_name = _consumer_dev_name, \
> - .consumer_channel = _consumer_channel, \
> - }
> -
> /* for consumer drivers */
> static struct iio_map axp288_adc_default_maps[] = {
> - AXP288_ADC_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
> - AXP288_ADC_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
> - AXP288_ADC_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
> - AXP288_ADC_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
> - AXP288_ADC_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
> - AXP288_ADC_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
> + IIO_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
> + IIO_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
> + IIO_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
> + IIO_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
> + IIO_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
> + IIO_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
> {},
> };
>
> diff --git a/include/linux/iio/machine.h b/include/linux/iio/machine.h
> index 1601a2a63a72..5e1cfa75f652 100644
> --- a/include/linux/iio/machine.h
> +++ b/include/linux/iio/machine.h
> @@ -28,4 +28,11 @@ struct iio_map {
> void *consumer_data;
> };
>
> +#define IIO_MAP(_provider_channel, _consumer_dev_name, _consumer_channel) \
> +{ \
> + .adc_channel_label = _provider_channel, \
> + .consumer_dev_name = _consumer_dev_name, \
> + .consumer_channel = _consumer_channel, \
> +}
> +
> #endif
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: Add macro to populate struct iio_map array
2017-11-25 15:50 ` Jonathan Cameron
@ 2017-12-02 13:29 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2017-12-02 13:29 UTC (permalink / raw)
To: Lukas Wunner
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
Mathias Duckeck, linux-iio, Chen-Yu Tsai, Jacob Pan
On Sat, 25 Nov 2017 15:50:10 +0000
Jonathan Cameron <jic23@kernel.org> wrote:
> On Sat, 25 Nov 2017 09:38:17 +0100
> Lukas Wunner <lukas@wunner.de> wrote:
>
> > 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: Chen-Yu Tsai <wens@csie.org>
> > Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
> > Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Seems reasonable to me but I'll let it sit for a few days in case
> anyone wants to comment.
>
> Jonathan
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
>
> > ---
> > The motivation for this change is that we're using it in a module which
> > is currently out-of-tree. I'm only converting axp288_adc.c here as it
> > already has such a macro, and not all the other drivers which declare
> > iio_map arrays because such trivial refactoring is not always welcome.
> > I could convert these other drivers as well if desired. If so, please
> > let me know if this should all be put in a single patch or split per
> > driver.
> >
> > Note that I've replaced _adc_channel_label with _provider_channel,
> > which is more apt in my opinion. Please shout if you disagree.
> >
> > Thanks!
> >
> > drivers/iio/adc/axp288_adc.c | 20 ++++++--------------
> > include/linux/iio/machine.h | 7 +++++++
> > 2 files changed, 13 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
> > index 60c9e853dd81..031d568b4972 100644
> > --- a/drivers/iio/adc/axp288_adc.c
> > +++ b/drivers/iio/adc/axp288_adc.c
> > @@ -92,22 +92,14 @@ static const struct iio_chan_spec axp288_adc_channels[] = {
> > },
> > };
> >
> > -#define AXP288_ADC_MAP(_adc_channel_label, _consumer_dev_name, \
> > - _consumer_channel) \
> > - { \
> > - .adc_channel_label = _adc_channel_label, \
> > - .consumer_dev_name = _consumer_dev_name, \
> > - .consumer_channel = _consumer_channel, \
> > - }
> > -
> > /* for consumer drivers */
> > static struct iio_map axp288_adc_default_maps[] = {
> > - AXP288_ADC_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
> > - AXP288_ADC_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
> > - AXP288_ADC_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
> > - AXP288_ADC_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
> > - AXP288_ADC_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
> > - AXP288_ADC_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
> > + IIO_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
> > + IIO_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
> > + IIO_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
> > + IIO_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
> > + IIO_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
> > + IIO_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
> > {},
> > };
> >
> > diff --git a/include/linux/iio/machine.h b/include/linux/iio/machine.h
> > index 1601a2a63a72..5e1cfa75f652 100644
> > --- a/include/linux/iio/machine.h
> > +++ b/include/linux/iio/machine.h
> > @@ -28,4 +28,11 @@ struct iio_map {
> > void *consumer_data;
> > };
> >
> > +#define IIO_MAP(_provider_channel, _consumer_dev_name, _consumer_channel) \
> > +{ \
> > + .adc_channel_label = _provider_channel, \
> > + .consumer_dev_name = _consumer_dev_name, \
> > + .consumer_channel = _consumer_channel, \
> > +}
> > +
> > #endif
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-02 13:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-25 8:38 [PATCH] iio: Add macro to populate struct iio_map array Lukas Wunner
2017-11-25 15:46 ` Chen-Yu Tsai
2017-11-25 15:50 ` Jonathan Cameron
2017-12-02 13:29 ` Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.