Skip to contentSkip to conversation

iio: imu: inv_mpu6050: use named initializers for temp in hw_info[]

PATCH In review Arnav Kapoor 4 participants 6 messages Oct 18 – Oct 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: imu: inv_mpu6050: use named initializers for temp in hw_info[]

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.

---
Follow-up suggested by Jonathan on the startup time fix:
https://lore.kernel.org/all/[email protected]/

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(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +76 -19
index 3bdcf92472e8..5deddd3c5e80 100644
@@ -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,
Signature · 1 line
2.53.0
#1 lore raw
Quoted 5 lines · On Sun, 18 Oct 2026 05:39:13 +0530 Arnav Kapoor <[email protected]> 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.

Quoted 8 lines

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

No functional change.

---

Your patch fails to apply, please check it out.

Signature · 2 lines
Kind regards,
Joshua Crofts
#2 lore raw
Quoted 1 line · Joshua Crofts

Your patch fails to apply, please check it out.

Thanks for trying it. The patch is based on iio.git fixes-togreg, on top of commit 2b8d4cd20ac8 ("iio: imu: inv_mpu6050: fix swapped accel and gyro startup times"), which changes the neighbouring .startup_time lines in every hw_info[] entry. It applies cleanly there, but not on togreg or testing, which don't have that fix yet. I should have said so below the ---, sorry.

Jonathan, I can resend once that fix has reached togreg, or rebase it however you prefer.

Thanks,
Arnav

#3 lore raw
Quoted 9 lines · Arnav Kapoor
Quoted 1 line · Joshua Crofts

Your patch fails to apply, please check it out.

Thanks for trying it. The patch is based on iio.git fixes-togreg, on top of commit 2b8d4cd20ac8 ("iio: imu: inv_mpu6050: fix swapped accel and gyro startup times"), which changes the neighbouring .startup_time lines in every hw_info[] entry. It applies cleanly there, but not on togreg or testing, which don't have that fix yet. I should have said so below the ---, sorry.

just use --base next time when formatting patch (with git format-patch).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 1 line · Andy Shevchenko

just use --base next time when formatting patch (with git format-patch).

Will do, thanks. For this one, the base was:

base-commit: 28691515f54f03f23636cbf1ee2cd60fc31e2353

maintainer
#5 lore raw
In reply to Arnav Kapoor
Quoted 10 lines · On Thu, 22 Oct 2026 00:08:00 +0530 Arnav Kapoor <[email protected]> wrote:
Quoted 1 line · Joshua Crofts

Your patch fails to apply, please check it out.

Thanks for trying it. The patch is based on iio.git fixes-togreg, on top of commit 2b8d4cd20ac8 ("iio: imu: inv_mpu6050: fix swapped accel and gyro startup times"), which changes the neighbouring .startup_time lines in every hw_info[] entry. It applies cleanly there, but not on togreg or testing, which don't have that fix yet. I should have said so below the ---, sorry.

Quoted 2 lines

Jonathan, I can resend once that fix has reached togreg, or rebase it however you prefer.

I'll hold it in patchwork so you shouldn't need to resend. I tend to do a sanity check on state of patches ever few weeks that picks up things like this.

But feel free to poke me if I seem to have lost it.

Jonathan

Quoted 3 lines

Thanks,
Arnav