1 From 8c9c4ed500e92c10dc4965dcd00692b3102a328a Mon Sep 17 00:00:00 2001
2 From: Sascha Hauer <s.hauer@pengutronix.de>
3 Date: Wed, 13 May 2015 10:52:37 +0200
4 Subject: [PATCH 18/76] thermal: of: always set sensor related callbacks
6 Now that the thermal core treats -ENOSYS like the callbacks were
7 not present at all we no longer have to overwrite the ops during
8 runtime but instead can always set them and return -ENOSYS if no
11 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
13 drivers/thermal/of-thermal.c | 33 +++++++++++++--------------------
14 1 file changed, 13 insertions(+), 20 deletions(-)
16 --- a/drivers/thermal/of-thermal.c
17 +++ b/drivers/thermal/of-thermal.c
18 @@ -91,7 +91,7 @@ static int of_thermal_get_temp(struct th
20 struct __thermal_zone *data = tz->devdata;
22 - if (!data->ops->get_temp)
26 return data->ops->get_temp(data->sensor_data, temp);
27 @@ -178,7 +178,7 @@ static int of_thermal_set_emul_temp(stru
28 struct __thermal_zone *data = tz->devdata;
30 if (!data->ops || !data->ops->set_emul_temp)
34 return data->ops->set_emul_temp(data->sensor_data, temp);
36 @@ -189,8 +189,8 @@ static int of_thermal_get_trend(struct t
37 struct __thermal_zone *data = tz->devdata;
40 - if (!data->ops->get_trend)
42 + if (!data->ops || !data->ops->get_trend)
45 r = data->ops->get_trend(data->sensor_data, trip, trend);
47 @@ -366,6 +366,10 @@ static int of_thermal_get_crit_temp(stru
50 static struct thermal_zone_device_ops of_thermal_ops = {
51 + .get_temp = of_thermal_get_temp,
52 + .get_trend = of_thermal_get_trend,
53 + .set_emul_temp = of_thermal_set_emul_temp,
55 .get_mode = of_thermal_get_mode,
56 .set_mode = of_thermal_set_mode,
58 @@ -399,13 +403,13 @@ thermal_zone_of_add_sensor(struct device
60 return ERR_PTR(-EINVAL);
63 + return ERR_PTR(-EINVAL);
65 mutex_lock(&tzd->lock);
67 tz->sensor_data = data;
69 - tzd->ops->get_temp = of_thermal_get_temp;
70 - tzd->ops->get_trend = of_thermal_get_trend;
71 - tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
72 mutex_unlock(&tzd->lock);
75 @@ -535,9 +539,6 @@ void thermal_zone_of_sensor_unregister(s
78 mutex_lock(&tzd->lock);
79 - tzd->ops->get_temp = NULL;
80 - tzd->ops->get_trend = NULL;
81 - tzd->ops->set_emul_temp = NULL;
84 tz->sensor_data = NULL;
85 @@ -845,7 +846,6 @@ int __init of_parse_thermal_zones(void)
87 struct device_node *np, *child;
88 struct __thermal_zone *tz;
89 - struct thermal_zone_device_ops *ops;
91 np = of_find_node_by_name(NULL, "thermal-zones");
93 @@ -869,29 +869,22 @@ int __init of_parse_thermal_zones(void)
97 - ops = kmemdup(&of_thermal_ops, sizeof(*ops), GFP_KERNEL);
101 tzp = kzalloc(sizeof(*tzp), GFP_KERNEL);
108 /* No hwmon because there might be hwmon drivers registering */
109 tzp->no_hwmon = true;
111 zone = thermal_zone_device_register(child->name, tz->ntrips,
114 + &of_thermal_ops, tzp,
118 pr_err("Failed to build %s zone %ld\n", child->name,
122 of_thermal_free_zone(tz);
123 /* attempting to build remaining zones still */