summaryrefslogtreecommitdiff
path: root/drivers/thermal/thermal_of.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/thermal_of.c')
-rw-r--r--drivers/thermal/thermal_of.c37
1 files changed, 13 insertions, 24 deletions
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 4d6c22e0ed85..f1cbf9aa62cf 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -117,6 +117,8 @@ static int thermal_of_populate_trip(struct device_node *np,
return ret;
}
+ trip->flags = THERMAL_TRIP_FLAG_RW_TEMP;
+
return 0;
}
@@ -438,13 +440,8 @@ static int thermal_of_unbind(struct thermal_zone_device *tz,
*/
static void thermal_of_zone_unregister(struct thermal_zone_device *tz)
{
- struct thermal_trip *trips = tz->trips;
- struct thermal_zone_device_ops *ops = tz->ops;
-
thermal_zone_device_disable(tz);
thermal_zone_device_unregister(tz);
- kfree(trips);
- kfree(ops);
}
/**
@@ -470,33 +467,27 @@ static void thermal_of_zone_unregister(struct thermal_zone_device *tz)
static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
const struct thermal_zone_device_ops *ops)
{
+ struct thermal_zone_device_ops of_ops = *ops;
struct thermal_zone_device *tz;
struct thermal_trip *trips;
struct thermal_zone_params tzp = {};
- struct thermal_zone_device_ops *of_ops;
struct device_node *np;
const char *action;
int delay, pdelay;
- int ntrips, mask;
+ int ntrips;
int ret;
- of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
- if (!of_ops)
- return ERR_PTR(-ENOMEM);
-
np = of_thermal_zone_find(sensor, id);
if (IS_ERR(np)) {
if (PTR_ERR(np) != -ENODEV)
pr_err("Failed to find thermal zone for %pOFn id=%d\n", sensor, id);
- ret = PTR_ERR(np);
- goto out_kfree_of_ops;
+ return ERR_CAST(np);
}
trips = thermal_of_trips_init(np, &ntrips);
if (IS_ERR(trips)) {
pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
- ret = PTR_ERR(trips);
- goto out_kfree_of_ops;
+ return ERR_CAST(trips);
}
ret = thermal_of_monitor_init(np, &delay, &pdelay);
@@ -507,18 +498,16 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
thermal_of_parameters_init(np, &tzp);
- of_ops->bind = thermal_of_bind;
- of_ops->unbind = thermal_of_unbind;
-
- mask = GENMASK_ULL((ntrips) - 1, 0);
+ of_ops.bind = thermal_of_bind;
+ of_ops.unbind = thermal_of_unbind;
ret = of_property_read_string(np, "critical-action", &action);
if (!ret)
- if (!of_ops->critical && !strcasecmp(action, "reboot"))
- of_ops->critical = thermal_zone_device_critical_reboot;
+ if (!of_ops.critical && !strcasecmp(action, "reboot"))
+ of_ops.critical = thermal_zone_device_critical_reboot;
tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
- mask, data, of_ops, &tzp,
+ data, &of_ops, &tzp,
pdelay, delay);
if (IS_ERR(tz)) {
ret = PTR_ERR(tz);
@@ -526,6 +515,8 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
goto out_kfree_trips;
}
+ kfree(trips);
+
ret = thermal_zone_device_enable(tz);
if (ret) {
pr_err("Failed to enabled thermal zone '%s', id=%d: %d\n",
@@ -538,8 +529,6 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
out_kfree_trips:
kfree(trips);
-out_kfree_of_ops:
- kfree(of_ops);
return ERR_PTR(ret);
}