[PATCH 6/8] hw/i2c: fix VOUT_MODE representation on little-endian machines

Titus Rwantare <[email protected]> Wed, 29 Jul 2026 23:13:21 +0000
Newsgroups org.nongnu.qemu-arm,org.nongnu.qemu-devel
Message-ID <[email protected]>
From: Jason Fan <[email protected]>

Even though VOUT_MODE is only one byte, bitfields are allocated in the
order specific to the host's endianness.

Signed-off-by: Titus Rwantare <[email protected]>
Signed-off-by: Jason Fan <[email protected]>
---
 include/hw/i2c/pmbus_device.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/hw/i2c/pmbus_device.h b/include/hw/i2c/pmbus_device.h
index 9f3569e997..03b2c21c19 100644
--- a/include/hw/i2c/pmbus_device.h
+++ b/include/hw/i2c/pmbus_device.h
@@ -449,10 +449,17 @@ typedef struct PMBusCoefficients {
 /**
  * VOUT_Mode bit fields
  */
+#if HOST_BIG_ENDIAN
 typedef struct PMBusVoutMode {
     uint8_t  mode:3;
     int8_t   exp:5;
 } PMBusVoutMode;
+# else
+typedef struct PMBusVoutMode {
+    int8_t   exp:5;
+    uint8_t  mode:3;
+} PMBusVoutMode;
+#endif
 
 /**
  * Convert sensor values to direct mode format
-- 
2.55.0.508.g3f0d502094-goog