Skip to content

Commit 9e9b7e1

Browse files
committed
thermal: intel: int340x: Use zone lock for synchronization
Because the ->get_trip_temp() and ->get_trip_type() thermal zone callbacks are only invoked from __thermal_zone_get_trip() which is always called by the thermal core under the zone lock, it is sufficient for int340x_thermal_update_trips() to acquire the zone lock for mutual exclusion with those callbacks. Accordingly, modify int340x_thermal_update_trips() to use the zone lock instead of the internal trip_mutex and drop the latter which is not necessary any more. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent b1bf9db commit 9e9b7e1

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ static int int340x_thermal_get_trip_temp(struct thermal_zone_device *zone,
4141
int trip, int *temp)
4242
{
4343
struct int34x_thermal_zone *d = zone->devdata;
44-
int i, ret = 0;
45-
46-
mutex_lock(&d->trip_mutex);
44+
int i;
4745

4846
if (trip < d->aux_trip_nr)
4947
*temp = d->aux_trips[trip];
@@ -62,22 +60,18 @@ static int int340x_thermal_get_trip_temp(struct thermal_zone_device *zone,
6260
}
6361
}
6462
if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT)
65-
ret = -EINVAL;
63+
return -EINVAL;
6664
}
6765

68-
mutex_unlock(&d->trip_mutex);
69-
70-
return ret;
66+
return 0;
7167
}
7268

7369
static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
7470
int trip,
7571
enum thermal_trip_type *type)
7672
{
7773
struct int34x_thermal_zone *d = zone->devdata;
78-
int i, ret = 0;
79-
80-
mutex_lock(&d->trip_mutex);
74+
int i;
8175

8276
if (trip < d->aux_trip_nr)
8377
*type = THERMAL_TRIP_PASSIVE;
@@ -96,12 +90,10 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
9690
}
9791
}
9892
if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT)
99-
ret = -EINVAL;
93+
return -EINVAL;
10094
}
10195

102-
mutex_unlock(&d->trip_mutex);
103-
104-
return ret;
96+
return 0;
10597
}
10698

10799
static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
@@ -222,8 +214,6 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
222214
if (!int34x_thermal_zone)
223215
return ERR_PTR(-ENOMEM);
224216

225-
mutex_init(&int34x_thermal_zone->trip_mutex);
226-
227217
int34x_thermal_zone->adev = adev;
228218

229219
int34x_thermal_zone->ops = kmemdup(&int340x_thermal_zone_ops,
@@ -286,7 +276,6 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
286276
err_trip_alloc:
287277
kfree(int34x_thermal_zone->ops);
288278
err_ops_alloc:
289-
mutex_destroy(&int34x_thermal_zone->trip_mutex);
290279
kfree(int34x_thermal_zone);
291280
return ERR_PTR(ret);
292281
}
@@ -299,7 +288,6 @@ void int340x_thermal_zone_remove(struct int34x_thermal_zone
299288
acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table);
300289
kfree(int34x_thermal_zone->aux_trips);
301290
kfree(int34x_thermal_zone->ops);
302-
mutex_destroy(&int34x_thermal_zone->trip_mutex);
303291
kfree(int34x_thermal_zone);
304292
}
305293
EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove);
@@ -309,7 +297,7 @@ void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone)
309297
acpi_handle zone_handle = int34x_zone->adev->handle;
310298
int i, err;
311299

312-
mutex_lock(&int34x_zone->trip_mutex);
300+
mutex_lock(&int34x_zone->zone->lock);
313301

314302
if (int34x_zone->crt_trip_id > 0) {
315303
err = int340x_thermal_get_trip_config(zone_handle, "_CRT",
@@ -344,7 +332,7 @@ void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone)
344332
int34x_zone->act_trips[i].temp = THERMAL_TEMP_INVALID;
345333
}
346334

347-
mutex_unlock(&int34x_zone->trip_mutex);
335+
mutex_unlock(&int34x_zone->zone->lock);
348336
}
349337
EXPORT_SYMBOL_GPL(int340x_thermal_update_trips);
350338

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ struct int34x_thermal_zone {
3232
struct thermal_zone_device_ops *ops;
3333
void *priv_data;
3434
struct acpi_lpat_conversion_table *lpat_table;
35-
struct mutex trip_mutex;
3635
};
3736

3837
struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *,

0 commit comments

Comments
 (0)