Skip to contentSkip to conversation

iio: accel: replace s64 __aligned(8) with aligned_s64

PATCH In review Jonathan Cameron 5 participants 7 messages Oct 20, 2024 – Oct 23, 2024

Subsystems (4)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

PATCH 1/1 iio: accel: replace s64 __aligned(8) with aligned_s64

From: Jonathan Cameron <[email protected]>

e4ca0e59c394 ("types: Complement the aligned types with signed 64-bit one") introduced aligned_s64. Use it for all IIO accelerometer drivers.

---

I debated whether to split this up by driver by the time we've done all IIO drivers that will be a very large number of trivial patches.

The changes are minor enough that they shouldn't present much of a backporting challenge if needed for future fixes etc.

I'm find splitting them up if people prefer.
Next on my list is to look at adding runtime checks that the buffers containing these timestamps are big enough but I want this out of the way first.

Cc Andy Shevchenko <[email protected]>
---
 drivers/iio/accel/bma180.c          | 3 ++-
 drivers/iio/accel/bma220_spi.c      | 1 +
 drivers/iio/accel/bma400_core.c     | 2 +-
 drivers/iio/accel/bmc150-accel.h    | 3 ++-
 drivers/iio/accel/fxls8962af-core.c | 3 ++-
 drivers/iio/accel/kionix-kx022a.c   | 3 ++-
 drivers/iio/accel/kxcjk-1013.c      | 3 ++-
 drivers/iio/accel/kxsd9.c           | 3 ++-
 drivers/iio/accel/mma7455_core.c    | 3 ++-
 drivers/iio/accel/mma8452.c         | 3 ++-
 drivers/iio/accel/msa311.c          | 3 ++-
 drivers/iio/accel/mxc4005.c         | 3 ++-
 drivers/iio/accel/stk8312.c         | 3 ++-
 drivers/iio/accel/stk8ba50.c        | 3 ++-
 14 files changed, 26 insertions(+), 13 deletions(-)
drivers/iio/accel/bma180.c +2 -1
index 1fe20eb78a0b..41a517e1630f 100644
@@ -21,6 +21,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/types.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/buffer.h>
@@ -144,7 +145,7 @@ struct bma180_data {
 	/* Ensure timestamp is naturally aligned */
 	struct {
 		s16 chan[4];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
 	} scan;
 };
 
drivers/iio/accel/bma220_spi.c +1 -0
index d33218e40c79..2d27a592a61e 100644
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/types.h>
 #include <linux/spi/spi.h>
 
 #include <linux/iio/buffer.h>
