linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Ardelean <ardeleanalex@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio <linux-iio@vger.kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH 4/9] iio: core: move @trig_readonly from struct iio_dev to struct iio_dev_opaque
Date: Tue, 27 Apr 2021 11:03:06 +0300	[thread overview]
Message-ID: <CA+U=Dsro4QKn1sGBwryDgpuNVuLKLYx7SzsM1q-+mUBrsqaY1w@mail.gmail.com> (raw)
In-Reply-To: <20210426174911.397061-5-jic23@kernel.org>

On Mon, Apr 26, 2021 at 8:50 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> This is only set via the iio_trig_set_immutable() call and later used
> by the IIO core so there is no benefit in drivers being able to access
> it.


Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>


>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>  drivers/iio/industrialio-trigger.c | 10 +++++++---
>  include/linux/iio/iio-opaque.h     |  2 ++
>  include/linux/iio/iio.h            |  2 --
>  3 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
> index b489eeeb0004..b23caa2f2aa1 100644
> --- a/drivers/iio/industrialio-trigger.c
> +++ b/drivers/iio/industrialio-trigger.c
> @@ -117,14 +117,17 @@ EXPORT_SYMBOL(iio_trigger_unregister);
>
>  int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *trig)
>  {
> +       struct iio_dev_opaque *iio_dev_opaque;
> +
>         if (!indio_dev || !trig)
>                 return -EINVAL;
>
> +       iio_dev_opaque = to_iio_dev_opaque(indio_dev);
>         mutex_lock(&indio_dev->mlock);
> -       WARN_ON(indio_dev->trig_readonly);
> +       WARN_ON(iio_dev_opaque->trig_readonly);
>
>         indio_dev->trig = iio_trigger_get(trig);
> -       indio_dev->trig_readonly = true;
> +       iio_dev_opaque->trig_readonly = true;
>         mutex_unlock(&indio_dev->mlock);
>
>         return 0;
> @@ -402,6 +405,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
>                                          size_t len)
>  {
>         struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> +       struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
>         struct iio_trigger *oldtrig = indio_dev->trig;
>         struct iio_trigger *trig;
>         int ret;
> @@ -411,7 +415,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
>                 mutex_unlock(&indio_dev->mlock);
>                 return -EBUSY;
>         }
> -       if (indio_dev->trig_readonly) {
> +       if (iio_dev_opaque->trig_readonly) {
>                 mutex_unlock(&indio_dev->mlock);
>                 return -EPERM;
>         }
> diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h
> index 96dd265103d0..10aa97239117 100644
> --- a/include/linux/iio/iio-opaque.h
> +++ b/include/linux/iio/iio-opaque.h
> @@ -8,6 +8,7 @@
>   * @indio_dev:                 public industrial I/O device information
>   * @id:                        used to identify device internally
>   * @driver_module:             used to make it harder to undercut users
> + * @trig_readonly:             mark the current trigger immutable
>   * @event_interface:           event chrdevs associated with interrupt lines
>   * @attached_buffers:          array of buffers statically attached by the driver
>   * @attached_buffers_cnt:      number of buffers in the array of statically attached buffers
> @@ -30,6 +31,7 @@ struct iio_dev_opaque {
>         struct iio_dev                  indio_dev;
>         int                             id;
>         struct module                   *driver_module;
> +       bool                            trig_readonly;
>         struct iio_event_interface      *event_interface;
>         struct iio_buffer               **attached_buffers;
>         unsigned int                    attached_buffers_cnt;
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index 9e8e1358a032..672f141f74c5 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -503,7 +503,6 @@ struct iio_buffer_setup_ops {
>   * @scan_timestamp:    [INTERN] set if any buffers have requested timestamp
>   * @scan_index_timestamp:[INTERN] cache of the index to the timestamp
>   * @trig:              [INTERN] current device trigger (buffer modes)
> - * @trig_readonly:     [INTERN] mark the current trigger immutable
>   * @pollfunc:          [DRIVER] function run on trigger being received
>   * @pollfunc_event:    [DRIVER] function run on events trigger being received
>   * @channels:          [DRIVER] channel specification structure table
> @@ -535,7 +534,6 @@ struct iio_dev {
>         bool                            scan_timestamp;
>         unsigned                        scan_index_timestamp;
>         struct iio_trigger              *trig;
> -       bool                            trig_readonly;
>         struct iio_poll_func            *pollfunc;
>         struct iio_poll_func            *pollfunc_event;
>
> --
> 2.31.1
>

  reply	other threads:[~2021-04-27  8:03 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 17:49 [PATCH 0/9] iio: Move more things from iio_dev to iio_dev_opaque Jonathan Cameron
2021-04-26 17:49 ` [PATCH 1/9] iio: core: move @id from struct iio_dev to struct iio_dev_opaque Jonathan Cameron
2021-04-27  7:44   ` Alexandru Ardelean
2021-04-27 17:16     ` Jonathan Cameron
2021-05-03 11:42   ` Jonathan Cameron
2021-04-26 17:49 ` [PATCH 2/9] iio: avoid shadowing of variable name in to_iio_dev_opaque() Jonathan Cameron
2021-04-27  7:45   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 3/9] iio: core: move @driver_module from struct iio_dev to struct iio_dev_opaque Jonathan Cameron
2021-04-28  6:55   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 4/9] iio: core: move @trig_readonly " Jonathan Cameron
2021-04-27  8:03   ` Alexandru Ardelean [this message]
2021-04-26 17:49 ` [PATCH 5/9] iio: core: move @scan_index_timestamp " Jonathan Cameron
2021-04-27  8:03   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 6/9] iio: core: move @info_exist_lock " Jonathan Cameron
2021-04-27  8:04   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 7/9] iio: core: move @chrdev from struct iio_dev " Jonathan Cameron
2021-04-27  8:06   ` Alexandru Ardelean
2021-04-27 17:17     ` Jonathan Cameron
2021-04-26 17:49 ` [PATCH 8/9] iio: core: move @flags " Jonathan Cameron
2021-04-27  8:07   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 9/9] iio: core: move @clock_id " Jonathan Cameron
2021-04-27  8:02   ` Alexandru Ardelean
2021-04-27 17:19     ` Jonathan Cameron
2021-04-27  8:08 ` [PATCH 0/9] iio: Move more things from iio_dev to iio_dev_opaque Alexandru Ardelean
2021-04-27 17:12   ` Jonathan Cameron
2021-04-28  6:55     ` Alexandru Ardelean
2021-05-03 11:53       ` 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='CA+U=Dsro4QKn1sGBwryDgpuNVuLKLYx7SzsM1q-+mUBrsqaY1w@mail.gmail.com' \
    --to=ardeleanalex@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@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;
as well as URLs for NNTP newsgroup(s).