Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (npcm750-pwm-fan) Use devm_thermal_of_cooling_device_register

Use devm_thermal_of_cooling_device_register() to register the cooling
device. As a side effect, this fixes a driver bug:
thermal_cooling_device_unregister() was not called on device removal.

Fixes: f1fd4a4db777 ("hwmon: Add NPCM7xx PWM and Fan driver")
Cc: Tomer Maimon <tmaimon77@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>

authored by

Guenter Roeck and committed by
Eduardo Valentin
0b2a785d 9ebe010e

+2 -4
+2 -4
drivers/hwmon/npcm750-pwm-fan.c
··· 864 864 snprintf(cdev->name, THERMAL_NAME_LENGTH, "%pOFn%d", child, 865 865 pwm_port); 866 866 867 - cdev->tcdev = thermal_of_cooling_device_register(child, 868 - cdev->name, 869 - cdev, 870 - &npcm7xx_pwm_cool_ops); 867 + cdev->tcdev = devm_thermal_of_cooling_device_register(dev, child, 868 + cdev->name, cdev, &npcm7xx_pwm_cool_ops); 871 869 if (IS_ERR(cdev->tcdev)) 872 870 return PTR_ERR(cdev->tcdev); 873 871