hwmon: (max6650) Introduce pwm_to_dac and dac_to_pwm
authorGuenter Roeck <linux@roeck-us.net>
Fri, 7 Jun 2019 17:23:17 +0000 (10:23 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 24 Jun 2019 01:33:01 +0000 (18:33 -0700)
commitb2905bb8e1f3764c21e449931f3fb75405f7d41e
treed880eee8fda6e9b52f252c002a5e17209785a2b3
parent8e5e7ddd38b69ef48a2104cd663fab0e3dd03e14
hwmon: (max6650) Introduce pwm_to_dac and dac_to_pwm

Consolidate conversion from pwm value to dac value and from dac value
to pwm value into helper functions.

While doing this, only update the cached dac value if writing it
to the chip was successful after an update. Also, put macro argument
of DIV_FROM_REG() into (), and simplify return statement of
max6650_set_cur_state().

Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/max6650.c