hwmon: (nct6775) Convert register access to regmap API
authorZev Weiss <zev@bewilderbeest.net>
Wed, 27 Apr 2022 01:01:49 +0000 (18:01 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 20 May 2022 17:57:05 +0000 (10:57 -0700)
commit4ef2774511dc6e552228bd6c3fefa2e7d41f38b7
tree49b5284a7f4038721ea8c08bed26f9ba3e49f7f7
parent981c5f3c744bbe2e6420a8a834d52c7ed2a75b7f
hwmon: (nct6775) Convert register access to regmap API

This replaces the nct6775_data->{read,write}_value function pointers
with a regmap.

The major difference is that the regmap access functions may fail, and
hence require checking at each call site.  While the existing WMI
register-access code had potential failure paths, they were masked by
the fact that the read_value() function returned the register value
directly, and hence squashed errors undetectably by simply returning
zero, and while the write_value() functions were capable of reporting
errors, all callers ignored them.

This improves the robustness of the existing code, and also prepares
the driver for an i2c version to be added soon, for which register
accesses are much more likely to actually fail.

The conversion of the register-access call sites is largely mechanical
(reading a register now returns the value via an out-param pointer,
and returned errors must be checked for and propagated to callers),
though the nct6775_write_fan_div() function is refactored slightly to
avoid duplicating nearly identical (and now lengthier) code in each
switch case.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20220427010154.29749-3-zev@bewilderbeest.net
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/nct6775.c