linux/drivers/hwmon/occ
Arnd Bergmann 2c021b45c1 hwmon: (occ) fix unaligned accesses
Passing a pointer to an unaligned integer as a function argument is
undefined behavior:

drivers/hwmon/occ/common.c:492:27: warning: taking address of packed member 'accumulator' of class or structure 'power_sensor_2' may result in an unaligned pointer value [-Waddress-of-packed-member]
  492 |   val = occ_get_powr_avg(&power->accumulator,
      |                           ^~~~~~~~~~~~~~~~~~
drivers/hwmon/occ/common.c:493:13: warning: taking address of packed member 'update_tag' of class or structure 'power_sensor_2' may result in an unaligned pointer value [-Waddress-of-packed-member]
  493 |            &power->update_tag);
      |             ^~~~~~~~~~~~~~~~~

Move the get_unaligned() calls out of the function and pass these
through argument registers instead.

Fixes: c10e753d43 ("hwmon (occ): Add sensor types and versions")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20250610092553.2641094-1-arnd@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-06-16 06:30:57 -07:00
..
common.c hwmon: (occ) fix unaligned accesses 2025-06-16 06:30:57 -07:00
common.h hwmon: (occ) Prevent power cap command overwriting poll response 2022-06-29 13:59:23 -07:00
Kconfig hwmon: (occ) OCC sensors aren't arch-specific 2022-12-04 16:45:02 -08:00
Makefile
p8_i2c.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
p9_sbe.c hwmon: (occ/p9_sbe) Constify 'struct bin_attribute' 2024-12-15 22:02:26 -08:00
sysfs.c