}
EXPORT_SYMBOL_GPL(cpufreq_cooling_register);
+bool cpufreq_cooling_test_related_cpu(struct thermal_cooling_device *cdev,
+ int cpu)
+{
+ struct cpufreq_cooling_device *cpufreq_cdev;
+ struct cpufreq_policy *policy;
+
+ if (cdev && cdev->devdata) {
+ cpufreq_cdev = cdev->devdata;
+ if (cpufreq_cdev->policy) {
+ policy = cpufreq_cdev->policy;
+ if (cpumask_test_cpu(cpu, policy->related_cpus))
+ return true;
+ }
+ }
+
+ return false;
+}
+EXPORT_SYMBOL_GPL(cpufreq_cooling_test_related_cpu);
+
/**
* of_cpufreq_cooling_register - function to create cpufreq cooling device.
* @policy: cpufreq policy
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/cpu_cooling.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>
}
EXPORT_SYMBOL_GPL(thermal_zone_bind_cooling_device);
+static void
+thermal_update_weight(struct thermal_instance *instance, unsigned long weight)
+{
+ instance->weight = weight;
+}
+
+static bool thermal_cdev_in_tz(struct thermal_cooling_device *cdev,
+ struct thermal_zone_device *tz)
+{
+ struct thermal_instance *pos;
+
+ list_for_each_entry(pos, &tz->thermal_instances, tz_node)
+ if (pos->cdev == cdev)
+ return true;
+
+ return false;
+}
+
+int thermal_cpu_cdev_set_weight(int cpu, unsigned long weight)
+{
+ struct thermal_cooling_device *cdev;
+ struct thermal_instance *instance;
+ struct thermal_zone_device *tz;
+
+ mutex_lock(&thermal_list_lock);
+ list_for_each_entry(cdev, &thermal_cdev_list, node) {
+ if (cpufreq_cooling_test_related_cpu(cdev, cpu))
+ goto update;
+ }
+
+ mutex_unlock(&thermal_list_lock);
+ return -ENODEV;
+
+update:
+ mutex_unlock(&thermal_list_lock);
+
+ mutex_lock(&cdev->lock);
+ list_for_each_entry(instance, &cdev->thermal_instances, cdev_node)
+ thermal_update_weight(instance, weight);
+ mutex_unlock(&cdev->lock);
+
+ /* Update thermal zones which are pinned to this cooling device.
+ * It will trigger recalculation of the states.
+ */
+ mutex_lock(&thermal_list_lock);
+ list_for_each_entry(tz, &thermal_tz_list, node) {
+ if (thermal_cdev_in_tz(cdev, tz))
+ thermal_zone_device_update(tz,
+ THERMAL_EVENT_UNSPECIFIED);
+
+ }
+ mutex_unlock(&thermal_list_lock);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(thermal_cpu_cdev_set_weight);
+
+
/**
* thermal_zone_unbind_cooling_device() - unbind a cooling device from a
* thermal zone.
*/
void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
+
+bool cpufreq_cooling_test_related_cpu(struct thermal_cooling_device *cdev,
+ int cpu);
+
#else /* !CONFIG_CPU_THERMAL */
static inline struct thermal_cooling_device *
cpufreq_cooling_register(struct cpufreq_policy *policy)
{
return;
}
+
+static inline
+bool cpufreq_cooling_test_related_cpu(struct thermal_cooling_device *cdev,
+ int cpu)
+{
+ return false;
+}
#endif /* CONFIG_CPU_THERMAL */
#if defined(CONFIG_THERMAL_OF) && defined(CONFIG_CPU_THERMAL)
struct thermal_cooling_device *, int);
void thermal_cdev_update(struct thermal_cooling_device *);
void thermal_notify_framework(struct thermal_zone_device *, int);
+int thermal_cpu_cdev_set_weight(int cpu, unsigned long weight);
#else
static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
{ return false; }
static inline void thermal_notify_framework(struct thermal_zone_device *tz,
int trip)
{ }
+static inline
+int thermal_cpu_cdev_set_weight(int cpu, unsigned long weight) {}
#endif /* CONFIG_THERMAL */
#if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL)