summaryrefslogtreecommitdiff
path: root/drivers/hwmon/nct6775.c
AgeCommit message (Collapse)AuthorFilesLines
2019-01-07hwmon: (nct6775) Enable IO mapping for NCT6797D and NCT6798DGuenter Roeck1-2/+4
Similar to other recent chips from Nuvoton, IO mapping may be disabled by default. Enable it when instantiating the driver and after resume. Fixes: 0599682b826f ("hwmon: (nct6775) Add support for NCT6798D") Fixes: e41da286a2fd ("hwmon: (nct6775) Add support for NCT6797D") Reported-by: Michael Cook <mcook@mackal.net> Cc: Michael Cook <mcook@mackal.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-01-07hwmon: (nct6775) Fix chip ID for NCT6798DGuenter Roeck1-3/+3
The chip ID is 0xd42[8-f], not 0xd45[8-f]. Fixes: 0599682b826f ("hwmon: (nct6775) Add support for NCT6798D") Reported-by: Michael Cook <mcook@mackal.net> Cc: Michael Cook <mcook@mackal.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Add support for NCT6798DGuenter Roeck1-4/+80
NCT6798D is, with the exception of fan and pwm channel configuration registers, similar to other chips of the series. One interesting difference is the chip ID, which is now extended to 13 bit (the 12-bit chip ID value overlaps with the chip ID of NCT6797D). Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Add support for NCT6797DGuenter Roeck1-4/+41
Add support for NCT6797D. With the exception of fan/pwm configuration registers, it is mostly compatible with NCT6795D. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Fix names of DIMM temperature sourcesGuenter Roeck1-8/+8
For NCT6795D and NCT6796D, the DIMM temperature sources are named "Agent[01] Dimm [01]" per datasheet. Match names in datasheets to avoid confusion. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6796) Clean up and amend fan/pwm configuration for NCT6796DGuenter Roeck1-14/+13
Now that everything is separated, clean up fan and pwm configuration for NCT6796D. While doing that, take the forgotten configuration register cre0 into account to determine if AUXFANIN2 (fan5) and AUXFANOUT2 (pwm5) are connected. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Separate fan/pwm configuration detection for NCT6795DGuenter Roeck1-4/+15
Separate fan/pwm configuration detection for NCT6795D into separate case statement to make the code easier to read. No functional change. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Separate fan/pwm configuration detection for NCT6793DGuenter Roeck1-5/+14
While detecting the configuration for multiple chips in one go reduces code size, it also increases code complexity. Separate chip detection to improve code readability. As first step, separate detection for NCT6793D. No functional change. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Fix fan6/pwm6 detection for NCT6792DGuenter Roeck1-1/+4
Per datasheet, AUXFANIN3 (fan6) and AUXFANOUT3 (pwm6) are only connected if DSW_EN is false. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Improve instruction groupingGuenter Roeck1-4/+4
When determining support for a given fan or pwm control, the code is easier to read if the necessary instructions are grouped together. No functional change. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Use logical or instead of if statements where possibleGuenter Roeck1-23/+11
Use boolean |= <expression>; instead of if (!boolean) boolean = <expression>; to assign values to boolean variables. No functional change. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Declare and initialize LDN specific config variables earlierGuenter Roeck1-5/+6
Declare and initialize LDN / chip specific configuration variables earlier. This simplifies re-using the configuration variables for multiple chips and makes the code easier to read. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Move config variable declarations and initializationsGuenter Roeck1-19/+11
Group configuration variable declarations and initialization together. While this results in reading more registers than necessary for a given chip, it improves code readability and simplifies extending the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Replace 'regval' with variables named after config registersGuenter Roeck1-20/+23
Using variables named after configuration registers makes it more obvious which configuration register value is used, especially if more than one configuration register value is used to determine a configuration detail. No functional change. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Rename configuration register variablesGuenter Roeck1-21/+21
Use variable names from chip datasheets (crXX) instead of regval_XX for configuration register variables. This is shorter and, together with subsequent changes, makes the code easier to read. No functional change. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Only display fan speed tolerance conditionallyGuenter Roeck1-13/+19
A fan speed tolerance only makes sense if a fan target speed has been configured in the first place. Otherwise we get odd output such as fan1_target:0 fan1_tolerance:337500 Only display values other than 0 if a fan target speed has been configured. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-11hwmon: (nct6775) Clean up a conditionDan Carpenter1-2/+1
I removed the "dsw_en &&" chunk of the condition because we know that "dsw_en" is set. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-09-17hwmon: (nct6775) Use different register to get fan RPM for fan7Guenter Roeck1-2/+2
The documented register to retrieve the fan RPM for fan7 is found to be unreliable at least with NCT6796D revision 3. Let's use register 0x4ce instead. This is undocumented for NCT6796D, but documented for NCT6797D and NCT6798D and known to be working. 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>
2018-09-16hwmon: (nct6775) Fix RPM output for fan7 on NCT6796DGuenter Roeck1-4/+9
fan7 on NCT6796D does not have a fan count register; it only has an RPM register. Switch to using RPM registers to read the fan speed for all chips supporting it to solve the problem for good. 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>
2018-09-15hwmon: (nct6775) Fix virtual temperature sources for NCT6796DGuenter Roeck1-6/+22
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>
2018-09-07hwmon: (nct6775) Fix access to fan pulse registersGuenter Roeck1-11/+16
Not all fans have a fan pulse register. This can result in reading beyond the end of REG_FAN_PULSES and FAN_PULSE_SHIFT arrays, and was reported by smatch as possible error. 1672 for (i = 0; i < ARRAY_SIZE(data->rpm); i++) { ^^^^^^^^^^^^^^^^^^^^^^^^ This is a 7 element array. ... 1685 data->fan_pulses[i] = 1686 (nct6775_read_value(data, data->REG_FAN_PULSES[i]) 1687 >> data->FAN_PULSE_SHIFT[i]) & 0x03; ^^^^^^^^^^^^^^^^^^^^^^^^ FAN_PULSE_SHIFT is either 5 or 6 elements. To fix the problem, we have to ensure that all REG_FAN_PULSES and FAN_PULSE_SHIFT have the appropriate length, and that REG_FAN_PULSES is only read if the register actually exists. Fixes: 6c009501ff200 ("hwmon: (nct6775) Add support for NCT6102D/6106D") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-09-06hwmon: (nct6775) Set weight source to zero correctlyDan Carpenter1-1/+1
This is dead code because j can never be 1 at this point. We had intended to just test if the bit was clear. Fixes: bbd8decd4123 ("hwmon: (nct6775) Add support for weighted fan control") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-08-27hwmon: (nct6775) Fix potential Spectre v1Gustavo A. R. Silva1-0/+2
val can be indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability. This issue was detected with the help of Smatch: vers/hwmon/nct6775.c:2698 store_pwm_weight_temp_sel() warn: potential spectre issue 'data->temp_src' [r] Fix this by sanitizing val before using it to index data->temp_src Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1]. [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2 Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-07-09hwmon: Mark expected switch fall-throughsGustavo A. R. Silva1-1/+1
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-07-09hwmon: (nct6775) Fix comment in the description of pwm_modeGuenter Roeck1-2/+2
Commit 415eb2a1aaa488 ("hwmon: (nct6775) Fix writing pwmX_mode") changed the definition of the pwm_mode variable, but did not update the comment describing it. Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Cc: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-06-17hwmon: (nct6775) Fix loop limitGuenter Roeck1-1/+1
Commit cc66b3038254 ("hwmon: (nct6775) Rework temperature source and label handling") changed a loop limit from "data->temp_label_num - 1" to "32", as part of moving from a string array to a bit mask. This results in the following error, reported by UBSAN. UBSAN: Undefined behaviour in drivers/hwmon/nct6775.c:4179:27 shift exponent 32 is too large for 32-bit type 'long unsigned int' Similar to the original loop, the limit has to be one less than the number of bits. Fixes: cc66b3038254 ("hwmon: (nct6775) Rework temperature source and label handling") Reported-by: Paul Menzel <pmenzel+linux-hwmon@molgen.mpg.de> Cc: Paul Menzel <pmenzel+linux-hwmon@molgen.mpg.de> Tested-by: Paul Menzel <pmenzel+linux-hwmon@molgen.mpg.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-06-13treewide: devm_kzalloc() -> devm_kcalloc()Kees Cook1-2/+2
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc(). This patch replaces cases of: devm_kzalloc(handle, a * b, gfp) with: devm_kcalloc(handle, a * b, gfp) as well as handling cases of: devm_kzalloc(handle, a * b * c, gfp) with: devm_kzalloc(handle, array3_size(a, b, c), gfp) as it's slightly less ugly than: devm_kcalloc(handle, array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: devm_kzalloc(handle, 4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. Some manual whitespace fixes were needed in this patch, as Coccinelle really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...". The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ expression HANDLE; type TYPE; expression THING, E; @@ ( devm_kzalloc(HANDLE, - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | devm_kzalloc(HANDLE, - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression HANDLE; expression COUNT; typedef u8; typedef __u8; @@ ( devm_kzalloc(HANDLE, - sizeof(u8) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(__u8) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(char) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(unsigned char) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(u8) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(__u8) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(char) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ expression HANDLE; type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ expression HANDLE; identifier SIZE, COUNT; @@ - devm_kzalloc + devm_kcalloc (HANDLE, - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression HANDLE; expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( devm_kzalloc(HANDLE, - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression HANDLE; expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ expression HANDLE; identifier STRIDE, SIZE, COUNT; @@ ( devm_kzalloc(HANDLE, - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression HANDLE; expression E1, E2, E3; constant C1, C2, C3; @@ ( devm_kzalloc(HANDLE, C1 * C2 * C3, ...) | devm_kzalloc(HANDLE, - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression HANDLE; expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( devm_kzalloc(HANDLE, sizeof(THING) * C2, ...) | devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...) | devm_kzalloc(HANDLE, C1 * C2 * C3, ...) | devm_kzalloc(HANDLE, C1 * C2, ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - (E1) * E2 + E1, E2 , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - (E1) * (E2) + E1, E2 , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
2018-03-27hwmon: (nct6775) Fix writing pwmX_modeGuenter Roeck1-5/+5
pwmX_mode is defined in the ABI as 0=DC mode, 1=pwm mode. The chip register bit is set to 1 for DC mode. This got mixed up, and writing 1 into pwmX_mode resulted in DC mode enabled. Fix it up by using the ABI definition throughout the driver for consistency. Fixes: 77eb5b3703d99 ("hwmon: (nct6775) Add support for pwm, pwm_mode, ... ") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-03-11hwmon: (nct6775) Add support for NCT6796DGuenter Roeck1-50/+122
NCT6796D is mostly compatible to NCT6795D. It supports an additional pwm control and fan speed channel. While we are at it, update documentation for NCT6795D. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-03-11hwmon: (nct6775) Initialize boolean variables with declarationGuenter Roeck1-24/+4
Initialize boolean flags in nct6775_check_fan_inputs() while declaring them instead of several times throughout the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-03-11hwmon: (nct6775) Improve fan6/pwm6 supportGuenter Roeck1-7/+30
Improve fan6/pwm6 detection on NCT6795D. Add support for fan pulses for fans 4..6 and fan min limits for fan6. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-03-11hwmon: (nct6775) Use NUM_FAN consistentlyGuenter Roeck1-6/+6
The size of some of the arrays using the number of fans is hardcoded. Use NUM_FAN consistently throughout the driver. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-06-12hwmon: (nct6775) Add support for NCT6795DGuenter Roeck1-4/+61
NCT6795D is mostly compatible to NCT6793D with a few minor differences. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-06-12hwmon: (nct6775) Improve fan detectionGuenter Roeck1-8/+37
Recent chips support multiple pins for fan speed inputs and fan control outputs. Examine all of them to determine supported fan controls. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-06-12hwmon: (nct6775) Rework temperature source and label handlingGuenter Roeck1-31/+65
Instead of checking if a temperature source has a label, use a bit mask to determine if a temperature source is valid for a given chip. This simplifies the code and, if necessary, lets us support chips with unknown or incomplete labels. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-06-12hwmon: (nct6775) Use bitopsGuenter Roeck1-61/+62
Using bitops instead of shift operations makes the code easier to read. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-01-02hwmon: (nct6775) use permission-specific DEVICE_ATTR variantsJulia Lawall1-2/+2
Use DEVICE_ATTR_RW for read/write attributes. This simplifies the source code, improves readbility, and reduces the chance of inconsistencies. The conversion was done automatically using coccinelle. It was validated by compiling both the old and the new source code and comparing its text, data, and bss size. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-19hwmon: (nct6775) Add support for multiple virtual temperature sourcesGuenter Roeck1-2/+13
For virtual temperatures, the actual temperature values are written by software, presumably by the BIOS. This functionality is (as of right now) supported on NCT6791D, NCT6792D, and NCT6793D. On those chips, the temperatures are written into registers 0xea..0xef on page 0. This is known to be used on some Asus motherboards, where the actual temperature source can be configured in the BIOS. Report the 'virtual' temperatures for all monotoring sources to address this situation. Example for the resulting output (as seen with the 'sensors' command): nct6791-isa-0290 Adapter: ISA adapter ... Virtual_TEMP: +31.0°C PECI Agent 0: +38.5°C Virtual_TEMP: +32.0°C ... Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (nct6775) Do not accept force_id unless chip is foundGuenter Roeck1-4/+4
Since commit 698a7c24a544 ("hwmon: (nct6775) Support two SuperIO chips in the same system"), the driver supports two Super-IO chips. This has the undesirable side effect that force_id always detects a second chip at address 0xfff8, even if no chip exists at that address. nct6775: Found NCT6793D or compatible chip at 0x4e:0xfff8 If no chip at all is found at a given SIO address, it does not make sense to instantiate it. Limit force_id to only work if some chip is found, that is if the chip ID returns a value other than 0xffff. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-12-18hwmon: (nct6683,nct6775) constify sensor_template_group structuresJulia Lawall1-5/+6
The sensor_template_group structures are never modified, so declare them as const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-10-30hwmon: (nct6775) Introduce separate temperature labels for NCT6792 and NCT6793Guenter Roeck1-1/+82
NCT6792 and NCT6793 are mostly register compatible to NCT6791, but temperature sources are different and difficult to manage with a single temperature label array. Introduce separate temperature label arrays for those chips to reflect the differences. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-10-30hwmon: (nct6775) NCT6791D and NCT6792D have an additional temperature sourceGuenter Roeck1-5/+13
Both NCT6791D and NCT6792D permit selection of a 'virtual' temperature register as temperature source. The virtual temperature registers are registers 0xea to 0xef in bank 0 and can be written by software. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-09-13hwmon: (nct6775) Add support for NCT6793DGuenter Roeck1-16/+32
NCT6793D is register compatible with NCT6792D. Also move nct6775_sio_names[] closer to enum kinds to simplify adding new chips. Tested-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-09-13hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chipsGuenter Roeck1-6/+10
The STEP_UP_TIME and STEP_DOWN_TIME registers are swapped for all chips but NCT6775. Reported-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Cc: stable@vger.kernel.org # v3.10+ Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-05-30hwmon: (nct6775) Add missing sysfs attribute initializationGuenter Roeck1-0/+2
The following error message is seen when loading the nct6775 driver with DEBUG_LOCK_ALLOC enabled. BUG: key ffff88040b2f0030 not in .data! ------------[ cut here ]------------ WARNING: CPU: 0 PID: 186 at kernel/locking/lockdep.c:2988 lockdep_init_map+0x469/0x630() DEBUG_LOCKS_WARN_ON(1) Caused by a missing call to sysfs_attr_init() when initializing sysfs attributes. Reported-by: Alexey Orishko <alexey.orishko@gmail.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Cc: stable@vger.kernel.org # v3.12+ Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-03-15hwmon: (nct6775) Enable auxiliary fan monitoring on ASRock Z77 Pro4-MGuenter Roeck1-0/+21
Auxiliary fan monitoring is not enabled on ASRock Z77 Pro4-M with BIOS version 2.00 if booted in UEFI Ultra-FastBoot mode. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-03-15hwmon: (nct6775) Restore hardware monitoring logical device status on resumeGuenter Roeck1-13/+22
After a suspend/resume cycle it is not guaranteed that the hardware monitoring device is still enabled. Ensure that this is the case after resume. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-03-15hwmon: (nct6775) Convert to use SIMPLE_DEV_PM_OPSGuenter Roeck1-17/+5
Get rid of #ifdef CONFIG_PM by using SIMPLE_DEV_PM_OPS and declaring suspend and resume functions with __maybe_unused. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-12-15Merge tag 'driver-core-3.19-rc1' of ↵Linus Torvalds1-1/+0
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core update from Greg KH: "Here's the set of driver core patches for 3.19-rc1. They are dominated by the removal of the .owner field in platform drivers. They touch a lot of files, but they are "simple" changes, just removing a line in a structure. Other than that, a few minor driver core and debugfs changes. There are some ath9k patches coming in through this tree that have been acked by the wireless maintainers as they relied on the debugfs changes. Everything has been in linux-next for a while" * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits) Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries" fs: debugfs: add forward declaration for struct device type firmware class: Deletion of an unnecessary check before the function call "vunmap" firmware loader: fix hung task warning dump devcoredump: provide a one-way disable function device: Add dev_<level>_once variants ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries ath: use seq_file api for ath9k debugfs files debugfs: add helper function to create device related seq_file drivers/base: cacheinfo: remove noisy error boot message Revert "core: platform: add warning if driver has no owner" drivers: base: support cpu cache information interface to userspace via sysfs drivers: base: add cpu_device_create to support per-cpu devices topology: replace custom attribute macros with standard DEVICE_ATTR* cpumask: factor out show_cpumap into separate helper function driver core: Fix unbalanced device reference in drivers_probe driver core: fix race with userland in device_add() sysfs/kernfs: make read requests on pre-alloc files use the buffer. sysfs/kernfs: allow attributes to request write buffer be pre-allocated. fs: sysfs: return EGBIG on write if offset is larger than file size ...
2014-12-01hwmon: (nct6775) Add blank lines after declarationsGuenter Roeck1-6/+24
checkpatch complains about WARNING: Missing a blank line after declarations Add missing blank lines. Also reorder variables length-wise where appropriate if a function header is touched anyway. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>