Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: add IIO_DECLARE_QUATERNION() macro

Add a new IIO_DECLARE_QUATERNION() macro that is used to declare the
field in an IIO buffer struct that contains a quaternion vector.

Quaternions are currently the only IIO data type that uses the .repeat
feature of struct iio_scan_type. This has an implicit rule that the
element in the buffer must be aligned to the entire size of the repeated
element. This macro will make that requirement explicit. Since this is
the only user, we just call the macro IIO_DECLARE_QUATERNION() instead
of something more generic.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
56bd57e7 36f6d4db

+12
+12
include/linux/iio/iio.h
··· 931 931 #define IIO_DECLARE_DMA_BUFFER_WITH_TS(type, name, count) \ 932 932 __IIO_DECLARE_BUFFER_WITH_TS(type, name, count) __aligned(IIO_DMA_MINALIGN) 933 933 934 + /** 935 + * IIO_DECLARE_QUATERNION() - Declare a quaternion element 936 + * @type: element type of the individual vectors 937 + * @name: identifier name 938 + * 939 + * Quaternions are a vector composed of 4 elements (W, X, Y, Z). Use this macro 940 + * to declare a quaternion element in a struct to ensure proper alignment in 941 + * an IIO buffer. 942 + */ 943 + #define IIO_DECLARE_QUATERNION(type, name) \ 944 + type name[4] __aligned(sizeof(type) * 4) 945 + 934 946 struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv); 935 947 936 948 /* The information at the returned address is guaranteed to be cacheline aligned */