Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1220168

[PATCH v5 1/5] thermal: Add a function to get the minimum power

From Javi Merino <javi.merino@arm.com>
Newsgroups linux.kernel
Subject [PATCH v5 1/5] thermal: Add a function to get the minimum power
Date 2015-09-07 15:30 +0200
Message-ID <q64EG-6NN-3@gated-at.bofh.it> (permalink)
References <q1IW5-6Yn-9@gated-at.bofh.it> <q64uZ-6CG-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The thermal core already has a function to get the maximum power of a
cooling device: power_actor_get_max_power().  Add a function to get the
minimum power of a cooling device.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Javi Merino <javi.merino@arm.com>
---
 drivers/thermal/thermal_core.c | 28 ++++++++++++++++++++++++++++
 include/linux/thermal.h        |  6 ++++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 4ca211be4c0f..760204f0b63c 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -997,6 +997,34 @@ int power_actor_get_max_power(struct thermal_cooling_device *cdev,
 }
 
 /**
+ * power_actor_get_min_power() - get the mainimum power that a cdev can consume
+ * @cdev:	pointer to &thermal_cooling_device
+ * @tz:		a valid thermal zone device pointer
+ * @min_power:	pointer in which to store the minimum power
+ *
+ * Calculate the minimum power consumption in milliwatts that the
+ * cooling device can currently consume and store it in @min_power.
+ *
+ * Return: 0 on success, -EINVAL if @cdev doesn't support the
+ * power_actor API or -E* on other error.
+ */
+int power_actor_get_min_power(struct thermal_cooling_device *cdev,
+			      struct thermal_zone_device *tz, u32 *min_power)
+{
+	unsigned long max_state;
+	int ret;
+
+	if (!cdev_is_power_actor(cdev))
+		return -EINVAL;
+
+	ret = cdev->ops->get_max_state(cdev, &max_state);
+	if (ret)
+		return ret;
+
+	return cdev->ops->state2power(cdev, tz, max_state, min_power);
+}
+
+/**
  * power_actor_set_power() - limit the maximum power that a cooling device can consume
  * @cdev:	pointer to &thermal_cooling_device
  * @instance:	thermal instance to update
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 037e9df2f610..f99d934d373a 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -384,6 +384,8 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
 
 int power_actor_get_max_power(struct thermal_cooling_device *,
 			      struct thermal_zone_device *tz, u32 *max_power);
+int power_actor_get_min_power(struct thermal_cooling_device *,
+			      struct thermal_zone_device *tz, u32 *min_power);
 int power_actor_set_power(struct thermal_cooling_device *,
 			  struct thermal_instance *, u32);
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
@@ -419,6 +421,10 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
 static inline int power_actor_get_max_power(struct thermal_cooling_device *cdev,
 			      struct thermal_zone_device *tz, u32 *max_power)
 { return 0; }
+static inline int power_actor_get_min_power(struct thermal_cooling_device *cdev,
+					    struct thermal_zone_device *tz,
+					    u32 *min_power)
+{ return -ENODEV; }
 static inline int power_actor_set_power(struct thermal_cooling_device *cdev,
 			  struct thermal_instance *tz, u32 power)
 { return 0; }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 0/5] Let the power allocator thermal governor run on any thermal zone Javi Merino <javi.merino@arm.com> - 2015-08-26 15:30 +0200
  [PATCH v4 5/5] thermal: power_allocator: exit early if there are no cooling devices Javi Merino <javi.merino@arm.com> - 2015-08-26 15:30 +0200
  [PATCH v4 4/5] thermal: power_allocator: don't require tzp to be present for the thermal zone Javi Merino <javi.merino@arm.com> - 2015-08-26 15:30 +0200
    Re: [PATCH v4 4/5] thermal: power_allocator: don't require tzp to be  present for the thermal zone Daniel Kurtz <djkurtz@chromium.org> - 2015-08-28 04:20 +0200
      Re: [PATCH v4 4/5] thermal: power_allocator: don't require tzp to be  present for the thermal zone Javi Merino <javi.merino@arm.com> - 2015-08-28 18:30 +0200
        Re: [PATCH v4 4/5] thermal: power_allocator: don't require tzp to be  present for the thermal zone Daniel Kurtz <djkurtz@chromium.org> - 2015-08-31 15:20 +0200
  [PATCH v4 1/5] thermal: Add a function to get the minimum power Javi Merino <javi.merino@arm.com> - 2015-08-26 15:30 +0200
  Re: [PATCH v4 0/5] Let the power allocator thermal governor run on  any thermal zone Javi Merino <javi.merino@arm.com> - 2015-09-02 17:20 +0200
  [PATCH v5 0/5] Let the power allocator thermal governor run on any thermal zone Javi Merino <javi.merino@arm.com> - 2015-09-07 15:20 +0200
    [PATCH v5 1/5] thermal: Add a function to get the minimum power Javi Merino <javi.merino@arm.com> - 2015-09-07 15:30 +0200
    [PATCH v5 3/5] thermal: power_allocator: relax the requirement of two passive trip points Javi Merino <javi.merino@arm.com> - 2015-09-07 15:30 +0200
    [PATCH v5 5/5] thermal: power_allocator: exit early if there are no cooling devices Javi Merino <javi.merino@arm.com> - 2015-09-07 15:30 +0200
    [PATCH v5 2/5] thermal: power_allocator: relax the requirement of a sustainable_power in tzp Javi Merino <javi.merino@arm.com> - 2015-09-07 15:30 +0200
    [PATCH v5 4/5] thermal: power_allocator: don't require tzp to be present for the thermal zone Javi Merino <javi.merino@arm.com> - 2015-09-07 15:30 +0200
    Re: [PATCH v5 0/5] Let the power allocator thermal governor run on  any thermal zone Daniel Kurtz <djkurtz@chromium.org> - 2015-09-08 03:50 +0200
    [PATCH v6 0/5] Let the power allocator thermal governor run on any thermal zone Javi Merino <javi.merino@arm.com> - 2015-09-14 15:30 +0200
      [PATCH v6 5/5] thermal: power_allocator: exit early if there are no cooling devices Javi Merino <javi.merino@arm.com> - 2015-09-14 15:30 +0200
      [PATCH v6 3/5] thermal: power_allocator: relax the requirement of two passive trip points Javi Merino <javi.merino@arm.com> - 2015-09-14 15:30 +0200
      [PATCH v6 4/5] thermal: power_allocator: don't require tzp to be present for the thermal zone Javi Merino <javi.merino@arm.com> - 2015-09-14 15:30 +0200
      [PATCH v6 2/5] thermal: power_allocator: relax the requirement of a sustainable_power in tzp Javi Merino <javi.merino@arm.com> - 2015-09-14 15:40 +0200
      [PATCH v6 1/5] thermal: Add a function to get the minimum power Javi Merino <javi.merino@arm.com> - 2015-09-14 15:40 +0200
  Re: [PATCH v4 0/5] Let the power allocator thermal governor run on  any thermal zone Eduardo Valentin <edubezval@gmail.com> - 2015-09-14 05:10 +0200
    Re: [PATCH v4 0/5] Let the power allocator thermal governor run on  any thermal zone Javi Merino <javi.merino@arm.com> - 2015-09-14 15:40 +0200

csiph-web