All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: imu: inv_mpu6050: use named initializers for temp in hw_info[]
@ 2026-10-18  0:09 Arnav Kapoor
  2026-10-20  7:59 ` Joshua Crofts
  0 siblings, 1 reply; 2+ messages in thread
From: Arnav Kapoor @ 2026-10-18  0:09 UTC (permalink / raw)
  To: Jean-Baptiste Maneyrol, Jonathan Cameron
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel, Arnav Kapoor

The temp member of struct inv_mpu6050_hw is initialized positionally
in every entry of hw_info[], as { *_TEMP_OFFSET, *_TEMP_SCALE }. The
order is correct today, but positional initializers of this kind are
how the accel and gyro startup times ended up swapped.

Use designated initializers, as already done for startup_time, so each
value is assigned to the member it is named after.

No functional change.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
Follow-up suggested by Jonathan on the startup time fix:
https://lore.kernel.org/all/20261011045710.357809-1-kapoorarnav43@gmail.com/

Compile-tested (W=1). The object file is byte-identical to the one
built without this patch, apart from debug info.

 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 95 +++++++++++++++++-----
 1 file changed, 76 insertions(+), 19 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 3bdcf92472e8..5deddd3c5e80 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -148,7 +148,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6050,
 		.config = &chip_config_6050,
 		.fifo_size = 1024,
-		.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
+		.temp = {
+			.offset = INV_MPU6050_TEMP_OFFSET,
+			.scale = INV_MPU6050_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
@@ -160,7 +163,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 512,
-		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
+		.temp = {
+			.offset = INV_MPU6500_TEMP_OFFSET,
+			.scale = INV_MPU6500_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -172,7 +178,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 512,
-		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
+		.temp = {
+			.offset = INV_MPU6500_TEMP_OFFSET,
+			.scale = INV_MPU6500_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -184,7 +193,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 4096,
-		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
+		.temp = {
+			.offset = INV_MPU6500_TEMP_OFFSET,
+			.scale = INV_MPU6500_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -196,7 +208,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6050,
 		.config = &chip_config_6050,
 		.fifo_size = 1024,
-		.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
+		.temp = {
+			.offset = INV_MPU6050_TEMP_OFFSET,
+			.scale = INV_MPU6050_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
@@ -208,7 +223,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6050,
 		.config = &chip_config_6050,
 		.fifo_size = 1024,
-		.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
+		.temp = {
+			.offset = INV_MPU6050_TEMP_OFFSET,
+			.scale = INV_MPU6050_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
@@ -220,7 +238,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 512,
-		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
+		.temp = {
+			.offset = INV_MPU6500_TEMP_OFFSET,
+			.scale = INV_MPU6500_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -232,7 +253,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 512,
-		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
+		.temp = {
+			.offset = INV_MPU6500_TEMP_OFFSET,
+			.scale = INV_MPU6500_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -244,7 +268,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 512,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -256,7 +283,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 512,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -268,7 +298,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 4 * 1024,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -280,7 +313,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 4 * 1024,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -292,7 +328,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_icm20602,
 		.config = &chip_config_6500,
 		.fifo_size = 1008,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_ICM20602_ACCEL_STARTUP_TIME,
 			.gyro = INV_ICM20602_GYRO_STARTUP_TIME,
@@ -304,7 +343,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_icm20602,
 		.config = &chip_config_6500,
 		.fifo_size = 1008,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_ICM20602_ACCEL_STARTUP_TIME,
 			.gyro = INV_ICM20602_GYRO_STARTUP_TIME,
@@ -316,7 +358,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 1024,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_ICM20690_ACCEL_STARTUP_TIME,
 			.gyro = INV_ICM20690_GYRO_STARTUP_TIME,
@@ -327,7 +372,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 512,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -339,7 +387,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 512,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -351,7 +402,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 4 * 1024,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
@@ -363,7 +417,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.reg = &reg_set_6500,
 		.config = &chip_config_6500,
 		.fifo_size = 4 * 1024,
-		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
+		.temp = {
+			.offset = INV_ICM20608_TEMP_OFFSET,
+			.scale = INV_ICM20608_TEMP_SCALE,
+		},
 		.startup_time = {
 			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
 			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: imu: inv_mpu6050: use named initializers for temp in hw_info[]
  2026-10-18  0:09 [PATCH] iio: imu: inv_mpu6050: use named initializers for temp in hw_info[] Arnav Kapoor
@ 2026-10-20  7:59 ` Joshua Crofts
  0 siblings, 0 replies; 2+ messages in thread
From: Joshua Crofts @ 2026-10-20  7:59 UTC (permalink / raw)
  To: Arnav Kapoor
  Cc: Jean-Baptiste Maneyrol, Jonathan Cameron, David Lechner,
	Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel

On Sun, 18 Oct 2026 05:39:13 +0530
Arnav Kapoor <kapoorarnav43@gmail.com> wrote:

> The temp member of struct inv_mpu6050_hw is initialized positionally
> in every entry of hw_info[], as { *_TEMP_OFFSET, *_TEMP_SCALE }. The
> order is correct today, but positional initializers of this kind are
> how the accel and gyro startup times ended up swapped.
> 
> Use designated initializers, as already done for startup_time, so each
> value is assigned to the member it is named after.
> 
> No functional change.
> 
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
> ---

Your patch fails to apply, please check it out.

-- 
Kind regards,
Joshua Crofts

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-20  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-18  0:09 [PATCH] iio: imu: inv_mpu6050: use named initializers for temp in hw_info[] Arnav Kapoor
2026-10-20  7:59 ` Joshua Crofts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.