1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* The industrial I/O core - generic buffer interfaces.
4 * Copyright (c) 2008 Jonathan Cameron
7 #ifndef _IIO_BUFFER_GENERIC_H_
8 #define _IIO_BUFFER_GENERIC_H_
9 #include <linux/sysfs.h>
10 #include <linux/iio/iio.h>
14 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
17 * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers
18 * @indio_dev: iio_dev structure for device.
20 * @timestamp: timestamp for the sample data
22 * Pushes data to the IIO device's buffers. If timestamps are enabled for the
23 * device the function will store the supplied timestamp as the last element in
24 * the sample data buffer before pushing it to the device buffers. The sample
25 * data buffer needs to be large enough to hold the additional timestamp
26 * (usually the buffer should be indio->scan_bytes bytes large).
28 * Returns 0 on success, a negative error code otherwise.
30 static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
31 void *data, int64_t timestamp)
33 if (indio_dev->scan_timestamp) {
34 size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
35 ((int64_t *)data)[ts_offset] = timestamp;
38 return iio_push_to_buffers(indio_dev, data);
41 bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
42 const unsigned long *mask);
44 int iio_device_attach_buffer(struct iio_dev *indio_dev,
45 struct iio_buffer *buffer);
47 #endif /* _IIO_BUFFER_GENERIC_H_ */