[PATCH v2 2/6] hwmon: (nct6775) Convert register access to regmap API

Guenter Roeck linux at roeck-us.net
Tue Apr 26 01:24:53 AEST 2022


On Tue, Mar 08, 2022 at 04:50:43PM -0800, Zev Weiss wrote:
> 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 at bewilderbeest.net>
> ---
>  drivers/hwmon/nct6775.c | 977 +++++++++++++++++++++++++++-------------

Needs "select REGMAP" in Kconfig.

Guenter


More information about the openbmc mailing list