hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/thermal/thermal_hwmon.c
....@@ -10,10 +10,12 @@
1010 * Copyright (C) 2013 Texas Instruments
1111 * Copyright (C) 2013 Eduardo Valentin <eduardo.valentin@ti.com>
1212 */
13
-#include <linux/hwmon.h>
14
-#include <linux/thermal.h>
15
-#include <linux/slab.h>
1613 #include <linux/err.h>
14
+#include <linux/export.h>
15
+#include <linux/hwmon.h>
16
+#include <linux/slab.h>
17
+#include <linux/thermal.h>
18
+
1719 #include "thermal_hwmon.h"
1820
1921 /* hwmon sys I/F */
....@@ -248,3 +250,31 @@
248250 kfree(hwmon);
249251 }
250252 EXPORT_SYMBOL_GPL(thermal_remove_hwmon_sysfs);
253
+
254
+static void devm_thermal_hwmon_release(struct device *dev, void *res)
255
+{
256
+ thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res);
257
+}
258
+
259
+int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
260
+{
261
+ struct thermal_zone_device **ptr;
262
+ int ret;
263
+
264
+ ptr = devres_alloc(devm_thermal_hwmon_release, sizeof(*ptr),
265
+ GFP_KERNEL);
266
+ if (!ptr)
267
+ return -ENOMEM;
268
+
269
+ ret = thermal_add_hwmon_sysfs(tz);
270
+ if (ret) {
271
+ devres_free(ptr);
272
+ return ret;
273
+ }
274
+
275
+ *ptr = tz;
276
+ devres_add(&tz->device, ptr);
277
+
278
+ return ret;
279
+}
280
+EXPORT_SYMBOL_GPL(devm_thermal_add_hwmon_sysfs);