Merge back thermal control material for 6.3.
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 27 Jan 2023 14:55:23 +0000 (15:55 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 27 Jan 2023 14:55:23 +0000 (15:55 +0100)
1  2 
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h

index 0a4eaa307156d6d24936ea85960e632a32f51351,228f44260b27771ed96062d6477d939498c51a0d..40c1e8a8bc1b3792046af9a9baa2d9c30ac884af
@@@ -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);
index 8f9872afd0d3c70a7af2060c09de71474760a6fc,e28ab1ba5e0622d491d6b99364a0c35082e4697e..6610a9cc441bc91a6d543e86f43c8cfe13926744
@@@ -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 *,