From: Rafael J. Wysocki Date: Fri, 27 Jan 2023 14:55:23 +0000 (+0100) Subject: Merge back thermal control material for 6.3. X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=79b2027097dd3046ff95a2701af441405f1ff298;p=linux.git Merge back thermal control material for 6.3. --- 79b2027097dd3046ff95a2701af441405f1ff298 diff --cc drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 0a4eaa307156d,228f44260b277..40c1e8a8bc1b3 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@@ -44,12 -41,7 +41,9 @@@ static int int340x_thermal_get_trip_tem int trip, int *temp) { struct int34x_thermal_zone *d = zone->devdata; - int i; + int i, ret = 0; + - if (d->override_ops && d->override_ops->get_trip_temp) - return d->override_ops->get_trip_temp(zone, trip, temp); - + mutex_lock(&d->trip_mutex); if (trip < d->aux_trip_nr) *temp = d->aux_trips[trip]; @@@ -81,12 -71,7 +75,9 @@@ static int int340x_thermal_get_trip_typ enum thermal_trip_type *type) { struct int34x_thermal_zone *d = zone->devdata; - int i; + int i, ret = 0; + - if (d->override_ops && d->override_ops->get_trip_type) - return d->override_ops->get_trip_type(zone, trip, type); - + mutex_lock(&d->trip_mutex); if (trip < d->aux_trip_nr) *type = THERMAL_TRIP_PASSIVE; @@@ -242,10 -215,17 +227,19 @@@ struct int34x_thermal_zone *int340x_the if (!int34x_thermal_zone) return ERR_PTR(-ENOMEM); + mutex_init(&int34x_thermal_zone->trip_mutex); + int34x_thermal_zone->adev = adev; - int34x_thermal_zone->override_ops = override_ops; + + int34x_thermal_zone->ops = kmemdup(&int340x_thermal_zone_ops, + sizeof(int340x_thermal_zone_ops), GFP_KERNEL); + if (!int34x_thermal_zone->ops) { + ret = -ENOMEM; + goto err_ops_alloc; + } + + if (get_temp) + int34x_thermal_zone->ops->get_temp = get_temp; status = acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt); if (ACPI_FAILURE(status)) @@@ -295,7 -275,8 +289,9 @@@ err_thermal_zone acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); err_trip_alloc: + kfree(int34x_thermal_zone->ops); + err_ops_alloc: + mutex_destroy(&int34x_thermal_zone->trip_mutex); kfree(int34x_thermal_zone); return ERR_PTR(ret); } @@@ -307,7 -288,7 +303,8 @@@ void int340x_thermal_zone_remove(struc thermal_zone_device_unregister(int34x_thermal_zone->zone); acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); + kfree(int34x_thermal_zone->ops); + mutex_destroy(&int34x_thermal_zone->trip_mutex); kfree(int34x_thermal_zone); } EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); diff --cc drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h index 8f9872afd0d3c,e28ab1ba5e062..6610a9cc441bc --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h @@@ -29,10 -29,9 +29,10 @@@ struct int34x_thermal_zone int hot_temp; int hot_trip_id; struct thermal_zone_device *zone; - struct thermal_zone_device_ops *override_ops; + struct thermal_zone_device_ops *ops; void *priv_data; struct acpi_lpat_conversion_table *lpat_table; + struct mutex trip_mutex; }; struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *,