hwmon: (nct6775) Fix virtual temperature sources for NCT6796D
authorGuenter Roeck <linux@roeck-us.net>
Fri, 14 Sep 2018 02:43:58 +0000 (19:43 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sat, 15 Sep 2018 14:42:07 +0000 (07:42 -0700)
commit37196ba4ae95a2077d78715eb12e879e57613d43
treedd42490dbf552fa86f4a65613f046b45994cd106
parentc793279c77035053e67937f5743c6ebfc303e7c5
hwmon: (nct6775) Fix virtual temperature sources for NCT6796D

The following kernel log message is reported for the nct6775 driver
on ASUS WS X299 SAGE.

nct6775: Found NCT6796D or compatible chip at 0x2e:0x290
nct6775 nct6775.656: Invalid temperature source 11 at index 0,
source register 0x100, temp register 0x73
nct6775 nct6775.656: Invalid temperature source 11 at index 2,
source register 0x300, temp register 0x77
nct6775 nct6775.656: Invalid temperature source 11 at index 3,
source register 0x800, temp register 0x79
nct6775 nct6775.656: Invalid temperature source 11 at index 4,
source register 0x900, temp register 0x7b

A recent version of the datasheet lists temperature source 11 as reserved.
However, an older version of the datasheet lists temperature sources 10
and 11 as supported virtual temperature sources. Apparently the older
version of the datasheet is correct, so list those temperature sources
as supported.

Virtual temperature sources are different than other temperature sources:
Values are not read from a temperature sensor, but written either from
BIOS or an embedded controller. As such, each virtual temperature has to
be reported. Since there is now more than one temperature source, we have
to keep virtual temperature sources in a chip-specific mask and can no
longer rely on the assumption that there is only one virtual temperature
source with a fixed index. This accounts for most of the complexity of this
patch.

Reported-by: Robert Kern <ulteq@web.de>
Cc: Robert Kern <ulteq@web.de>
Fixes: 81820059a428 ("hwmon: (nct6775) Add support for NCT6796D")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/nct6775.c