| .. | .. |
|---|
| 10 | 10 | * Copyright (C) 2013 Texas Instruments |
|---|
| 11 | 11 | * Copyright (C) 2013 Eduardo Valentin <eduardo.valentin@ti.com> |
|---|
| 12 | 12 | */ |
|---|
| 13 | | -#include <linux/hwmon.h> |
|---|
| 14 | | -#include <linux/thermal.h> |
|---|
| 15 | | -#include <linux/slab.h> |
|---|
| 16 | 13 | #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 | + |
|---|
| 17 | 19 | #include "thermal_hwmon.h" |
|---|
| 18 | 20 | |
|---|
| 19 | 21 | /* hwmon sys I/F */ |
|---|
| .. | .. |
|---|
| 248 | 250 | kfree(hwmon); |
|---|
| 249 | 251 | } |
|---|
| 250 | 252 | 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); |
|---|