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 9/9] iio: core: move @clock_id from struct iio_dev to struct iio_dev_opaque
Date: Tue, 27 Apr 2021 11:02:02 +0300	[thread overview]
Message-ID: <CA+U=DsrsFhH65HkdNSTFLXF3-rbpEYkZ5MvoXDmuSeniHampXA@mail.gmail.com> (raw)
In-Reply-To: <20210426174911.397061-10-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>
>
> There is already an acessor function used to access it, making this
> move straight forward.

Right now the iio_device_get_clock() helper is only being used in the
Chrome EC core sensor driver.
Maybe later if that can be reworked without this helper, then it could
be made private to IIO core.
Though, chances are some other driver may come along later and ask for
it to be public again.

Anyway.

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

>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>  drivers/iio/industrialio-core.c | 14 +++++++++++++-
>  include/linux/iio/iio-opaque.h  |  2 ++
>  include/linux/iio/iio.h         | 12 +-----------
>  3 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 4a4c02fea152..efb4cf91c9e4 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -271,13 +271,25 @@ int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
>                 mutex_unlock(&indio_dev->mlock);
>                 return -EBUSY;
>         }
> -       indio_dev->clock_id = clock_id;
> +       iio_dev_opaque->clock_id = clock_id;
>         mutex_unlock(&indio_dev->mlock);
>
>         return 0;
>  }
>  EXPORT_SYMBOL(iio_device_set_clock);
>
> +/**
> + * iio_device_get_clock() - Retrieve current timestamping clock for the device
> + * @indio_dev: IIO device structure containing the device
> + */
> +clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
> +{
> +       struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
> +
> +       return iio_dev_opaque->clock_id;
> +}
> +EXPORT_SYMBOL(iio_device_get_clock);
> +
>  /**
>   * iio_get_time_ns() - utility function to get a time stamp for events etc
>   * @indio_dev: device
> diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h
> index d7c3036861ac..c9504e9da571 100644
> --- a/include/linux/iio/iio-opaque.h
> +++ b/include/linux/iio/iio-opaque.h
> @@ -24,6 +24,7 @@
>   * @legacy_scan_el_group:      attribute group for legacy scan elements attribute group
>   * @legacy_buffer_group:       attribute group for legacy buffer attributes group
>   * @scan_index_timestamp:      cache of the index to the timestamp
> + * @clock_id:                  timestamping clock posix identifier
>   * @chrdev:                    associated character device
>   * @flags:                     file ops related flags including busy flag.
>   * @debugfs_dentry:            device specific debugfs dentry
> @@ -51,6 +52,7 @@ struct iio_dev_opaque {
>         struct attribute_group          legacy_buffer_group;
>
>         unsigned int                    scan_index_timestamp;
> +       clockid_t                       clock_id;
>         struct cdev                     chrdev;
>         unsigned long                   flags;
>
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index ed0537015eee..5606a3f4c4cb 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -509,7 +509,6 @@ struct iio_buffer_setup_ops {
>   * @name:              [DRIVER] name of the device.
>   * @label:              [DRIVER] unique name to identify which device this is
>   * @info:              [DRIVER] callbacks and constant info from driver
> - * @clock_id:          [INTERN] timestamping clock posix identifier
>   * @setup_ops:         [DRIVER] callbacks to call before and after buffer
>   *                     enable/disable
>   * @priv:              [DRIVER] reference to driver's private information
> @@ -538,7 +537,6 @@ struct iio_dev {
>         const char                      *name;
>         const char                      *label;
>         const struct iio_info           *info;
> -       clockid_t                       clock_id;
>         const struct iio_buffer_setup_ops       *setup_ops;
>
>         void                            *priv;
> @@ -589,15 +587,7 @@ static inline void iio_device_put(struct iio_dev *indio_dev)
>                 put_device(&indio_dev->dev);
>  }
>
> -/**
> - * iio_device_get_clock() - Retrieve current timestamping clock for the device
> - * @indio_dev: IIO device structure containing the device
> - */
> -static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
> -{
> -       return indio_dev->clock_id;
> -}
> -
> +clockid_t iio_device_get_clock(const struct iio_dev *indio_dev);
>  int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id);
>
>  /**
> --
> 2.31.1
>

  reply	other threads:[~2021-04-27  8:02 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
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 [this message]
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=DsrsFhH65HkdNSTFLXF3-rbpEYkZ5MvoXDmuSeniHampXA@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).