public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vasileios Amoiridis <vassilisamir@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: lars@metafoo.de, krzysztof.kozlowski@linaro.org,
	nuno.sa@analog.com, u.kleine-koenig@baylibre.com,
	abhashkumarjha123@gmail.com, jstephan@baylibre.com,
	dlechner@baylibre.com, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 6/6] iio: core: mark scan_timestamp as __private
Date: Tue, 3 Dec 2024 23:14:27 +0100	[thread overview]
Message-ID: <Z0-Cw-R1FJZCpnPY@vamoirid-laptop> (raw)
In-Reply-To: <20241130141954.07423793@jic23-huawei>

On Sat, Nov 30, 2024 at 02:19:54PM +0000, Jonathan Cameron wrote:
> On Sat, 30 Nov 2024 01:27:10 +0100
> Vasileios Amoiridis <vassilisamir@gmail.com> wrote:
> 
> > Since there are no more direct accesses to the indio_dev->scan_timestamp
> > value, it can be marked as __private and use the macro ACCESS_PRIVATE()
> > in order to access it. Like this, static checkers will be able to inform
> > in case someone tries to either write to the value, or read its value
> > directly.
> > 
> > Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
> > ---
> >  drivers/iio/industrialio-buffer.c | 2 +-
> >  include/linux/iio/iio.h           | 4 ++--
> >  2 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> > index 8104696cd475..c332741f3cf4 100644
> > --- a/drivers/iio/industrialio-buffer.c
> > +++ b/drivers/iio/industrialio-buffer.c
> > @@ -1137,7 +1137,7 @@ static int iio_enable_buffers(struct iio_dev *indio_dev,
> >  	int ret;
> >  
> >  	indio_dev->active_scan_mask = config->scan_mask;
> > -	indio_dev->scan_timestamp = config->scan_timestamp;
> > +	ACCESS_PRIVATE(indio_dev, scan_timestamp) = config->scan_timestamp;
> >  	indio_dev->scan_bytes = config->scan_bytes;
> >  	iio_dev_opaque->currentmode = config->mode;
> >  
> > diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> > index 5661794d1127..669b4ef1280d 100644
> > --- a/include/linux/iio/iio.h
> > +++ b/include/linux/iio/iio.h
> > @@ -611,7 +611,7 @@ struct iio_dev {
> >  	const unsigned long		*available_scan_masks;
> >  	unsigned int			__private masklength;
> >  	const unsigned long		*active_scan_mask;
> > -	bool				scan_timestamp;
> > +	bool				__private scan_timestamp;
> >  	struct iio_trigger		*trig;
> >  	struct iio_poll_func		*pollfunc;
> >  	struct iio_poll_func		*pollfunc_event;
> > @@ -908,7 +908,7 @@ int iio_active_scan_mask_index(struct iio_dev *indio_dev);
> >   */
> >  static inline bool iio_is_soft_ts_enabled(const struct iio_dev *indio_dev)
> >  {
> > -	return indio_dev->scan_timestamp;
> > +	return ACCESS_PRIVATE(indio_dev, scan_timestamp);
> If we only end up with one use of this (based on feedback on other drivers)
> I'd tempted to deliberately not provide this convenience function and instead
> just use ACCESS_PRIVATE() directly in iio_push_to_buffers_with_timestamp()
> 
> Nice work. Particularly by highlighting some 'odd corners' in drivers that
> probably make no real sense to keep ;)
> 
> Jonathan
> 
> 
> >  }
> >  
> >  ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
>

Hi Jonathan,

Indeed, if it is only one case that this is being used, it wouldn't make
sense to provide an accessor. I wouldn't think of going directly to
touch the drivers without sending this RFC first, so it's good that you
like the solution of optimizing the drivers themselves. I might find
some time before the weekend to spin a v2 to discuss. Thanks for your
time, your comments are always of great help!

Cheers,
Vasilis

      reply	other threads:[~2024-12-03 22:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-30  0:27 [PATCH RFC 0/6] iio: mark scan_timestamp __private Vasileios Amoiridis
2024-11-30  0:27 ` [PATCH RFC 1/6] iio: create accessor for iio_dev->scan_timestamp Vasileios Amoiridis
2024-11-30  0:27 ` [PATCH RFC 2/6] iio: make use of iio_is_soft_ts_enabled() Vasileios Amoiridis
2024-11-30  0:27 ` [PATCH RFC 3/6] iio: adc: dln2-adc: " Vasileios Amoiridis
2024-11-30 14:02   ` Jonathan Cameron
2024-12-03 21:38     ` Vasileios Amoiridis
2024-11-30  0:27 ` [PATCH RFC 4/6] iio: adc: max1363: " Vasileios Amoiridis
2024-11-30 14:09   ` Jonathan Cameron
2024-12-03 22:08     ` Vasileios Amoiridis
2024-11-30  0:27 ` [PATCH RFC 5/6] iio: common: ssp_sensors: " Vasileios Amoiridis
2024-11-30 14:17   ` Jonathan Cameron
2024-12-03 22:10     ` Vasileios Amoiridis
2024-11-30  0:27 ` [PATCH RFC 6/6] iio: core: mark scan_timestamp as __private Vasileios Amoiridis
2024-11-30 14:19   ` Jonathan Cameron
2024-12-03 22:14     ` Vasileios Amoiridis [this message]

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=Z0-Cw-R1FJZCpnPY@vamoirid-laptop \
    --to=vassilisamir@gmail.com \
    --cc=abhashkumarjha123@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=jstephan@baylibre.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=u.kleine-koenig@baylibre.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