From: Jonathan Cameron <jic23@kernel.org>
To: Artur Rojek <contact@artur-rojek.eu>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Paul Cercueil <paul@crapouillou.net>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Heiko Stuebner <heiko@sntech.de>,
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
devicetree@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 4/6] iio/adc: ingenic: Retrieve channels list from soc data struct
Date: Sun, 12 Jul 2020 13:11:30 +0100 [thread overview]
Message-ID: <20200712131130.350fd3c7@archlinux> (raw)
In-Reply-To: <20200712130713.64cd2bac@archlinux>
On Sun, 12 Jul 2020 13:07:13 +0100
Jonathan Cameron <jic23@kernel.org> wrote:
> On Thu, 9 Jul 2020 17:21:58 +0200
> Artur Rojek <contact@artur-rojek.eu> wrote:
>
> > From: Paul Cercueil <paul@crapouillou.net>
> >
> > Instead of having one array of struct iio_chan_spec for all SoCs, and
> > have some SoCs remove the last item of the array as they can't use it,
> > have each SoC define its array of supported channels.
> >
> > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> > Tested-by: Artur Rojek <contact@artur-rojek.eu>
> Applied to the togreg branch of iio.git and pushed out as testing for
> autobuilders to play with it.
Actually removed from tree again.
Artur, as you sent this patch on to me, you need to sign-off on it
so we maintain the DCO related records of how this got to the kernel.
You can just reply here to give it.
Thanks,
Jonathan
>
> Thanks,
>
> Jonathan
>
> > ---
> >
> > Changes:
> >
> > v8: new patch
> >
> > drivers/iio/adc/ingenic-adc.c | 99 +++++++++++++++++++++++------------
> > 1 file changed, 65 insertions(+), 34 deletions(-)
> >
> > diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
> > index 89019fb59d48..0233a9055c86 100644
> > --- a/drivers/iio/adc/ingenic-adc.c
> > +++ b/drivers/iio/adc/ingenic-adc.c
> > @@ -55,6 +55,8 @@ struct ingenic_adc_soc_data {
> > size_t battery_scale_avail_size;
> > unsigned int battery_vref_mode: 1;
> > unsigned int has_aux2: 1;
> > + const struct iio_chan_spec *channels;
> > + unsigned int num_channels;
> > int (*init_clk_div)(struct device *dev, struct ingenic_adc *adc);
> > };
> >
> > @@ -262,6 +264,61 @@ static int jz4770_adc_init_clk_div(struct device *dev, struct ingenic_adc *adc)
> > return 0;
> > }
> >
> > +static const struct iio_chan_spec jz4740_channels[] = {
> > + {
> > + .extend_name = "aux",
> > + .type = IIO_VOLTAGE,
> > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > + BIT(IIO_CHAN_INFO_SCALE),
> > + .indexed = 1,
> > + .channel = INGENIC_ADC_AUX,
> > + .scan_index = -1,
> > + },
> > + {
> > + .extend_name = "battery",
> > + .type = IIO_VOLTAGE,
> > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > + BIT(IIO_CHAN_INFO_SCALE),
> > + .info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW) |
> > + BIT(IIO_CHAN_INFO_SCALE),
> > + .indexed = 1,
> > + .channel = INGENIC_ADC_BATTERY,
> > + .scan_index = -1,
> > + },
> > +};
> > +
> > +static const struct iio_chan_spec jz4770_channels[] = {
> > + {
> > + .extend_name = "aux",
> > + .type = IIO_VOLTAGE,
> > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > + BIT(IIO_CHAN_INFO_SCALE),
> > + .indexed = 1,
> > + .channel = INGENIC_ADC_AUX,
> > + .scan_index = -1,
> > + },
> > + {
> > + .extend_name = "battery",
> > + .type = IIO_VOLTAGE,
> > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > + BIT(IIO_CHAN_INFO_SCALE),
> > + .info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW) |
> > + BIT(IIO_CHAN_INFO_SCALE),
> > + .indexed = 1,
> > + .channel = INGENIC_ADC_BATTERY,
> > + .scan_index = -1,
> > + },
> > + {
> > + .extend_name = "aux2",
> > + .type = IIO_VOLTAGE,
> > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > + BIT(IIO_CHAN_INFO_SCALE),
> > + .indexed = 1,
> > + .channel = INGENIC_ADC_AUX2,
> > + .scan_index = -1,
> > + },
> > +};
> > +
> > static const struct ingenic_adc_soc_data jz4725b_adc_soc_data = {
> > .battery_high_vref = JZ4725B_ADC_BATTERY_HIGH_VREF,
> > .battery_high_vref_bits = JZ4725B_ADC_BATTERY_HIGH_VREF_BITS,
> > @@ -271,6 +328,8 @@ static const struct ingenic_adc_soc_data jz4725b_adc_soc_data = {
> > .battery_scale_avail_size = ARRAY_SIZE(jz4725b_adc_battery_scale_avail),
> > .battery_vref_mode = true,
> > .has_aux2 = false,
> > + .channels = jz4740_channels,
> > + .num_channels = ARRAY_SIZE(jz4740_channels),
> > .init_clk_div = jz4725b_adc_init_clk_div,
> > };
> >
> > @@ -283,6 +342,8 @@ static const struct ingenic_adc_soc_data jz4740_adc_soc_data = {
> > .battery_scale_avail_size = ARRAY_SIZE(jz4740_adc_battery_scale_avail),
> > .battery_vref_mode = true,
> > .has_aux2 = false,
> > + .channels = jz4740_channels,
> > + .num_channels = ARRAY_SIZE(jz4740_channels),
> > .init_clk_div = NULL, /* no ADCLK register on JZ4740 */
> > };
> >
> > @@ -295,6 +356,8 @@ static const struct ingenic_adc_soc_data jz4770_adc_soc_data = {
> > .battery_scale_avail_size = ARRAY_SIZE(jz4770_adc_battery_scale_avail),
> > .battery_vref_mode = false,
> > .has_aux2 = true,
> > + .channels = jz4770_channels,
> > + .num_channels = ARRAY_SIZE(jz4770_channels),
> > .init_clk_div = jz4770_adc_init_clk_div,
> > };
> >
> > @@ -427,35 +490,6 @@ static const struct iio_info ingenic_adc_info = {
> > .of_xlate = ingenic_adc_of_xlate,
> > };
> >
> > -static const struct iio_chan_spec ingenic_channels[] = {
> > - {
> > - .extend_name = "aux",
> > - .type = IIO_VOLTAGE,
> > - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > - BIT(IIO_CHAN_INFO_SCALE),
> > - .indexed = 1,
> > - .channel = INGENIC_ADC_AUX,
> > - },
> > - {
> > - .extend_name = "battery",
> > - .type = IIO_VOLTAGE,
> > - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > - BIT(IIO_CHAN_INFO_SCALE),
> > - .info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW) |
> > - BIT(IIO_CHAN_INFO_SCALE),
> > - .indexed = 1,
> > - .channel = INGENIC_ADC_BATTERY,
> > - },
> > - { /* Must always be last in the array. */
> > - .extend_name = "aux2",
> > - .type = IIO_VOLTAGE,
> > - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > - BIT(IIO_CHAN_INFO_SCALE),
> > - .indexed = 1,
> > - .channel = INGENIC_ADC_AUX2,
> > - },
> > -};
> > -
> > static int ingenic_adc_probe(struct platform_device *pdev)
> > {
> > struct device *dev = &pdev->dev;
> > @@ -517,11 +551,8 @@ static int ingenic_adc_probe(struct platform_device *pdev)
> > iio_dev->dev.parent = dev;
> > iio_dev->name = "jz-adc";
> > iio_dev->modes = INDIO_DIRECT_MODE;
> > - iio_dev->channels = ingenic_channels;
> > - iio_dev->num_channels = ARRAY_SIZE(ingenic_channels);
> > - /* Remove AUX2 from the list of supported channels. */
> > - if (!adc->soc_data->has_aux2)
> > - iio_dev->num_channels -= 1;
> > + iio_dev->channels = soc_data->channels;
> > + iio_dev->num_channels = soc_data->num_channels;
> > iio_dev->info = &ingenic_adc_info;
> >
> > ret = devm_iio_device_register(dev, iio_dev);
>
next prev parent reply other threads:[~2020-07-12 12:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 15:21 [PATCH v8 0/6] iio/adc: ingenic: Cleanups & add touchscreen mode Artur Rojek
2020-07-09 15:21 ` [PATCH v8 1/6] dt-bindings: iio/adc: Convert ingenic-adc docs to YAML Artur Rojek
2020-07-12 11:22 ` Jonathan Cameron
2020-07-09 15:21 ` [PATCH v8 2/6] IIO: Ingenic JZ47xx: Error check clk_enable calls Artur Rojek
2020-07-12 12:02 ` Jonathan Cameron
2020-07-13 5:07 ` Ardelean, Alexandru
2020-07-13 11:20 ` Jonathan Cameron
2020-07-09 15:21 ` [PATCH v8 3/6] IIO: Ingenic JZ47xx: Add xlate cb to retrieve correct channel idx Artur Rojek
2020-07-12 12:05 ` Jonathan Cameron
2020-07-09 15:21 ` [PATCH v8 4/6] iio/adc: ingenic: Retrieve channels list from soc data struct Artur Rojek
2020-07-12 12:07 ` Jonathan Cameron
2020-07-12 12:11 ` Jonathan Cameron [this message]
2020-07-12 19:53 ` Artur Rojek
2020-07-09 15:21 ` [PATCH v8 5/6] dt-bindings: iio/adc: Add touchscreen idx for JZ47xx SoC ADC Artur Rojek
2020-07-09 20:24 ` Rob Herring
2020-07-09 15:22 ` [PATCH v8 6/6] IIO: Ingenic JZ47xx: Add touchscreen mode Artur Rojek
2020-07-12 13:19 ` Jonathan Cameron
2020-07-12 20:16 ` Paul Cercueil
2020-07-20 11:49 ` Jonathan Cameron
2020-07-09 15:43 ` [PATCH v8 0/6] iio/adc: ingenic: Cleanups & add " Andy Shevchenko
2020-07-09 16:05 ` Artur Rojek
2020-07-09 16:42 ` Andy Shevchenko
2020-07-14 18:33 ` Heiko Stuebner
2020-07-19 22:16 ` Artur Rojek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200712131130.350fd3c7@archlinux \
--to=jic23@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=contact@artur-rojek.eu \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=heiko@sntech.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=paul@crapouillou.net \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).