Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Nuno Sa <nuno.sa@analog.com>
Cc: <linux-iio@vger.kernel.org>, Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>
Subject: Re: [PATCH RFC 0/3] iio: add helpers and accessors for active channels and masklength
Date: Sat, 15 Jun 2024 14:18:47 +0100	[thread overview]
Message-ID: <20240615141847.70429abd@jic23-huawei> (raw)
In-Reply-To: <20240612-dev-iio-scan-private-v1-0-7c75c8e3d30b@analog.com>

On Wed, 12 Jun 2024 16:20:47 +0200
Nuno Sa <nuno.sa@analog.com> wrote:

> Hi Jonathan,
> 
> In [1], you suggested for an iterator for the active channels (so driver
> don't directly access masklength). This RFC showcases that iterator and
> goes one step further by giving an accessors for masklength so that
> drivers can read that variable (we have drivers doing that). The
> accessors uses ACCESS_PRIVATE() so it will warn us if some driver
> directly access the variable making it more difficult to mess with it
> (like changing it's value) without being noticed during review (or the
> auto builders).
> 
> Anyways, before jumping in changing all the drivers using this, I guess
> the questions are:
> 
> 1) Is the iterator useful enough to add one (kind of like it and save a
> line of code :))?
> 2) Do we care about going with the work of marking masklength private? 
> 
> If we go ahead the plan would be:
> 
> 1) Add the helpers macros;
> 2) Convert all drivers that directly access 'masklength';
> 3) Annotate it as private.
> 
> [1]: https://lore.kernel.org/linux-iio/20240428142343.5067c898@jic23-huawei/

Cute. I'd not seen the __private bit before.

Looks good to me.  I think we should spin it a little differently.
1. Add macro and a dummy 

#define iio_dev_mask_length(indio_dev) (indio_dev)->mask_length

2. Convert drivers

3. What you have + the ACCESS_PRIVATE change.

that accessor still lets people change it rather than making
it strictly private.   I wonder if we need a little more complicated

static inline int iio_dev_mask_length(struct iio_dev *indio_dev)
{
	return ACCESS_PRIVATE()...
}

or can just review for anyone doing iio_dev_mask_length(indio_dev) = 4;




> 
> ---
> Nuno Sa (3):
>       iio: core: add new helper to iterate active channels
>       iio: imu: adis16475: make use of iio_for_each_active_channel()
>       iio: core annotate masklength as private
> 
>  drivers/iio/imu/adis16475.c | 3 +--
>  include/linux/iio/iio.h     | 8 +++++++-
>  2 files changed, 8 insertions(+), 3 deletions(-)
> ---
> base-commit: cc1ce839526a65620778617da0b022bd88e8a139
> change-id: 20240612-dev-iio-scan-private-86f4a0fd288f
> --
> 
> Thanks!
> - Nuno Sá
> 


  parent reply	other threads:[~2024-06-15 13:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12 14:20 [PATCH RFC 0/3] iio: add helpers and accessors for active channels and masklength Nuno Sa
2024-06-12 14:20 ` [PATCH RFC 1/3] iio: core: add new helper to iterate active channels Nuno Sa
2024-06-12 14:20 ` [PATCH RFC 2/3] iio: imu: adis16475: make use of iio_for_each_active_channel() Nuno Sa
2024-06-12 14:20 ` [PATCH RFC 3/3] iio: core annotate masklength as private Nuno Sa
2024-06-15 13:18 ` Jonathan Cameron [this message]
2024-06-17  6:34   ` [PATCH RFC 0/3] iio: add helpers and accessors for active channels and masklength Nuno Sá

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=20240615141847.70429abd@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /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