Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Fabio Estevam <festevam@gmail.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	mazziesaccount@gmail.com, linux-iio@vger.kernel.org,
	Fabio Estevam <festevam@denx.de>,
	stable@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: Fix scan mask subset check logic
Date: Mon, 5 May 2025 16:16:45 +0100	[thread overview]
Message-ID: <20250505161645.5bca37c5@jic23-huawei> (raw)
In-Reply-To: <CAOMZO5DeMNGqpF4T7tuvBBN=i95uReSTXkj-sNW2jZTUO++5ZA@mail.gmail.com>

On Mon, 5 May 2025 11:24:36 -0300
Fabio Estevam <festevam@gmail.com> wrote:

> Hi Jonathan,
> 
> On Sun, May 4, 2025 at 2:04 PM Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > Ah. I was wrong for last two channels above. The scan masks for single channel for
> > differential channels also index a bunch we aren't using in this device.
> >  
> > > +       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
> > > +       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \  
> > //gap here as we aren't using 4,5  6,7 8,9, 10,11
> >  
> > > +       MAX1363_CHAN_B(1, 0, d1m0, 14, bits, ev_spec, num_ev_spec),     \  
> > Should be 18
> > https://elixir.bootlin.com/linux/v6.14.5/source/drivers/iio/adc/max1363.c#L262  
> > > +       MAX1363_CHAN_B(3, 2, d3m2, 15, bits, ev_spec, num_ev_spec),     \  
> > and 19 I believe.  
> 
> This works fine for me, thanks:
> 
> --- a/drivers/iio/adc/max1363.c
> +++ b/drivers/iio/adc/max1363.c
> @@ -504,10 +504,10 @@ static const struct iio_event_spec max1363_events[] = {
>         MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec),          \
>         MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec),          \
>         MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec),          \
> -       MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec),      \
> -       MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec),      \
> -       MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec),      \
> -       MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec),      \
> +       MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec),     \
> +       MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec),     \
> +       MAX1363_CHAN_B(1, 0, d1m0, 18, bits, ev_spec, num_ev_spec),     \
> +       MAX1363_CHAN_B(3, 2, d3m2, 19, bits, ev_spec, num_ev_spec),     \
>         IIO_CHAN_SOFT_TIMESTAMP(8)                                      \
>         }
> 
> > Maybe we can simplify this and make it less error prone. These scan indices
> > are always the same as the enum max1363_mode entries in the 2nd or 3rd parameter.
> > We can just reuse those I think.  Only the single channel ones apply here
> > but those are the first set of entries in that enum.
> >
> > Bonus points for just dropping the parameter and using the existing addr
> > parameter for the macro as si as well.
> >
> > That is:
> > #define MAX1363_CHAN_U(num, addr, bits, ev_spec, num_ev_spec)   \
> >         {                                                               \
> >                 .type = IIO_VOLTAGE,                                    \
> >                 .indexed = 1,                                           \
> >                 .channel = num,                                         \
> >                 .address = addr,                                        \
> >                 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),           \
> >                 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
> >                 .datasheet_name = "AIN"#num,                            \
> >                 .scan_type = {                                          \
> >                         .sign = 'u',                                    \
> >                         .realbits = bits,                               \
> >                         .storagebits = (bits > 8) ? 16 : 8,             \
> >                         .endianness = IIO_BE,                           \
> >                 },                                                      \
> >                 .scan_index = (addr),                                   \
> > The above changed from si to addr  
> 
> I tried this change on top of the previous one, and it still works.
> 
> How do you think we should proceed? Can you please submit formal patches?
That would be perfect! If you can do it by modifying the macro as that is
going to be the simplest path to ensure there are no others even better.

Jonathan

> 
> You can add:
> 
> Reported-by: Fabio Estevam <festevam@denx.de>
> Tested-by: Fabio Estevam <festevam@denx.de>
> 
> Thanks


  reply	other threads:[~2025-05-05 15:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29 15:02 [PATCH 1/2] iio: Fix scan mask subset check logic Fabio Estevam
2025-04-29 15:02 ` [PATCH 2/2] iio: adc: max1363: Reorder max11607_mode_list[] Fabio Estevam
2025-04-29 17:35   ` Jonathan Cameron
2025-04-29 18:37     ` Fabio Estevam
2025-04-29 17:33 ` [PATCH 1/2] iio: Fix scan mask subset check logic Jonathan Cameron
2025-04-29 18:33   ` Fabio Estevam
2025-04-29 19:05     ` Fabio Estevam
2025-04-30 13:11       ` Jonathan Cameron
2025-04-30 13:26         ` Fabio Estevam
2025-04-30 17:25           ` Jonathan Cameron
2025-04-30 19:37             ` Fabio Estevam
2025-05-03 12:02               ` Fabio Estevam
2025-05-04 17:06                 ` Jonathan Cameron
2025-05-04 17:04               ` Jonathan Cameron
2025-05-05 14:24                 ` Fabio Estevam
2025-05-05 15:16                   ` Jonathan Cameron [this message]
2025-05-08 13:29                     ` Fabio Estevam
2025-05-08 19:05                       ` Jonathan Cameron

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=20250505161645.5bca37c5@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=festevam@denx.de \
    --cc=festevam@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=stable@vger.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