diff mbox series

[15/20] iio: buffer: Make timestamp s64 in iio_push_to_buffers_with_timestamp()

Message ID 20241215182912.481706-16-jic23@kernel.org (mailing list archive)
State New
Headers show
Series IIO: Tidying up timestamp alignment markings. | expand

Commit Message

Jonathan Cameron Dec. 15, 2024, 6:29 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This is a bit of a corner case for selecting between the in kernel types
and standard c integer types we tend to prefer for userspace interfaces.
The interface is entirely within the kernel but in many cases the data
ultimately ends up in userspace (via some time in a kfifo).  On balance
the value passed is almost always an s64, so standardize on that.
Main reason to change this is that it has led to some inconsistency in
the storage type used.  The majority use aligned_s64 rather than
int64_t __aligned(8) and this will ensure there is one obvious choice.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 include/linux/iio/buffer.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Andy Shevchenko Dec. 15, 2024, 9:12 p.m. UTC | #1
On Sun, Dec 15, 2024 at 06:29:06PM +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This is a bit of a corner case for selecting between the in kernel types
> and standard c integer types we tend to prefer for userspace interfaces.

s/c/C/

> The interface is entirely within the kernel but in many cases the data
> ultimately ends up in userspace (via some time in a kfifo).  On balance
> the value passed is almost always an s64, so standardize on that.
> Main reason to change this is that it has led to some inconsistency in
> the storage type used.  The majority use aligned_s64 rather than
> int64_t __aligned(8) and this will ensure there is one obvious choice.

...

>  static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
> -	void *data, int64_t timestamp)
> +	void *data, s64 timestamp)

Hmm... Is it the indentation used for other static inline definitions there?
Otherwise I would fix it to follow standard pattern (use same column as the
first argument).

...

>  	if (indio_dev->scan_timestamp) {
> -		size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
> -		((int64_t *)data)[ts_offset] = timestamp;
> +		size_t ts_offset = indio_dev->scan_bytes / sizeof(s64) - 1;

sizeof(timestamp) ?

> +		((s64 *)data)[ts_offset] = timestamp;
>  	}
diff mbox series

Patch

diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 418b1307d3f2..88699a341669 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -35,11 +35,11 @@  int iio_pop_from_buffer(struct iio_buffer *buffer, void *data);
  * Returns 0 on success, a negative error code otherwise.
  */
 static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
-	void *data, int64_t timestamp)
+	void *data, s64 timestamp)
 {
 	if (indio_dev->scan_timestamp) {
-		size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
-		((int64_t *)data)[ts_offset] = timestamp;
+		size_t ts_offset = indio_dev->scan_bytes / sizeof(s64) - 1;
+		((s64 *)data)[ts_offset] = timestamp;
 	}
 
 	return iio_push_to_buffers(indio_dev, data);