]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/thermal/thermal_hwmon.c
Merge tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[linux.git] / drivers / thermal / thermal_hwmon.c
index dd5d8ee3792870fccbff4c5ab0b7fb251d007612..c8d2620f2e42712dbeb4390828d4f26f419bc694 100644 (file)
@@ -248,3 +248,31 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
        kfree(hwmon);
 }
 EXPORT_SYMBOL_GPL(thermal_remove_hwmon_sysfs);
+
+static void devm_thermal_hwmon_release(struct device *dev, void *res)
+{
+       thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res);
+}
+
+int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
+{
+       struct thermal_zone_device **ptr;
+       int ret;
+
+       ptr = devres_alloc(devm_thermal_hwmon_release, sizeof(*ptr),
+                          GFP_KERNEL);
+       if (!ptr)
+               return -ENOMEM;
+
+       ret = thermal_add_hwmon_sysfs(tz);
+       if (ret) {
+               devres_free(ptr);
+               return ret;
+       }
+
+       *ptr = tz;
+       devres_add(&tz->device, ptr);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(devm_thermal_add_hwmon_sysfs);