• Guenter Roeck's avatar
    hwmon: (pwm-fan) Use devm_thermal_of_cooling_device_register · 37bcec5d
    Guenter Roeck authored
    Use devm_thermal_of_cooling_device_register() to register the cooling
    device. Also use devm_add_action_or_reset() to stop the fan on device
    removal, and to disable the pwm. Introduce a local 'dev' variable in
    the probe function to make the code easier to read.
    
    As a side effect, this fixes a bug seen if pwm_fan_of_get_cooling_data()
    returned an error. In that situation, the pwm was not disabled, and
    the fan was not stopped. Using devm functions also ensures that the
    pwm is disabled and that the fan is stopped only after the hwmon device
    has been unregistered.
    
    Cc: Lukasz Majewski <l.majewski@samsung.com>
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
    37bcec5d
pwm-fan.c 8.35 KB