diff mbox series

[v5,13/18] iio: expose iio_device_set_clock

Message ID 20191115093412.144922-14-gwendal@chromium.org (mailing list archive)
State New, archived
Headers show
Series cros_ec: Add sensorhub driver and FIFO processing | expand

Commit Message

Gwendal Grignou Nov. 15, 2019, 9:34 a.m. UTC
Some IIO devices may want to override the default (realtime) to another
clock source by default.
It can beneficial when timestamps coming from the hardware or underlying
drivers are already in that format.
It can always be overridden by attribute current_timestamp_clock.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
 drivers/iio/industrialio-core.c | 8 +++++++-
 include/linux/iio/iio.h         | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron Nov. 16, 2019, 11:42 a.m. UTC | #1
On Fri, 15 Nov 2019 01:34:07 -0800
Gwendal Grignou <gwendal@chromium.org> wrote:

> Some IIO devices may want to override the default (realtime) to another
> clock source by default.
> It can beneficial when timestamps coming from the hardware or underlying
> drivers are already in that format.
> It can always be overridden by attribute current_timestamp_clock.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Definitely a step in the right direction.  We may want to also
consider a 'lock' on the value to prevent userspace overriding it, or
to perhaps limit the available choices.

For now though this lets you move forwards

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/industrialio-core.c | 8 +++++++-
>  include/linux/iio/iio.h         | 2 ++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index a46cdf2d8833..92815bdc14ee 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -188,7 +188,12 @@ ssize_t iio_read_const_attr(struct device *dev,
>  }
>  EXPORT_SYMBOL(iio_read_const_attr);
>  
> -static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
> +/**
> + * iio_device_set_clock() - Set current timestamping clock for the device
> + * @indio_dev: IIO device structure containing the device
> + * @clock_id: timestamping clock posix identifier to set.
> + */
> +int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
>  {
>  	int ret;
>  	const struct iio_event_interface *ev_int = indio_dev->event_interface;
> @@ -206,6 +211,7 @@ static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
>  
>  	return 0;
>  }
> +EXPORT_SYMBOL(iio_device_set_clock);
>  
>  /**
>   * iio_get_time_ns() - utility function to get a time stamp for events etc
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index 862ce0019eba..b18f34a8901f 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -627,6 +627,8 @@ static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
>  	return indio_dev->clock_id;
>  }
>  
> +int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id);
> +
>  /**
>   * dev_to_iio_dev() - Get IIO device struct from a device struct
>   * @dev: 		The device embedded in the IIO device
diff mbox series

Patch

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index a46cdf2d8833..92815bdc14ee 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -188,7 +188,12 @@  ssize_t iio_read_const_attr(struct device *dev,
 }
 EXPORT_SYMBOL(iio_read_const_attr);
 
-static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
+/**
+ * iio_device_set_clock() - Set current timestamping clock for the device
+ * @indio_dev: IIO device structure containing the device
+ * @clock_id: timestamping clock posix identifier to set.
+ */
+int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
 {
 	int ret;
 	const struct iio_event_interface *ev_int = indio_dev->event_interface;
@@ -206,6 +211,7 @@  static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
 
 	return 0;
 }
+EXPORT_SYMBOL(iio_device_set_clock);
 
 /**
  * iio_get_time_ns() - utility function to get a time stamp for events etc
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 862ce0019eba..b18f34a8901f 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -627,6 +627,8 @@  static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
 	return indio_dev->clock_id;
 }
 
+int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id);
+
 /**
  * dev_to_iio_dev() - Get IIO device struct from a device struct
  * @dev: 		The device embedded in the IIO device