.. | .. |
---|
44 | 44 | int trip, int *temp) |
---|
45 | 45 | { |
---|
46 | 46 | struct int34x_thermal_zone *d = zone->devdata; |
---|
47 | | - int i; |
---|
| 47 | + int i, ret = 0; |
---|
48 | 48 | |
---|
49 | 49 | if (d->override_ops && d->override_ops->get_trip_temp) |
---|
50 | 50 | return d->override_ops->get_trip_temp(zone, trip, temp); |
---|
| 51 | + |
---|
| 52 | + mutex_lock(&d->trip_mutex); |
---|
51 | 53 | |
---|
52 | 54 | if (trip < d->aux_trip_nr) |
---|
53 | 55 | *temp = d->aux_trips[trip]; |
---|
.. | .. |
---|
66 | 68 | } |
---|
67 | 69 | } |
---|
68 | 70 | if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT) |
---|
69 | | - return -EINVAL; |
---|
| 71 | + ret = -EINVAL; |
---|
70 | 72 | } |
---|
71 | 73 | |
---|
72 | | - return 0; |
---|
| 74 | + mutex_unlock(&d->trip_mutex); |
---|
| 75 | + |
---|
| 76 | + return ret; |
---|
73 | 77 | } |
---|
74 | 78 | |
---|
75 | 79 | static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone, |
---|
.. | .. |
---|
77 | 81 | enum thermal_trip_type *type) |
---|
78 | 82 | { |
---|
79 | 83 | struct int34x_thermal_zone *d = zone->devdata; |
---|
80 | | - int i; |
---|
| 84 | + int i, ret = 0; |
---|
81 | 85 | |
---|
82 | 86 | if (d->override_ops && d->override_ops->get_trip_type) |
---|
83 | 87 | return d->override_ops->get_trip_type(zone, trip, type); |
---|
| 88 | + |
---|
| 89 | + mutex_lock(&d->trip_mutex); |
---|
84 | 90 | |
---|
85 | 91 | if (trip < d->aux_trip_nr) |
---|
86 | 92 | *type = THERMAL_TRIP_PASSIVE; |
---|
.. | .. |
---|
99 | 105 | } |
---|
100 | 106 | } |
---|
101 | 107 | if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT) |
---|
102 | | - return -EINVAL; |
---|
| 108 | + ret = -EINVAL; |
---|
103 | 109 | } |
---|
104 | 110 | |
---|
105 | | - return 0; |
---|
| 111 | + mutex_unlock(&d->trip_mutex); |
---|
| 112 | + |
---|
| 113 | + return ret; |
---|
106 | 114 | } |
---|
107 | 115 | |
---|
108 | 116 | static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, |
---|
.. | .. |
---|
174 | 182 | int trip_cnt = int34x_zone->aux_trip_nr; |
---|
175 | 183 | int i; |
---|
176 | 184 | |
---|
| 185 | + mutex_lock(&int34x_zone->trip_mutex); |
---|
| 186 | + |
---|
177 | 187 | int34x_zone->crt_trip_id = -1; |
---|
178 | 188 | if (!int340x_thermal_get_trip_config(int34x_zone->adev->handle, "_CRT", |
---|
179 | 189 | &int34x_zone->crt_temp)) |
---|
.. | .. |
---|
201 | 211 | int34x_zone->act_trips[i].valid = true; |
---|
202 | 212 | } |
---|
203 | 213 | |
---|
| 214 | + mutex_unlock(&int34x_zone->trip_mutex); |
---|
| 215 | + |
---|
204 | 216 | return trip_cnt; |
---|
205 | 217 | } |
---|
206 | 218 | EXPORT_SYMBOL_GPL(int340x_thermal_read_trips); |
---|
.. | .. |
---|
223 | 235 | GFP_KERNEL); |
---|
224 | 236 | if (!int34x_thermal_zone) |
---|
225 | 237 | return ERR_PTR(-ENOMEM); |
---|
| 238 | + |
---|
| 239 | + mutex_init(&int34x_thermal_zone->trip_mutex); |
---|
226 | 240 | |
---|
227 | 241 | int34x_thermal_zone->adev = adev; |
---|
228 | 242 | int34x_thermal_zone->override_ops = override_ops; |
---|
.. | .. |
---|
275 | 289 | acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); |
---|
276 | 290 | kfree(int34x_thermal_zone->aux_trips); |
---|
277 | 291 | err_trip_alloc: |
---|
| 292 | + mutex_destroy(&int34x_thermal_zone->trip_mutex); |
---|
278 | 293 | kfree(int34x_thermal_zone); |
---|
279 | 294 | return ERR_PTR(ret); |
---|
280 | 295 | } |
---|
.. | .. |
---|
286 | 301 | thermal_zone_device_unregister(int34x_thermal_zone->zone); |
---|
287 | 302 | acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); |
---|
288 | 303 | kfree(int34x_thermal_zone->aux_trips); |
---|
| 304 | + mutex_destroy(&int34x_thermal_zone->trip_mutex); |
---|
289 | 305 | kfree(int34x_thermal_zone); |
---|
290 | 306 | } |
---|
291 | 307 | EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); |
---|