public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Marek Vasut <marex@denx.de>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-iio <linux-iio@vger.kernel.org>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH 4/6] iio: adc: ti-ads1015: Deduplicate channel macros
Date: Sun, 20 Mar 2022 13:22:22 +0000	[thread overview]
Message-ID: <20220320132222.793abcea@jic23-huawei> (raw)
In-Reply-To: <35811c26-2363-6be0-09fe-91ee77f29069@denx.de>

On Fri, 11 Mar 2022 19:51:56 +0100
Marek Vasut <marex@denx.de> wrote:

> On 3/11/22 18:03, Andy Shevchenko wrote:
> > On Fri, Mar 11, 2022 at 12:33:49PM +0100, Marek Vasut wrote:  
> >> On 3/11/22 12:29, Andy Shevchenko wrote:  
> >>> On Fri, Mar 11, 2022 at 1:55 AM Marek Vasut <marex@denx.de> wrote:  
> >>>> On 3/10/22 15:25, Andy Shevchenko wrote:  
> >>>>> On Thu, Mar 10, 2022 at 01:34:00AM +0100, Marek Vasut wrote:  
> > 
> > ...
> >   
> >>>>>> -            .realbits = 12,                                 \
> >>>>>> +            .realbits = (_realbits),                        \
> >>>>>>                .storagebits = 16,                              \  
> >>>>>
> >>>>> This seems inconsistent a bit. What if the next chip wants to have more than
> >>>>> 16 bits in realbits?  
> >>>>
> >>>> When such a chip exists, this can be parametrized as well.  
> >>>
> >>> Yes, My point is that it's error prone.  
> >>
> >> Won't IIO core warn if realbits > storagebits ?  
> > 
> > If it's the case, then it's very good!  
> 
> No, apparently it won't .

Easy to add I think and a good idea. Though can only be a runtime
check obviously.

Put a verification check in iio_buffer_add_channel_sys() which
is registering the _type attr used to get access to this info from
user space.

Jonathan

> 
> > ...
> >   
> >>>>> I see two options:
> >>>>> 1) add static assert to make sure realbits <= storagebits;  
> >>>>
> >>>> Does static_assert work in array of structures (I don't think it does) ?  
> >>>
> >>> You can check, but IIRC some of the macros have it. Don't remember the
> >>> details, though.  
> >>
> >> I already checked before replying, hence my question, as I didn't find a way
> >> to make it work.  
> > 
> > It seems that current use cases have it either in functions or in
> > the expressions as ({...}). I dunno if the result of ({...}) can be
> > a data structure or compound literal.  
> 
> I added a patch to v2, but ugh, it isn't nice:
> 
> [PATCH v2 7/7] iio: adc: ti-ads1015: Add static assert to test if 
> shifted realbits fit into storagebits


  reply	other threads:[~2022-03-20 13:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10  0:33 [PATCH 1/6] dt-bindings: iio: adc: ti,ads1015: Add missing ADS1115 compatible string Marek Vasut
2022-03-10  0:33 ` [PATCH 2/6] dt-bindings: iio: adc: ti,ads1015: Add TLA2024 " Marek Vasut
2022-03-10 12:52   ` Krzysztof Kozlowski
2022-03-10  0:33 ` [PATCH 3/6] iio: adc: ti-ads1015: Switch to static const writeable ranges table Marek Vasut
2022-03-10  0:34 ` [PATCH 4/6] iio: adc: ti-ads1015: Deduplicate channel macros Marek Vasut
2022-03-10 14:25   ` Andy Shevchenko
2022-03-10 23:29     ` Marek Vasut
2022-03-11 11:29       ` Andy Shevchenko
2022-03-11 11:33         ` Marek Vasut
2022-03-11 17:03           ` Andy Shevchenko
2022-03-11 18:51             ` Marek Vasut
2022-03-20 13:22               ` Jonathan Cameron [this message]
2022-03-10  0:34 ` [PATCH 5/6] iio: adc: ti-ads1015: Make channel event_spec optional Marek Vasut
2022-03-10  0:34 ` [PATCH 6/6] iio: adc: ti-ads1015: Add TLA2024 support Marek Vasut
2022-03-10 12:51 ` [PATCH 1/6] dt-bindings: iio: adc: ti,ads1015: Add missing ADS1115 compatible string Krzysztof Kozlowski

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=20220320132222.793abcea@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=daniel.baluta@nxp.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=marex@denx.de \
    /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