Commit 2c021b4
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: c10e753 ("hwmon (occ): Add sensor types and versions")
Signed-off-by: Arnd Bergmann <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>1 parent 744c2fe commit 2c021b4
1 file changed
+13
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
462 | | - | |
| 462 | + | |
463 | 463 | | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 464 | + | |
| 465 | + | |
468 | 466 | | |
469 | 467 | | |
470 | 468 | | |
| |||
489 | 487 | | |
490 | 488 | | |
491 | 489 | | |
492 | | - | |
493 | | - | |
| 490 | + | |
| 491 | + | |
494 | 492 | | |
495 | 493 | | |
496 | 494 | | |
| |||
527 | 525 | | |
528 | 526 | | |
529 | 527 | | |
530 | | - | |
531 | | - | |
| 528 | + | |
| 529 | + | |
532 | 530 | | |
533 | 531 | | |
534 | 532 | | |
| |||
541 | 539 | | |
542 | 540 | | |
543 | 541 | | |
544 | | - | |
545 | | - | |
| 542 | + | |
| 543 | + | |
546 | 544 | | |
547 | 545 | | |
548 | 546 | | |
| |||
555 | 553 | | |
556 | 554 | | |
557 | 555 | | |
558 | | - | |
559 | | - | |
| 556 | + | |
| 557 | + | |
560 | 558 | | |
561 | 559 | | |
562 | 560 | | |
| |||
569 | 567 | | |
570 | 568 | | |
571 | 569 | | |
572 | | - | |
573 | | - | |
| 570 | + | |
| 571 | + | |
574 | 572 | | |
575 | 573 | | |
576 | 574 | | |
| |||
0 commit comments