thermal: core: Move power_actor_set_power into IPA
authorLukasz Luba <lukasz.luba@arm.com>
Thu, 15 Oct 2020 11:24:41 +0000 (12:24 +0100)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Tue, 27 Oct 2020 08:44:32 +0000 (09:44 +0100)
Since the power actor section has one function power_actor_set_power()
move it into Intelligent Power Allocation (IPA). There is no other user
of that helper function. It would also allow to remove the check of
cdev_is_power_actor() because the code which calls it in IPA already does
the needed check. Make the function static since only IPA use it.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20201015112441.4056-5-lukasz.luba@arm.com
drivers/thermal/gov_power_allocator.c
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h

index eb8c9af..b29e21c 100644 (file)
@@ -255,6 +255,38 @@ static u32 pid_controller(struct thermal_zone_device *tz,
 }
 
 /**
+ * power_actor_set_power() - limit the maximum power a cooling device consumes
+ * @cdev:      pointer to &thermal_cooling_device
+ * @instance:  thermal instance to update
+ * @power:     the power in milliwatts
+ *
+ * Set the cooling device to consume at most @power milliwatts. The limit is
+ * expected to be a cap at the maximum power consumption.
+ *
+ * Return: 0 on success, -EINVAL if the cooling device does not
+ * implement the power actor API or -E* for other failures.
+ */
+static int
+power_actor_set_power(struct thermal_cooling_device *cdev,
+                     struct thermal_instance *instance, u32 power)
+{
+       unsigned long state;
+       int ret;
+
+       ret = cdev->ops->power2state(cdev, power, &state);
+       if (ret)
+               return ret;
+
+       instance->target = clamp_val(state, instance->lower, instance->upper);
+       mutex_lock(&cdev->lock);
+       cdev->updated = false;
+       mutex_unlock(&cdev->lock);
+       thermal_cdev_update(cdev);
+
+       return 0;
+}
+
+/**
  * divvy_up_power() - divvy the allocated power between the actors
  * @req_power: each actor's requested power
  * @max_power: each actor's maximum available power
index d5540bf..96349ba 100644 (file)
@@ -593,47 +593,6 @@ static void thermal_zone_device_check(struct work_struct *work)
        thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
 }
 
-/*
- * Power actor section: interface to power actors to estimate power
- *
- * Set of functions used to interact to cooling devices that know
- * how to estimate their devices power consumption.
- */
-
-/**
- * power_actor_set_power() - limit the maximum power a cooling device consumes
- * @cdev:      pointer to &thermal_cooling_device
- * @instance:  thermal instance to update
- * @power:     the power in milliwatts
- *
- * Set the cooling device to consume at most @power milliwatts. The limit is
- * expected to be a cap at the maximum power consumption.
- *
- * Return: 0 on success, -EINVAL if the cooling device does not
- * implement the power actor API or -E* for other failures.
- */
-int power_actor_set_power(struct thermal_cooling_device *cdev,
-                         struct thermal_instance *instance, u32 power)
-{
-       unsigned long state;
-       int ret;
-
-       if (!cdev_is_power_actor(cdev))
-               return -EINVAL;
-
-       ret = cdev->ops->power2state(cdev, power, &state);
-       if (ret)
-               return ret;
-
-       instance->target = clamp_val(state, instance->lower, instance->upper);
-       mutex_lock(&cdev->lock);
-       cdev->updated = false;
-       mutex_unlock(&cdev->lock);
-       thermal_cdev_update(cdev);
-
-       return 0;
-}
-
 void thermal_zone_device_rebind_exception(struct thermal_zone_device *tz,
                                          const char *cdev_type, size_t size)
 {
index 416cdb1..8df600f 100644 (file)
@@ -65,8 +65,6 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
                cdev->ops->power2state;
 }
 
-int power_actor_set_power(struct thermal_cooling_device *cdev,
-                         struct thermal_instance *ti, u32 power);
 /**
  * struct thermal_trip - representation of a point in temperature domain
  * @np: pointer to struct device_node that this trip point was created from