Commit fdaf0c8
hwmon: (coretemp) Fix bogus core_id to attr name mapping
Before commit 7108b80 ("hwmon/coretemp: Handle large core ID
value"), there is a fixed mapping between
1. cpu_core_id
2. the index in pdata->core_data[] array
3. the sysfs attr name, aka "tempX_"
The later two always equal cpu_core_id + 2.
After the commit, pdata->core_data[] index is got from ida so that it
can handle sparse core ids and support more cores within a package.
However, the commit erroneously maps the sysfs attr name to
pdata->core_data[] index instead of cpu_core_id + 2.
As a result, the code is not aligned with the comments, and brings user
visible changes in hwmon sysfs on systems with sparse core id.
For example, before commit 7108b80 ("hwmon/coretemp: Handle large
core ID value"),
/sys/class/hwmon/hwmon2/temp2_label:Core 0
/sys/class/hwmon/hwmon2/temp3_label:Core 1
/sys/class/hwmon/hwmon2/temp4_label:Core 2
/sys/class/hwmon/hwmon2/temp5_label:Core 3
/sys/class/hwmon/hwmon2/temp6_label:Core 4
/sys/class/hwmon/hwmon3/temp10_label:Core 8
/sys/class/hwmon/hwmon3/temp11_label:Core 9
after commit,
/sys/class/hwmon/hwmon2/temp2_label:Core 0
/sys/class/hwmon/hwmon2/temp3_label:Core 1
/sys/class/hwmon/hwmon2/temp4_label:Core 2
/sys/class/hwmon/hwmon2/temp5_label:Core 3
/sys/class/hwmon/hwmon2/temp6_label:Core 4
/sys/class/hwmon/hwmon2/temp7_label:Core 8
/sys/class/hwmon/hwmon2/temp8_label:Core 9
Restore the previous behavior and rework the code, comments and variable
names to avoid future confusions.
Fixes: 7108b80 ("hwmon/coretemp: Handle large core ID value")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Link: https://lore.kernel.org/r/20240202092144.71180-3-rui.zhang@intel.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>1 parent 4e440ab commit fdaf0c8
1 file changed
Lines changed: 19 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
434 | 441 | | |
435 | 442 | | |
436 | 443 | | |
437 | 444 | | |
438 | 445 | | |
439 | 446 | | |
440 | | - | |
| 447 | + | |
441 | 448 | | |
442 | 449 | | |
443 | 450 | | |
| |||
495 | 502 | | |
496 | 503 | | |
497 | 504 | | |
498 | | - | |
| 505 | + | |
499 | 506 | | |
500 | 507 | | |
501 | 508 | | |
502 | 509 | | |
503 | 510 | | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
508 | 514 | | |
509 | 515 | | |
510 | | - | |
| 516 | + | |
511 | 517 | | |
512 | 518 | | |
513 | 519 | | |
514 | 520 | | |
515 | 521 | | |
516 | 522 | | |
517 | | - | |
| 523 | + | |
518 | 524 | | |
519 | 525 | | |
520 | 526 | | |
| |||
540 | 546 | | |
541 | 547 | | |
542 | 548 | | |
543 | | - | |
| 549 | + | |
544 | 550 | | |
545 | 551 | | |
546 | | - | |
| 552 | + | |
547 | 553 | | |
548 | 554 | | |
549 | 555 | | |
550 | 556 | | |
551 | 557 | | |
552 | | - | |
| 558 | + | |
553 | 559 | | |
554 | 560 | | |
555 | 561 | | |
556 | | - | |
| 562 | + | |
557 | 563 | | |
558 | 564 | | |
559 | 565 | | |
| |||
0 commit comments