[PATCH] iio: imu: inv_mpu6050: use named initializers for temp in hw_info[]
From: Arnav Kapoor
Date: Sat Oct 17 2026 - 20:09:39 EST
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@xxxxxxxxxx>
Signed-off-by: Arnav Kapoor <kapoorarnav43@xxxxxxxxx>
---
Follow-up suggested by Jonathan on the startup time fix:
https://lore.kernel.org/all/20261011045710.357809-1-kapoorarnav43@xxxxxxxxx/
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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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 = ®_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