• Zev Weiss's avatar
    hwmon: (nct6775) Convert register access to regmap API · 4ef27745
    Zev Weiss authored
    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: default avatarZev Weiss <zev@bewilderbeest.net>
    Reviewed-by: default avatarJoel Stanley <joel@jms.id.au>
    Link: https://lore.kernel.org/r/20220427010154.29749-3-zev@bewilderbeest.netTested-by: default avatarOleksandr Natalenko <oleksandr@natalenko.name>
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    4ef27745
nct6775.c 154 KB