Skip to content

Commit 69f0793

Browse files
gwendalcrEnric Balletbo i Serra
authored andcommitted
iio: expose iio_device_set_clock
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 <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent d9452ad commit 69f0793

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

drivers/iio/industrialio-core.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ ssize_t iio_read_const_attr(struct device *dev,
189189
}
190190
EXPORT_SYMBOL(iio_read_const_attr);
191191

192-
static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
192+
/**
193+
* iio_device_set_clock() - Set current timestamping clock for the device
194+
* @indio_dev: IIO device structure containing the device
195+
* @clock_id: timestamping clock posix identifier to set.
196+
*/
197+
int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
193198
{
194199
int ret;
195200
const struct iio_event_interface *ev_int = indio_dev->event_interface;
@@ -207,6 +212,7 @@ static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
207212

208213
return 0;
209214
}
215+
EXPORT_SYMBOL(iio_device_set_clock);
210216

211217
/**
212218
* iio_get_time_ns() - utility function to get a time stamp for events etc

include/linux/iio/iio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
627627
return indio_dev->clock_id;
628628
}
629629

630+
int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id);
631+
630632
/**
631633
* dev_to_iio_dev() - Get IIO device struct from a device struct
632634
* @dev: The device embedded in the IIO device

0 commit comments

Comments
 (0)