drivers/iio/accel/bma400_core.c +1 -1
index d96840d135c6..eb32c963dfc8 100644
@@ -115,7 +115,7 @@ struct bma400_data {
 	struct {
 		__le16 buff[3];
 		u8 temperature;
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} buffer __aligned(IIO_DMA_MINALIGN);
 	__le16 status;
 	__be16 duration;
drivers/iio/accel/bmc150-accel.h +2 -1
index 7775c5edaeef..7a7baf52e595 100644
@@ -6,6 +6,7 @@
 #include <linux/iio/iio.h>
 #include <linux/mutex.h>
 #include <linux/regulator/consumer.h>
+#include <linux/types.h>
 #include <linux/workqueue.h>
 
 struct regmap;
@@ -69,7 +70,7 @@ struct bmc150_accel_data {
 	 */
 	struct {
 		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} scan;
 	u8 bw_bits;
 	u32 slope_dur;
drivers/iio/accel/fxls8962af-core.c +2 -1
index 37f33c29fb4b..ab427f3461db 100644
@@ -22,6 +22,7 @@
 #include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
+#include <linux/types.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/events.h>
@@ -163,7 +164,7 @@ struct fxls8962af_data {
 	const struct fxls8962af_chip_info *chip_info;
 	struct {
 		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} scan;
 	int64_t timestamp, old_timestamp;	/* Only used in hw fifo mode. */
 	struct iio_mount_matrix orientation;
drivers/iio/accel/kionix-kx022a.c +2 -1
index 53d59a04ae15..32387819995d 100644
@@ -16,6 +16,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/string_choices.h>
+#include <linux/types.h>
 #include <linux/units.h>
 
 #include <linux/iio/iio.h>
@@ -292,7 +293,7 @@ struct kx022a_data {
 	__le16 buffer[8] __aligned(IIO_DMA_MINALIGN);
 	struct {
 		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} scan;
 };
 
drivers/iio/accel/kxcjk-1013.c +2 -1
index b76df8816323..bbf65fc97b08 100644
@@ -11,6 +11,7 @@
 #include <linux/bitops.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/types.h>
 #include <linux/acpi.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
@@ -250,7 +251,7 @@ struct kxcjk1013_data {
 	/* Ensure timestamp naturally aligned */
 	struct {
 		s16 chans[AXIS_MAX];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
 	} scan;
 	u8 odr_bits;
 	u8 range;
drivers/iio/accel/kxsd9.c +2 -1
index 70dfd6e354db..6d2b0a22e550 100644
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
 #include <linux/slab.h>
+#include <linux/types.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/bitops.h>
@@ -215,7 +216,7 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p)
 	 */
 	struct {
 		__be16 chan[4];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} hw_values;
 	int ret;
 
drivers/iio/accel/mma7455_core.c +2 -1
index a34195b3215d..50f7ac1845c6 100644
@@ -19,6 +19,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/types.h>
 
 #include "mma7455.h"
 
@@ -58,7 +59,7 @@ struct mma7455_data {
 	 */
 	struct {
 		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} scan;
 };
 
drivers/iio/accel/mma8452.c +2 -1
index 62e6369e2269..de4525b30edc 100644
@@ -32,6 +32,7 @@
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
+#include <linux/types.h>
 
 #define MMA8452_STATUS				0x00
 #define  MMA8452_STATUS_DRDY			(BIT(2) | BIT(1) | BIT(0))
@@ -115,7 +116,7 @@ struct mma8452_data {
 	/* Ensure correct alignment of time stamp when present */
 	struct {
 		__be16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} buffer;
 };
 
drivers/iio/accel/msa311.c +2 -1
index 57025354c7cd..e7fb860f3233 100644
@@ -34,6 +34,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/string_choices.h>
+#include <linux/types.h>
 #include <linux/units.h>
 
 #include <linux/iio/buffer.h>
@@ -893,7 +894,7 @@ static irqreturn_t msa311_buffer_thread(int irq, void *p)
 	__le16 axis;
 	struct {
 		__le16 channels[MSA311_SI_Z + 1];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} buf;
 
 	memset(&buf, 0, sizeof(buf));
drivers/iio/accel/mxc4005.c +2 -1
index fc54a2a4693c..cb5c4e354fc0 100644
@@ -11,6 +11,7 @@
 #include <linux/iio/iio.h>
 #include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
+#include <linux/types.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/buffer.h>
@@ -69,7 +70,7 @@ struct mxc4005_data {
 	/* Ensure timestamp is naturally aligned */
 	struct {
 		__be16 chans[3];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
 	} scan;
 	bool trigger_enabled;
 	unsigned int control;
drivers/iio/accel/stk8312.c +2 -1
index abead190254b..471c154c3631 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/delay.h>
+#include <linux/types.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -105,7 +106,7 @@ struct stk8312_data {
 	/* Ensure timestamp is naturally aligned */
 	struct {
 		s8 chans[3];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
 	} scan;
 };
 
drivers/iio/accel/stk8ba50.c +2 -1
index a32a77324e92..cab592a68622 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/types.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -94,7 +95,7 @@ struct stk8ba50_data {
 	/* Ensure timestamp is naturally aligned */
 	struct {
 		s16 chans[3];
-		s64 timetamp __aligned(8);
+		aligned_s64 timetamp;
 	} scan;
 };
 
Signature · 1 line
2.46.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

e4ca0e59c394 ("types: Complement the aligned types with signed 64-bit one") introduced aligned_s64. Use it for all IIO accelerometer drivers.

---

I debated whether to split this up by driver by the time we've done all IIO drivers that will be a very large number of trivial patches.

Quoted 7 lines

The changes are minor enough that they shouldn't present much of a backporting challenge if needed for future fixes etc.

I'm find splitting them up if people prefer.
Next on my list is to look at adding runtime checks that the buffers containing these timestamps are big enough but I want this out of the way first.

I agree on all your points.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#2 lore raw
Quoted 16 lines · On Mon, 21 Oct 2024 10:10:25 +0300 Andy Shevchenko…
Quoted 15 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

e4ca0e59c394 ("types: Complement the aligned types with signed 64-bit one") introduced aligned_s64. Use it for all IIO accelerometer drivers.

---

I debated whether to split this up by driver by the time we've done all IIO drivers that will be a very large number of trivial patches.

The changes are minor enough that they shouldn't present much of a backporting challenge if needed for future fixes etc.

Quoted 9 lines
Quoted 4 lines

I'm find splitting them up if people prefer.
Next on my list is to look at adding runtime checks that the buffers containing these timestamps are big enough but I want this out of the way first.

I agree on all your points.

Applied given it's so trivial and 3 people already reviewed!

Thanks,

Jonathan

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Jonathan Cameron
Quoted 12 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

e4ca0e59c394 ("types: Complement the aligned types with signed 64-bit one") introduced aligned_s64. Use it for all IIO accelerometer drivers.

---

I debated whether to split this up by driver by the time we've done all IIO drivers that will be a very large number of trivial patches.

Quoted 7 lines

The changes are minor enough that they shouldn't present much of a backporting challenge if needed for future fixes etc.

I'm find splitting them up if people prefer.
Next on my list is to look at adding runtime checks that the buffers containing these timestamps are big enough but I want this out of the way first.

Makes sense to me.

Quoted 5 lines
Cc Andy Shevchenko <[email protected]>
---
  drivers/iio/accel/kionix-kx022a.c   | 3 ++-
  drivers/iio/accel/kxcjk-1013.c      | 3 ++-
  drivers/iio/accel/kxsd9.c           | 3 ++-

For the Kionix/ROHM seensors,

Yours,
-- Matti

#4 lore raw
In reply to Jonathan Cameron
Quoted 15 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

e4ca0e59c394 ("types: Complement the aligned types with signed 64-bit one") introduced aligned_s64. Use it for all IIO accelerometer drivers.

---

I debated whether to split this up by driver by the time we've done all IIO drivers that will be a very large number of trivial patches.

The changes are minor enough that they shouldn't present much of a backporting challenge if needed for future fixes etc.

Quoted 7 lines

I'm find splitting them up if people prefer.
Next on my list is to look at adding runtime checks that the buffers containing these timestamps are big enough but I want this out of the way first.

Cc Andy Shevchenko <[email protected]>

---

LGTM,

Reviewed-by; Nuno Sa <[email protected]>

Quoted 298 lines

 drivers/iio/accel/bma180.c          | 3 ++-
 drivers/iio/accel/bma220_spi.c      | 1 +
 drivers/iio/accel/bma400_core.c     | 2 +-
 drivers/iio/accel/bmc150-accel.h    | 3 ++-
 drivers/iio/accel/fxls8962af-core.c | 3 ++-
 drivers/iio/accel/kionix-kx022a.c   | 3 ++-
 drivers/iio/accel/kxcjk-1013.c      | 3 ++-
 drivers/iio/accel/kxsd9.c           | 3 ++-
 drivers/iio/accel/mma7455_core.c    | 3 ++-
 drivers/iio/accel/mma8452.c         | 3 ++-
 drivers/iio/accel/msa311.c          | 3 ++-
 drivers/iio/accel/mxc4005.c         | 3 ++-
 drivers/iio/accel/stk8312.c         | 3 ++-
 drivers/iio/accel/stk8ba50.c        | 3 ++-

 14 files changed, 26 insertions(+), 13 deletions(-)
drivers/iio/accel/bma180.c +2 -1
index 1fe20eb78a0b..41a517e1630f 100644
@@ -21,6 +21,7 @@
  #include <linux/regulator/consumer.h>
  #include <linux/slab.h>
  #include <linux/string.h>
+#include <linux/types.h>
  #include <linux/iio/iio.h>
  #include <linux/iio/sysfs.h>
  #include <linux/iio/buffer.h>
@@ -144,7 +145,7 @@ struct bma180_data {
  	/* Ensure timestamp is naturally aligned */
  	struct {
  		s16 chan[4];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
  	} scan;
  };

drivers/iio/accel/bma220_spi.c +1 -0
index d33218e40c79..2d27a592a61e 100644
@@ -9,6 +9,7 @@
  #include <linux/kernel.h>
  #include <linux/mod_devicetable.h>
  #include <linux/module.h>
+#include <linux/types.h>
  #include <linux/spi/spi.h>


 #include <linux/iio/buffer.h>

drivers/iio/accel/bma400_core.c +1 -1
index d96840d135c6..eb32c963dfc8 100644
@@ -115,7 +115,7 @@ struct bma400_data {
  	struct {
  		__le16 buff[3];
  		u8 temperature;
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} buffer __aligned(IIO_DMA_MINALIGN);
  	__le16 status;
  	__be16 duration;
drivers/iio/accel/bmc150- renamed from drivers/iio/accel/bmc150-accel.h +0 -0

accel.h
index 7775c5edaeef..7a7baf52e595 100644

drivers/iio/accel/bmc150-accel.h +1 -0
@@ -6,6 +6,7 @@
  #include <linux/iio/iio.h>
  #include <linux/mutex.h>
  #include <linux/regulator/consumer.h>
+#include <linux/types.h>
  #include <linux/workqueue.h>


 struct regmap;

drivers/iio/accel/bmc150-accel.h +1 -1
@@ -69,7 +70,7 @@ struct bmc150_accel_data {
  	 */
  	struct {
  		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} scan;
  	u8 bw_bits;
  	u32 slope_dur;
drivers/iio/accel/fxls8962af-core.c +1 -0
index 37f33c29fb4b..ab427f3461db 100644
@@ -22,6 +22,7 @@
  #include <linux/property.h>
  #include <linux/regulator/consumer.h>
  #include <linux/regmap.h>
+#include <linux/types.h>


 #include <linux/iio/buffer.h>
 #include <linux/iio/events.h>

drivers/iio/accel/fxls8962af-core.c +1 -1
@@ -163,7 +164,7 @@ struct fxls8962af_data {
  	const struct fxls8962af_chip_info *chip_info;
  	struct {
  		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} scan;

  int64_t timestamp, old_timestamp; /* Only used in hw fifo mode.
*/
  struct iio_mount_matrix orientation;

drivers/iio/accel/kionix- renamed from drivers/iio/accel/kionix-kx022a.c +0 -0

kx022a.c
index 53d59a04ae15..32387819995d 100644

drivers/iio/accel/kionix-kx022a.c +1 -0
@@ -16,6 +16,7 @@
  #include <linux/regulator/consumer.h>
  #include <linux/slab.h>
  #include <linux/string_choices.h>
+#include <linux/types.h>
  #include <linux/units.h>


 #include <linux/iio/iio.h>

drivers/iio/accel/kionix-kx022a.c +1 -1
@@ -292,7 +293,7 @@ struct kx022a_data {
  	__le16 buffer[8] __aligned(IIO_DMA_MINALIGN);
  	struct {
  		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} scan;
  };

drivers/iio/accel/kxcjk-1013.c +2 -1
index b76df8816323..bbf65fc97b08 100644
@@ -11,6 +11,7 @@
  #include <linux/bitops.h>
  #include <linux/slab.h>
  #include <linux/string.h>
+#include <linux/types.h>
  #include <linux/acpi.h>
  #include <linux/pm.h>
  #include <linux/pm_runtime.h>
@@ -250,7 +251,7 @@ struct kxcjk1013_data {
  	/* Ensure timestamp naturally aligned */
  	struct {
  		s16 chans[AXIS_MAX];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
  	} scan;
  	u8 odr_bits;
  	u8 range;
drivers/iio/accel/kxsd9.c +2 -1
index 70dfd6e354db..6d2b0a22e550 100644
@@ -15,6 +15,7 @@
  #include <linux/kernel.h>
  #include <linux/sysfs.h>
  #include <linux/slab.h>
+#include <linux/types.h>
  #include <linux/module.h>
  #include <linux/regmap.h>
  #include <linux/bitops.h>
@@ -215,7 +216,7 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p)
  	 */
  	struct {
  		__be16 chan[4];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} hw_values;
  	int ret;

drivers/iio/accel/mma7455_core.c +1 -0
index a34195b3215d..50f7ac1845c6 100644
@@ -19,6 +19,7 @@
  #include <linux/iio/triggered_buffer.h>
  #include <linux/module.h>
  #include <linux/regmap.h>
+#include <linux/types.h>


 #include "mma7455.h"

drivers/iio/accel/mma7455_core.c +1 -1
@@ -58,7 +59,7 @@ struct mma7455_data {
  	 */
  	struct {
  		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} scan;
  };

drivers/iio/accel/mma8452.c +1 -0
index 62e6369e2269..de4525b30edc 100644
@@ -32,6 +32,7 @@
  #include <linux/delay.h>
  #include <linux/pm_runtime.h>
  #include <linux/regulator/consumer.h>
+#include <linux/types.h>


 #define MMA8452_STATUS 0x00
 #define  MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))

drivers/iio/accel/mma8452.c +1 -1
@@ -115,7 +116,7 @@ struct mma8452_data {
  	/* Ensure correct alignment of time stamp when present */
  	struct {
  		__be16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} buffer;
  };

drivers/iio/accel/msa311.c +1 -0
index 57025354c7cd..e7fb860f3233 100644
@@ -34,6 +34,7 @@
  #include <linux/pm_runtime.h>
  #include <linux/regmap.h>
  #include <linux/string_choices.h>
+#include <linux/types.h>
  #include <linux/units.h>


 #include <linux/iio/buffer.h>

drivers/iio/accel/msa311.c +1 -1
@@ -893,7 +894,7 @@ static irqreturn_t msa311_buffer_thread(int irq, void *p)
  	__le16 axis;
  	struct {
  		__le16 channels[MSA311_SI_Z + 1];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} buf;


  memset(&buf, 0, sizeof(buf));

drivers/iio/accel/mxc4005.c +2 -1
index fc54a2a4693c..cb5c4e354fc0 100644
@@ -11,6 +11,7 @@
  #include <linux/iio/iio.h>
  #include <linux/mod_devicetable.h>
  #include <linux/regmap.h>
+#include <linux/types.h>
  #include <linux/iio/sysfs.h>
  #include <linux/iio/trigger.h>
  #include <linux/iio/buffer.h>
@@ -69,7 +70,7 @@ struct mxc4005_data {
  	/* Ensure timestamp is naturally aligned */
  	struct {
  		__be16 chans[3];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
  	} scan;
  	bool trigger_enabled;
  	unsigned int control;
drivers/iio/accel/stk8312.c +2 -1
index abead190254b..471c154c3631 100644
@@ -12,6 +12,7 @@
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/delay.h>
+#include <linux/types.h>
  #include <linux/iio/buffer.h>
  #include <linux/iio/iio.h>
  #include <linux/iio/sysfs.h>
@@ -105,7 +106,7 @@ struct stk8312_data {
  	/* Ensure timestamp is naturally aligned */
  	struct {
  		s8 chans[3];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
  	} scan;
  };

drivers/iio/accel/stk8ba50.c +2 -1
index a32a77324e92..cab592a68622 100644
@@ -12,6 +12,7 @@
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/mod_devicetable.h>
+#include <linux/types.h>
  #include <linux/iio/buffer.h>
  #include <linux/iio/iio.h>
  #include <linux/iio/sysfs.h>
@@ -94,7 +95,7 @@ struct stk8ba50_data {
  	/* Ensure timestamp is naturally aligned */
  	struct {
  		s16 chans[3];
-		s64 timetamp __aligned(8);
+		aligned_s64 timetamp;
  	} scan;
  };

Reviewed-by Nuno Sa on v1 1/1
#5 lore raw
In reply to Jonathan Cameron
Quoted 9 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

e4ca0e59c394 ("types: Complement the aligned types with signed 64-bit one") introduced aligned_s64. Use it for all IIO accelerometer drivers.

---

Giving a proper tag this time :)

Quoted 311 lines

I debated whether to split this up by driver by the time we've done all IIO drivers that will be a very large number of trivial patches.

The changes are minor enough that they shouldn't present much of a backporting challenge if needed for future fixes etc.

I'm find splitting them up if people prefer.
Next on my list is to look at adding runtime checks that the buffers containing these timestamps are big enough but I want this out of the way first.

Cc Andy Shevchenko <[email protected]>

---
 drivers/iio/accel/bma180.c          | 3 ++-
 drivers/iio/accel/bma220_spi.c      | 1 +
 drivers/iio/accel/bma400_core.c     | 2 +-
 drivers/iio/accel/bmc150-accel.h    | 3 ++-
 drivers/iio/accel/fxls8962af-core.c | 3 ++-
 drivers/iio/accel/kionix-kx022a.c   | 3 ++-
 drivers/iio/accel/kxcjk-1013.c      | 3 ++-
 drivers/iio/accel/kxsd9.c           | 3 ++-
 drivers/iio/accel/mma7455_core.c    | 3 ++-
 drivers/iio/accel/mma8452.c         | 3 ++-
 drivers/iio/accel/msa311.c          | 3 ++-
 drivers/iio/accel/mxc4005.c         | 3 ++-
 drivers/iio/accel/stk8312.c         | 3 ++-
 drivers/iio/accel/stk8ba50.c        | 3 ++-

 14 files changed, 26 insertions(+), 13 deletions(-)
drivers/iio/accel/bma180.c +2 -1
index 1fe20eb78a0b..41a517e1630f 100644
@@ -21,6 +21,7 @@
  #include <linux/regulator/consumer.h>
  #include <linux/slab.h>
  #include <linux/string.h>
+#include <linux/types.h>
  #include <linux/iio/iio.h>
  #include <linux/iio/sysfs.h>
  #include <linux/iio/buffer.h>
@@ -144,7 +145,7 @@ struct bma180_data {
  	/* Ensure timestamp is naturally aligned */
  	struct {
  		s16 chan[4];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
  	} scan;
  };

drivers/iio/accel/bma220_spi.c +1 -0
index d33218e40c79..2d27a592a61e 100644
@@ -9,6 +9,7 @@
  #include <linux/kernel.h>
  #include <linux/mod_devicetable.h>
  #include <linux/module.h>
+#include <linux/types.h>
  #include <linux/spi/spi.h>


 #include <linux/iio/buffer.h>

drivers/iio/accel/bma400_core.c +1 -1
index d96840d135c6..eb32c963dfc8 100644
@@ -115,7 +115,7 @@ struct bma400_data {
  	struct {
  		__le16 buff[3];
  		u8 temperature;
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} buffer __aligned(IIO_DMA_MINALIGN);
  	__le16 status;
  	__be16 duration;
drivers/iio/accel/bmc150- renamed from drivers/iio/accel/bmc150-accel.h +0 -0

accel.h
index 7775c5edaeef..7a7baf52e595 100644

drivers/iio/accel/bmc150-accel.h +1 -0
@@ -6,6 +6,7 @@
  #include <linux/iio/iio.h>
  #include <linux/mutex.h>
  #include <linux/regulator/consumer.h>
+#include <linux/types.h>
  #include <linux/workqueue.h>


 struct regmap;

drivers/iio/accel/bmc150-accel.h +1 -1
@@ -69,7 +70,7 @@ struct bmc150_accel_data {
  	 */
  	struct {
  		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} scan;
  	u8 bw_bits;
  	u32 slope_dur;
drivers/iio/accel/fxls8962af-core.c +1 -0
index 37f33c29fb4b..ab427f3461db 100644
@@ -22,6 +22,7 @@
  #include <linux/property.h>
  #include <linux/regulator/consumer.h>
  #include <linux/regmap.h>
+#include <linux/types.h>


 #include <linux/iio/buffer.h>
 #include <linux/iio/events.h>

drivers/iio/accel/fxls8962af-core.c +1 -1
@@ -163,7 +164,7 @@ struct fxls8962af_data {
  	const struct fxls8962af_chip_info *chip_info;
  	struct {
  		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} scan;

  int64_t timestamp, old_timestamp; /* Only used in hw fifo mode.
*/
  struct iio_mount_matrix orientation;

drivers/iio/accel/kionix- renamed from drivers/iio/accel/kionix-kx022a.c +0 -0

kx022a.c
index 53d59a04ae15..32387819995d 100644

drivers/iio/accel/kionix-kx022a.c +1 -0
@@ -16,6 +16,7 @@
  #include <linux/regulator/consumer.h>
  #include <linux/slab.h>
  #include <linux/string_choices.h>
+#include <linux/types.h>
  #include <linux/units.h>


 #include <linux/iio/iio.h>

drivers/iio/accel/kionix-kx022a.c +1 -1
@@ -292,7 +293,7 @@ struct kx022a_data {
  	__le16 buffer[8] __aligned(IIO_DMA_MINALIGN);
  	struct {
  		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} scan;
  };

drivers/iio/accel/kxcjk-1013.c +2 -1
index b76df8816323..bbf65fc97b08 100644
@@ -11,6 +11,7 @@
  #include <linux/bitops.h>
  #include <linux/slab.h>
  #include <linux/string.h>
+#include <linux/types.h>
  #include <linux/acpi.h>
  #include <linux/pm.h>
  #include <linux/pm_runtime.h>
@@ -250,7 +251,7 @@ struct kxcjk1013_data {
  	/* Ensure timestamp naturally aligned */
  	struct {
  		s16 chans[AXIS_MAX];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
  	} scan;
  	u8 odr_bits;
  	u8 range;
drivers/iio/accel/kxsd9.c +2 -1
index 70dfd6e354db..6d2b0a22e550 100644
@@ -15,6 +15,7 @@
  #include <linux/kernel.h>
  #include <linux/sysfs.h>
  #include <linux/slab.h>
+#include <linux/types.h>
  #include <linux/module.h>
  #include <linux/regmap.h>
  #include <linux/bitops.h>
@@ -215,7 +216,7 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p)
  	 */
  	struct {
  		__be16 chan[4];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} hw_values;
  	int ret;

drivers/iio/accel/mma7455_core.c +1 -0
index a34195b3215d..50f7ac1845c6 100644
@@ -19,6 +19,7 @@
  #include <linux/iio/triggered_buffer.h>
  #include <linux/module.h>
  #include <linux/regmap.h>
+#include <linux/types.h>


 #include "mma7455.h"

drivers/iio/accel/mma7455_core.c +1 -1
@@ -58,7 +59,7 @@ struct mma7455_data {
  	 */
  	struct {
  		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} scan;
  };

drivers/iio/accel/mma8452.c +1 -0
index 62e6369e2269..de4525b30edc 100644
@@ -32,6 +32,7 @@
  #include <linux/delay.h>
  #include <linux/pm_runtime.h>
  #include <linux/regulator/consumer.h>
+#include <linux/types.h>


 #define MMA8452_STATUS 0x00
 #define  MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))

drivers/iio/accel/mma8452.c +1 -1
@@ -115,7 +116,7 @@ struct mma8452_data {
  	/* Ensure correct alignment of time stamp when present */
  	struct {
  		__be16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} buffer;
  };

drivers/iio/accel/msa311.c +1 -0
index 57025354c7cd..e7fb860f3233 100644
@@ -34,6 +34,7 @@
  #include <linux/pm_runtime.h>
  #include <linux/regmap.h>
  #include <linux/string_choices.h>
+#include <linux/types.h>
  #include <linux/units.h>


 #include <linux/iio/buffer.h>

drivers/iio/accel/msa311.c +1 -1
@@ -893,7 +894,7 @@ static irqreturn_t msa311_buffer_thread(int irq, void *p)
  	__le16 axis;
  	struct {
  		__le16 channels[MSA311_SI_Z + 1];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
  	} buf;


  memset(&buf, 0, sizeof(buf));

drivers/iio/accel/mxc4005.c +2 -1
index fc54a2a4693c..cb5c4e354fc0 100644
@@ -11,6 +11,7 @@
  #include <linux/iio/iio.h>
  #include <linux/mod_devicetable.h>
  #include <linux/regmap.h>
+#include <linux/types.h>
  #include <linux/iio/sysfs.h>
  #include <linux/iio/trigger.h>
  #include <linux/iio/buffer.h>
@@ -69,7 +70,7 @@ struct mxc4005_data {
  	/* Ensure timestamp is naturally aligned */
  	struct {
  		__be16 chans[3];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
  	} scan;
  	bool trigger_enabled;
  	unsigned int control;
drivers/iio/accel/stk8312.c +2 -1
index abead190254b..471c154c3631 100644
@@ -12,6 +12,7 @@
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/delay.h>
+#include <linux/types.h>
  #include <linux/iio/buffer.h>
  #include <linux/iio/iio.h>
  #include <linux/iio/sysfs.h>
@@ -105,7 +106,7 @@ struct stk8312_data {
  	/* Ensure timestamp is naturally aligned */
  	struct {
  		s8 chans[3];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
  	} scan;
  };

drivers/iio/accel/stk8ba50.c +2 -1
index a32a77324e92..cab592a68622 100644
@@ -12,6 +12,7 @@
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/mod_devicetable.h>
+#include <linux/types.h>
  #include <linux/iio/buffer.h>
  #include <linux/iio/iio.h>
  #include <linux/iio/sysfs.h>
@@ -94,7 +95,7 @@ struct stk8ba50_data {
  	/* Ensure timestamp is naturally aligned */
  	struct {
  		s16 chans[3];
-		s64 timetamp __aligned(8);
+		aligned_s64 timetamp;
  	} scan;
  };

Reviewed-by on v1 1/1
#6 lore raw
In reply to Jonathan Cameron
Quoted 6 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

e4ca0e59c394 ("types: Complement the aligned types with signed 64-bit one") introduced aligned_s64. Use it for all IIO accelerometer drivers.

Quoted 313 lines

---

I debated whether to split this up by driver by the time we've done all IIO drivers that will be a very large number of trivial patches.

The changes are minor enough that they shouldn't present much of a backporting challenge if needed for future fixes etc.

I'm find splitting them up if people prefer.
Next on my list is to look at adding runtime checks that the buffers containing these timestamps are big enough but I want this out of the way first.

Cc Andy Shevchenko <[email protected]>
---
 drivers/iio/accel/bma180.c          | 3 ++-
 drivers/iio/accel/bma220_spi.c      | 1 +
 drivers/iio/accel/bma400_core.c     | 2 +-
 drivers/iio/accel/bmc150-accel.h    | 3 ++-
 drivers/iio/accel/fxls8962af-core.c | 3 ++-
 drivers/iio/accel/kionix-kx022a.c   | 3 ++-
 drivers/iio/accel/kxcjk-1013.c      | 3 ++-
 drivers/iio/accel/kxsd9.c           | 3 ++-
 drivers/iio/accel/mma7455_core.c    | 3 ++-
 drivers/iio/accel/mma8452.c         | 3 ++-
 drivers/iio/accel/msa311.c          | 3 ++-
 drivers/iio/accel/mxc4005.c         | 3 ++-
 drivers/iio/accel/stk8312.c         | 3 ++-
 drivers/iio/accel/stk8ba50.c        | 3 ++-
 14 files changed, 26 insertions(+), 13 deletions(-)
drivers/iio/accel/bma180.c +2 -1
index 1fe20eb78a0b..41a517e1630f 100644
@@ -21,6 +21,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/types.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/buffer.h>
@@ -144,7 +145,7 @@ struct bma180_data {
 	/* Ensure timestamp is naturally aligned */
 	struct {
 		s16 chan[4];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
 	} scan;
 };
 
drivers/iio/accel/bma220_spi.c +1 -0
index d33218e40c79..2d27a592a61e 100644
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/types.h>
 #include <linux/spi/spi.h>
 
 #include <linux/iio/buffer.h>
drivers/iio/accel/bma400_core.c +1 -1
index d96840d135c6..eb32c963dfc8 100644
@@ -115,7 +115,7 @@ struct bma400_data {
 	struct {
 		__le16 buff[3];
 		u8 temperature;
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} buffer __aligned(IIO_DMA_MINALIGN);
 	__le16 status;
 	__be16 duration;
drivers/iio/accel/bmc150-accel.h +2 -1
index 7775c5edaeef..7a7baf52e595 100644
@@ -6,6 +6,7 @@
 #include <linux/iio/iio.h>
 #include <linux/mutex.h>
 #include <linux/regulator/consumer.h>
+#include <linux/types.h>
 #include <linux/workqueue.h>
 
 struct regmap;
@@ -69,7 +70,7 @@ struct bmc150_accel_data {
 	 */
 	struct {
 		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} scan;
 	u8 bw_bits;
 	u32 slope_dur;
drivers/iio/accel/fxls8962af-core.c +2 -1
index 37f33c29fb4b..ab427f3461db 100644
@@ -22,6 +22,7 @@
 #include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
+#include <linux/types.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/events.h>
@@ -163,7 +164,7 @@ struct fxls8962af_data {
 	const struct fxls8962af_chip_info *chip_info;
 	struct {
 		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} scan;
 	int64_t timestamp, old_timestamp;	/* Only used in hw fifo mode. */
 	struct iio_mount_matrix orientation;
drivers/iio/accel/kionix-kx022a.c +2 -1
index 53d59a04ae15..32387819995d 100644
@@ -16,6 +16,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/string_choices.h>
+#include <linux/types.h>
 #include <linux/units.h>
 
 #include <linux/iio/iio.h>
@@ -292,7 +293,7 @@ struct kx022a_data {
 	__le16 buffer[8] __aligned(IIO_DMA_MINALIGN);
 	struct {
 		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} scan;
 };
 
drivers/iio/accel/kxcjk-1013.c +2 -1
index b76df8816323..bbf65fc97b08 100644
@@ -11,6 +11,7 @@
 #include <linux/bitops.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/types.h>
 #include <linux/acpi.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
@@ -250,7 +251,7 @@ struct kxcjk1013_data {
 	/* Ensure timestamp naturally aligned */
 	struct {
 		s16 chans[AXIS_MAX];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
 	} scan;
 	u8 odr_bits;
 	u8 range;
drivers/iio/accel/kxsd9.c +2 -1
index 70dfd6e354db..6d2b0a22e550 100644
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
 #include <linux/slab.h>
+#include <linux/types.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/bitops.h>
@@ -215,7 +216,7 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p)
 	 */
 	struct {
 		__be16 chan[4];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} hw_values;
 	int ret;
 
drivers/iio/accel/mma7455_core.c +2 -1
index a34195b3215d..50f7ac1845c6 100644
@@ -19,6 +19,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/types.h>
 
 #include "mma7455.h"
 
@@ -58,7 +59,7 @@ struct mma7455_data {
 	 */
 	struct {
 		__le16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} scan;
 };
 
drivers/iio/accel/mma8452.c +2 -1
index 62e6369e2269..de4525b30edc 100644
@@ -32,6 +32,7 @@
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
+#include <linux/types.h>
 
 #define MMA8452_STATUS				0x00
 #define  MMA8452_STATUS_DRDY			(BIT(2) | BIT(1) | BIT(0))
@@ -115,7 +116,7 @@ struct mma8452_data {
 	/* Ensure correct alignment of time stamp when present */
 	struct {
 		__be16 channels[3];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} buffer;
 };
 
drivers/iio/accel/msa311.c +2 -1
index 57025354c7cd..e7fb860f3233 100644
@@ -34,6 +34,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/string_choices.h>
+#include <linux/types.h>
 #include <linux/units.h>
 
 #include <linux/iio/buffer.h>
@@ -893,7 +894,7 @@ static irqreturn_t msa311_buffer_thread(int irq, void *p)
 	__le16 axis;
 	struct {
 		__le16 channels[MSA311_SI_Z + 1];
-		s64 ts __aligned(8);
+		aligned_s64 ts;
 	} buf;
 
 	memset(&buf, 0, sizeof(buf));
drivers/iio/accel/mxc4005.c +2 -1
index fc54a2a4693c..cb5c4e354fc0 100644
@@ -11,6 +11,7 @@
 #include <linux/iio/iio.h>
 #include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
+#include <linux/types.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/buffer.h>
@@ -69,7 +70,7 @@ struct mxc4005_data {
 	/* Ensure timestamp is naturally aligned */
 	struct {
 		__be16 chans[3];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
 	} scan;
 	bool trigger_enabled;
 	unsigned int control;
drivers/iio/accel/stk8312.c +2 -1
index abead190254b..471c154c3631 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/delay.h>
+#include <linux/types.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -105,7 +106,7 @@ struct stk8312_data {
 	/* Ensure timestamp is naturally aligned */
 	struct {
 		s8 chans[3];
-		s64 timestamp __aligned(8);
+		aligned_s64 timestamp;
 	} scan;
 };
 
drivers/iio/accel/stk8ba50.c +2 -1
index a32a77324e92..cab592a68622 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/types.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -94,7 +95,7 @@ struct stk8ba50_data {
 	/* Ensure timestamp is naturally aligned */
 	struct {
 		s16 chans[3];
-		s64 timetamp __aligned(8);
+		aligned_s64 timetamp;
 	} scan;
 };
 
Signature · 1 line
2.46.2
Signature · 2 lines
Thank you,
Dmitry