Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1516777 > unrolled thread
| Started by | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| First post | 2016-11-08 06:10 +0100 |
| Last post | 2016-11-08 10:10 +0100 |
| Articles | 10 on this page of 50 — 1 participant |
Back to article view | Back to linux.kernel
[PATCHv2 00/49] thermal: reorganizing thermal core Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:10 +0100
[PATCHv2 03/49] thermal: core: group device_create_file() calls that are always created Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:10 +0100
[PATCHv2 16/49] thermal: core: split passive_store Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 18/49] thermal: core: split available_policies_show() Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 30/49] thermal: core: move __unbind() helper to where it is used Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 39/49] thermal: core: add a comment describing the device management section Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 24/49] thermal: core: move cooling device sysfs to thermal_sysfs.c Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 37/49] thermal: core: add a comment describing the main update loop Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 36/49] thermal: core: move notify to the zone update section Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 05/49] thermal: core: move emul_temp creation to tz->device.groups Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 07/49] thermal: core: move passive attr to tz->device.groups Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 38/49] thermal: core: add a comment describing the power actor section Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 12/49] thermal: core: move the trip attrs to the tz sysfs I/F section Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 09/49] thermal: core: move power actor code out of sysfs I/F section Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 46/49] thermal: core: improve kerneldoc entry of thermal_cooling_device_unregister Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 48/49] thermal: sysfs: use kcalloc() instead of kzalloc() Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 17/49] thermal: core: split policy_store Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 23/49] thermal: core: move to_cooling_device macro to header file Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 33/49] thermal: core: fix couple of style issues on __bind() helper Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 19/49] thermal: core: move to_thermal_zone() macro to header file Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 21/49] thermal: core: match parenthesis on code alignment Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 43/49] thermal: core: standardize line breaking alignment Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 22/49] thermal: core: move thermal_zone sysfs to thermal_sysfs.c Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 40/49] thermal: sysfs: remove symbols of emul_temp when config is disabled Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 11/49] thermal: core: fix style on remove_trip_attrs() Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 32/49] thermal: core: move bind_tz() to where it is used Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 41/49] thermal: core: remove FSF address in the GPL notice Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 02/49] thermal: core: group thermal_zone DEVICE_ATTR's declarations Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 14/49] thermal: core: move trips attributes to tz->device.groups Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 20/49] thermal: core: treat correctly the return value of *scanf calls Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:20 +0100
[PATCHv2 29/49] thermal: core: small style fix on __unbind() helper Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 10/49] thermal: core: remove useless empty line Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 28/49] thermal: core: move idr handling to device management section Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 04/49] thermal: core: use dev.groups to manage always present tz attributes Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 06/49] thermal: core: move mode attribute to tz->device.groups Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 01/49] thermal: core: prevent zones with no types to be registered Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 42/49] thermal: core: small style fix when checking for __find_governor() Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 44/49] thermal: core: remove void function return statements Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 27/49] thermal: core: group functions related to governor handling Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 35/49] thermal: core: add inline to print_bind_err_msg() Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 25/49] thermal: core: remove a couple of style issues on helpers Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 13/49] thermal: core: create tz->device.groups dynamically Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 49/49] thermal: core: move slop and offset helpers to thermal_helpers.c Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 31/49] thermal: core: move bind_cdev() to where it is used Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:30 +0100
[PATCHv2 45/49] thermal: core: remove style warnings and checks Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:40 +0100
[PATCHv2 26/49] thermal: core: introduce thermal_helpers.c Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 06:40 +0100
[PATCHv2 47/49] thermal: core: use kzalloc(sizeof(*ptr),...) Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 07:10 +0100
[PATCHv2 15/49] thermal: core: remove unnecessary device_remove() calls Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 07:20 +0100
[PATCHv2 08/49] thermal: core: improve power actor documentation Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 10:00 +0100
[PATCHv2 34/49] thermal: core: move __bind() to where it is used Eduardo Valentin <edubezval@gmail.com> - 2016-11-08 10:10 +0100
Page 3 of 3 — ← Prev page 1 2 [3]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 06:30 +0100 |
| Subject | [PATCHv2 25/49] thermal: core: remove a couple of style issues on helpers |
| Message-ID | <sB78S-572-19@gated-at.bofh.it> |
| In reply to | #1516777 |
Reorganizing the code of helper functions to improve
readability and style, as recommended by checkpatch.pl.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/thermal_core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index fb19021..3a189fd 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -248,8 +248,9 @@ int get_tz_trend(struct thermal_zone_device *tz, int trip)
}
EXPORT_SYMBOL(get_tz_trend);
-struct thermal_instance *get_thermal_instance(struct thermal_zone_device *tz,
- struct thermal_cooling_device *cdev, int trip)
+struct thermal_instance *
+get_thermal_instance(struct thermal_zone_device *tz,
+ struct thermal_cooling_device *cdev, int trip)
{
struct thermal_instance *pos = NULL;
struct thermal_instance *target_instance = NULL;
@@ -513,7 +514,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
if (!ret && *temp < crit_temp)
*temp = tz->emul_temperature;
}
-
+
mutex_unlock(&tz->lock);
exit:
return ret;
@@ -1192,7 +1193,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
/* Make sure cdev enters the deepest cooling state */
list_for_each_entry(instance, &cdev->thermal_instances, cdev_node) {
dev_dbg(&cdev->device, "zone%d->target=%lu\n",
- instance->tz->id, instance->target);
+ instance->tz->id, instance->target);
if (instance->target == THERMAL_NO_TARGET)
continue;
if (instance->target > target)
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 06:30 +0100 |
| Subject | [PATCHv2 13/49] thermal: core: create tz->device.groups dynamically |
| Message-ID | <sB78S-572-31@gated-at.bofh.it> |
| In reply to | #1516777 |
This is a patch to allow adding groups created dynamically. For now we
create only the existing group. However, this is a preparation to allow
creating trip groups, which are determined only when the number of trips
are known at runtime.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/thermal_core.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index e399ae6..971f033 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1236,7 +1236,7 @@ static const struct attribute_group *thermal_zone_attribute_groups[] = {
&thermal_zone_attribute_group,
&thermal_zone_mode_attribute_group,
&thermal_zone_passive_attribute_group,
- NULL
+ /* This is not NULL terminated as we create the group dynamically */
};
/**
@@ -1347,6 +1347,25 @@ static void remove_trip_attrs(struct thermal_zone_device *tz)
kfree(tz->trip_hyst_attrs);
}
+static int thermal_zone_create_device_groups(struct thermal_zone_device *tz)
+{
+ const struct attribute_group **groups;
+ int i, size;
+
+ size = ARRAY_SIZE(thermal_zone_attribute_groups) + 1;
+ /* This also takes care of API requirement to be NULL terminated */
+ groups = kcalloc(size, sizeof(*groups), GFP_KERNEL);
+ if (!groups)
+ return -ENOMEM;
+
+ for (i = 0; i < size - 1; i++)
+ groups[i] = thermal_zone_attribute_groups[i];
+
+ tz->device.groups = groups;
+
+ return 0;
+}
+
/* sys I/F for cooling device */
#define to_cooling_device(_dev) \
container_of(_dev, struct thermal_cooling_device, device)
@@ -1982,7 +2001,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
tz->polling_delay = polling_delay;
/* Add nodes that are always present via .groups */
- tz->device.groups = thermal_zone_attribute_groups;
+ thermal_zone_create_device_groups(tz);
/* A new thermal zone needs to be updated anyway. */
atomic_set(&tz->need_update, 1);
@@ -2111,7 +2130,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
idr_destroy(&tz->idr);
mutex_destroy(&tz->lock);
device_unregister(&tz->device);
- return;
+ kfree(tz->device.groups);
}
EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 06:30 +0100 |
| Subject | [PATCHv2 49/49] thermal: core: move slop and offset helpers to thermal_helpers.c |
| Message-ID | <sB78S-572-23@gated-at.bofh.it> |
| In reply to | #1516777 |
Reorganize code to reflect better placement.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/thermal_core.c | 30 ------------------------------
drivers/thermal/thermal_helpers.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 4f93844..7daffc1 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1358,36 +1358,6 @@ struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name)
}
EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name);
-/**
- * thermal_zone_get_slope - return the slope attribute of the thermal zone
- * @tz: thermal zone device with the slope attribute
- *
- * Return: If the thermal zone device has a slope attribute, return it, else
- * return 1.
- */
-int thermal_zone_get_slope(struct thermal_zone_device *tz)
-{
- if (tz && tz->tzp)
- return tz->tzp->slope;
- return 1;
-}
-EXPORT_SYMBOL_GPL(thermal_zone_get_slope);
-
-/**
- * thermal_zone_get_offset - return the offset attribute of the thermal zone
- * @tz: thermal zone device with the offset attribute
- *
- * Return: If the thermal zone device has a offset attribute, return it, else
- * return 0.
- */
-int thermal_zone_get_offset(struct thermal_zone_device *tz)
-{
- if (tz && tz->tzp)
- return tz->tzp->offset;
- return 0;
-}
-EXPORT_SYMBOL_GPL(thermal_zone_get_offset);
-
#ifdef CONFIG_NET
static const struct genl_multicast_group thermal_event_mcgrps[] = {
{ .name = THERMAL_GENL_MCAST_GROUP_NAME, },
diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
index dfdba5a..8cdf75a 100644
--- a/drivers/thermal/thermal_helpers.c
+++ b/drivers/thermal/thermal_helpers.c
@@ -194,3 +194,33 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
dev_dbg(&cdev->device, "set to state %lu\n", target);
}
EXPORT_SYMBOL(thermal_cdev_update);
+
+/**
+ * thermal_zone_get_slope - return the slope attribute of the thermal zone
+ * @tz: thermal zone device with the slope attribute
+ *
+ * Return: If the thermal zone device has a slope attribute, return it, else
+ * return 1.
+ */
+int thermal_zone_get_slope(struct thermal_zone_device *tz)
+{
+ if (tz && tz->tzp)
+ return tz->tzp->slope;
+ return 1;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_get_slope);
+
+/**
+ * thermal_zone_get_offset - return the offset attribute of the thermal zone
+ * @tz: thermal zone device with the offset attribute
+ *
+ * Return: If the thermal zone device has a offset attribute, return it, else
+ * return 0.
+ */
+int thermal_zone_get_offset(struct thermal_zone_device *tz)
+{
+ if (tz && tz->tzp)
+ return tz->tzp->offset;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_get_offset);
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 06:30 +0100 |
| Subject | [PATCHv2 31/49] thermal: core: move bind_cdev() to where it is used |
| Message-ID | <sB78S-572-25@gated-at.bofh.it> |
| In reply to | #1516777 |
Moving the helper to closer where it is used.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/thermal_core.c | 76 +++++++++++++++++++++---------------------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c121933..e397d88 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -319,44 +319,6 @@ static void __bind(struct thermal_zone_device *tz, int mask,
}
}
-static void bind_cdev(struct thermal_cooling_device *cdev)
-{
- int i, ret;
- const struct thermal_zone_params *tzp;
- struct thermal_zone_device *pos = NULL;
-
- mutex_lock(&thermal_list_lock);
-
- list_for_each_entry(pos, &thermal_tz_list, node) {
- if (!pos->tzp && !pos->ops->bind)
- continue;
-
- if (pos->ops->bind) {
- ret = pos->ops->bind(pos, cdev);
- if (ret)
- print_bind_err_msg(pos, cdev, ret);
- continue;
- }
-
- tzp = pos->tzp;
- if (!tzp || !tzp->tbp)
- continue;
-
- for (i = 0; i < tzp->num_tbps; i++) {
- if (tzp->tbp[i].cdev || !tzp->tbp[i].match)
- continue;
- if (tzp->tbp[i].match(pos, cdev))
- continue;
- tzp->tbp[i].cdev = cdev;
- __bind(pos, tzp->tbp[i].trip_mask, cdev,
- tzp->tbp[i].binding_limits,
- tzp->tbp[i].weight);
- }
- }
-
- mutex_unlock(&thermal_list_lock);
-}
-
static void bind_tz(struct thermal_zone_device *tz)
{
int i, ret;
@@ -889,6 +851,44 @@ static struct class thermal_class = {
.dev_release = thermal_release,
};
+static void bind_cdev(struct thermal_cooling_device *cdev)
+{
+ int i, ret;
+ const struct thermal_zone_params *tzp;
+ struct thermal_zone_device *pos = NULL;
+
+ mutex_lock(&thermal_list_lock);
+
+ list_for_each_entry(pos, &thermal_tz_list, node) {
+ if (!pos->tzp && !pos->ops->bind)
+ continue;
+
+ if (pos->ops->bind) {
+ ret = pos->ops->bind(pos, cdev);
+ if (ret)
+ print_bind_err_msg(pos, cdev, ret);
+ continue;
+ }
+
+ tzp = pos->tzp;
+ if (!tzp || !tzp->tbp)
+ continue;
+
+ for (i = 0; i < tzp->num_tbps; i++) {
+ if (tzp->tbp[i].cdev || !tzp->tbp[i].match)
+ continue;
+ if (tzp->tbp[i].match(pos, cdev))
+ continue;
+ tzp->tbp[i].cdev = cdev;
+ __bind(pos, tzp->tbp[i].trip_mask, cdev,
+ tzp->tbp[i].binding_limits,
+ tzp->tbp[i].weight);
+ }
+ }
+
+ mutex_unlock(&thermal_list_lock);
+}
+
/**
* __thermal_cooling_device_register() - register a new thermal cooling device
* @np: a pointer to a device tree node.
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 06:40 +0100 |
| Subject | [PATCHv2 45/49] thermal: core: remove style warnings and checks |
| Message-ID | <sB7ix-5a0-1@gated-at.bofh.it> |
| In reply to | #1516777 |
Removing several style issues in thermal code code.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/thermal_core.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 8365d0b..e3cdba5 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -718,10 +718,10 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
mutex_lock(&tz->lock);
mutex_lock(&cdev->lock);
list_for_each_entry(pos, &tz->thermal_instances, tz_node)
- if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
- result = -EEXIST;
- break;
- }
+ if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
+ result = -EEXIST;
+ break;
+ }
if (!result) {
list_add_tail(&dev->tz_node, &tz->thermal_instances);
list_add_tail(&dev->cdev_node, &cdev->thermal_instances);
@@ -801,8 +801,8 @@ static void thermal_release(struct device *dev)
sizeof("thermal_zone") - 1)) {
tz = to_thermal_zone(dev);
kfree(tz);
- } else if(!strncmp(dev_name(dev), "cooling_device",
- sizeof("cooling_device") - 1)) {
+ } else if (!strncmp(dev_name(dev), "cooling_device",
+ sizeof("cooling_device") - 1)) {
cdev = to_cooling_device(dev);
kfree(cdev);
}
@@ -1036,8 +1036,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
mutex_lock(&thermal_list_lock);
list_for_each_entry(pos, &thermal_cdev_list, node)
- if (pos == cdev)
- break;
+ if (pos == cdev)
+ break;
if (pos != cdev) {
/* thermal cooling device not found */
mutex_unlock(&thermal_list_lock);
@@ -1241,7 +1241,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
/* Bind cooling devices for this zone */
bind_tz(tz);
- INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check);
+ INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check);
thermal_zone_device_reset(tz);
/* Update the new thermal zone and mark it as already updated. */
@@ -1275,8 +1275,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
mutex_lock(&thermal_list_lock);
list_for_each_entry(pos, &thermal_tz_list, node)
- if (pos == tz)
- break;
+ if (pos == tz)
+ break;
if (pos != tz) {
/* thermal zone device not found */
mutex_unlock(&thermal_list_lock);
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 06:40 +0100 |
| Subject | [PATCHv2 26/49] thermal: core: introduce thermal_helpers.c |
| Message-ID | <sB7ix-5a0-3@gated-at.bofh.it> |
| In reply to | #1516777 |
Here we have a simple code organization. This patch moves
functions that do not need to handle thermal core internal
data structure to thermal_helpers.c file.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/Makefile | 3 +-
drivers/thermal/thermal_core.c | 170 ---------------------------------
drivers/thermal/thermal_helpers.c | 196 ++++++++++++++++++++++++++++++++++++++
3 files changed, 198 insertions(+), 171 deletions(-)
create mode 100644 drivers/thermal/thermal_helpers.c
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 767c3c9..6a3d7b5 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -3,7 +3,8 @@
#
obj-$(CONFIG_THERMAL) += thermal_sys.o
-thermal_sys-y += thermal_core.o thermal_sysfs.o
+thermal_sys-y += thermal_core.o thermal_sysfs.o \
+ thermal_helpers.o
# interface to/from other layers providing sensors
thermal_sys-$(CONFIG_THERMAL_HWMON) += thermal_hwmon.o
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 3a189fd..519aa94 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -230,48 +230,6 @@ static void release_idr(struct idr *idr, struct mutex *lock, int id)
mutex_unlock(lock);
}
-int get_tz_trend(struct thermal_zone_device *tz, int trip)
-{
- enum thermal_trend trend;
-
- if (tz->emul_temperature || !tz->ops->get_trend ||
- tz->ops->get_trend(tz, trip, &trend)) {
- if (tz->temperature > tz->last_temperature)
- trend = THERMAL_TREND_RAISING;
- else if (tz->temperature < tz->last_temperature)
- trend = THERMAL_TREND_DROPPING;
- else
- trend = THERMAL_TREND_STABLE;
- }
-
- return trend;
-}
-EXPORT_SYMBOL(get_tz_trend);
-
-struct thermal_instance *
-get_thermal_instance(struct thermal_zone_device *tz,
- struct thermal_cooling_device *cdev, int trip)
-{
- struct thermal_instance *pos = NULL;
- struct thermal_instance *target_instance = NULL;
-
- mutex_lock(&tz->lock);
- mutex_lock(&cdev->lock);
-
- list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
- if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
- target_instance = pos;
- break;
- }
- }
-
- mutex_unlock(&cdev->lock);
- mutex_unlock(&tz->lock);
-
- return target_instance;
-}
-EXPORT_SYMBOL(get_thermal_instance);
-
static void print_bind_err_msg(struct thermal_zone_device *tz,
struct thermal_cooling_device *cdev, int ret)
{
@@ -472,105 +430,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
monitor_thermal_zone(tz);
}
-/**
- * thermal_zone_get_temp() - returns the temperature of a thermal zone
- * @tz: a valid pointer to a struct thermal_zone_device
- * @temp: a valid pointer to where to store the resulting temperature.
- *
- * When a valid thermal zone reference is passed, it will fetch its
- * temperature and fill @temp.
- *
- * Return: On success returns 0, an error code otherwise
- */
-int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
-{
- int ret = -EINVAL;
- int count;
- int crit_temp = INT_MAX;
- enum thermal_trip_type type;
-
- if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
- goto exit;
-
- mutex_lock(&tz->lock);
-
- ret = tz->ops->get_temp(tz, temp);
-
- if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
- for (count = 0; count < tz->trips; count++) {
- ret = tz->ops->get_trip_type(tz, count, &type);
- if (!ret && type == THERMAL_TRIP_CRITICAL) {
- ret = tz->ops->get_trip_temp(tz, count,
- &crit_temp);
- break;
- }
- }
-
- /*
- * Only allow emulating a temperature when the real temperature
- * is below the critical temperature so that the emulation code
- * cannot hide critical conditions.
- */
- if (!ret && *temp < crit_temp)
- *temp = tz->emul_temperature;
- }
-
- mutex_unlock(&tz->lock);
-exit:
- return ret;
-}
-EXPORT_SYMBOL_GPL(thermal_zone_get_temp);
-
-void thermal_zone_set_trips(struct thermal_zone_device *tz)
-{
- int low = -INT_MAX;
- int high = INT_MAX;
- int trip_temp, hysteresis;
- int i, ret;
-
- mutex_lock(&tz->lock);
-
- if (!tz->ops->set_trips || !tz->ops->get_trip_hyst)
- goto exit;
-
- for (i = 0; i < tz->trips; i++) {
- int trip_low;
-
- tz->ops->get_trip_temp(tz, i, &trip_temp);
- tz->ops->get_trip_hyst(tz, i, &hysteresis);
-
- trip_low = trip_temp - hysteresis;
-
- if (trip_low < tz->temperature && trip_low > low)
- low = trip_low;
-
- if (trip_temp > tz->temperature && trip_temp < high)
- high = trip_temp;
- }
-
- /* No need to change trip points */
- if (tz->prev_low_trip == low && tz->prev_high_trip == high)
- goto exit;
-
- tz->prev_low_trip = low;
- tz->prev_high_trip = high;
-
- dev_dbg(&tz->device,
- "new temperature boundaries: %d < x < %d\n", low, high);
-
- /*
- * Set a temperature window. When this window is left the driver
- * must inform the thermal core via thermal_zone_device_update.
- */
- ret = tz->ops->set_trips(tz, low, high);
- if (ret)
- dev_err(&tz->device, "Failed to set trips: %d\n", ret);
-
-exit:
- mutex_unlock(&tz->lock);
-}
-EXPORT_SYMBOL_GPL(thermal_zone_set_trips);
-
static void update_temperature(struct thermal_zone_device *tz)
{
int temp, ret;
@@ -1178,35 +1037,6 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
}
EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);
-void thermal_cdev_update(struct thermal_cooling_device *cdev)
-{
- struct thermal_instance *instance;
- unsigned long target = 0;
-
- mutex_lock(&cdev->lock);
- /* cooling device is updated*/
- if (cdev->updated) {
- mutex_unlock(&cdev->lock);
- return;
- }
-
- /* Make sure cdev enters the deepest cooling state */
- list_for_each_entry(instance, &cdev->thermal_instances, cdev_node) {
- dev_dbg(&cdev->device, "zone%d->target=%lu\n",
- instance->tz->id, instance->target);
- if (instance->target == THERMAL_NO_TARGET)
- continue;
- if (instance->target > target)
- target = instance->target;
- }
- cdev->ops->set_cur_state(cdev, target);
- cdev->updated = true;
- mutex_unlock(&cdev->lock);
- trace_cdev_update(cdev, target);
- dev_dbg(&cdev->device, "set to state %lu\n", target);
-}
-EXPORT_SYMBOL(thermal_cdev_update);
-
/**
* thermal_notify_framework - Sensor drivers use this API to notify framework
* @tz: thermal zone device
diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
new file mode 100644
index 0000000..dfdba5a
--- /dev/null
+++ b/drivers/thermal/thermal_helpers.c
@@ -0,0 +1,196 @@
+/*
+ * thermal_helpers.c - helper functions to handle thermal devices
+ *
+ * Copyright (C) 2016 Eduardo Valentin <edubezval@gmail.com>
+ *
+ * Highly based on original thermal_core.c
+ * Copyright (C) 2008 Intel Corp
+ * Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com>
+ * Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/sysfs.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+
+#include <trace/events/thermal.h>
+
+#include "thermal_core.h"
+
+int get_tz_trend(struct thermal_zone_device *tz, int trip)
+{
+ enum thermal_trend trend;
+
+ if (tz->emul_temperature || !tz->ops->get_trend ||
+ tz->ops->get_trend(tz, trip, &trend)) {
+ if (tz->temperature > tz->last_temperature)
+ trend = THERMAL_TREND_RAISING;
+ else if (tz->temperature < tz->last_temperature)
+ trend = THERMAL_TREND_DROPPING;
+ else
+ trend = THERMAL_TREND_STABLE;
+ }
+
+ return trend;
+}
+EXPORT_SYMBOL(get_tz_trend);
+
+struct thermal_instance *
+get_thermal_instance(struct thermal_zone_device *tz,
+ struct thermal_cooling_device *cdev, int trip)
+{
+ struct thermal_instance *pos = NULL;
+ struct thermal_instance *target_instance = NULL;
+
+ mutex_lock(&tz->lock);
+ mutex_lock(&cdev->lock);
+
+ list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
+ if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
+ target_instance = pos;
+ break;
+ }
+ }
+
+ mutex_unlock(&cdev->lock);
+ mutex_unlock(&tz->lock);
+
+ return target_instance;
+}
+EXPORT_SYMBOL(get_thermal_instance);
+
+/**
+ * thermal_zone_get_temp() - returns the temperature of a thermal zone
+ * @tz: a valid pointer to a struct thermal_zone_device
+ * @temp: a valid pointer to where to store the resulting temperature.
+ *
+ * When a valid thermal zone reference is passed, it will fetch its
+ * temperature and fill @temp.
+ *
+ * Return: On success returns 0, an error code otherwise
+ */
+int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
+{
+ int ret = -EINVAL;
+ int count;
+ int crit_temp = INT_MAX;
+ enum thermal_trip_type type;
+
+ if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
+ goto exit;
+
+ mutex_lock(&tz->lock);
+
+ ret = tz->ops->get_temp(tz, temp);
+
+ if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
+ for (count = 0; count < tz->trips; count++) {
+ ret = tz->ops->get_trip_type(tz, count, &type);
+ if (!ret && type == THERMAL_TRIP_CRITICAL) {
+ ret = tz->ops->get_trip_temp(tz, count,
+ &crit_temp);
+ break;
+ }
+ }
+
+ /*
+ * Only allow emulating a temperature when the real temperature
+ * is below the critical temperature so that the emulation code
+ * cannot hide critical conditions.
+ */
+ if (!ret && *temp < crit_temp)
+ *temp = tz->emul_temperature;
+ }
+
+ mutex_unlock(&tz->lock);
+exit:
+ return ret;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_get_temp);
+
+void thermal_zone_set_trips(struct thermal_zone_device *tz)
+{
+ int low = -INT_MAX;
+ int high = INT_MAX;
+ int trip_temp, hysteresis;
+ int i, ret;
+
+ mutex_lock(&tz->lock);
+
+ if (!tz->ops->set_trips || !tz->ops->get_trip_hyst)
+ goto exit;
+
+ for (i = 0; i < tz->trips; i++) {
+ int trip_low;
+
+ tz->ops->get_trip_temp(tz, i, &trip_temp);
+ tz->ops->get_trip_hyst(tz, i, &hysteresis);
+
+ trip_low = trip_temp - hysteresis;
+
+ if (trip_low < tz->temperature && trip_low > low)
+ low = trip_low;
+
+ if (trip_temp > tz->temperature && trip_temp < high)
+ high = trip_temp;
+ }
+
+ /* No need to change trip points */
+ if (tz->prev_low_trip == low && tz->prev_high_trip == high)
+ goto exit;
+
+ tz->prev_low_trip = low;
+ tz->prev_high_trip = high;
+
+ dev_dbg(&tz->device,
+ "new temperature boundaries: %d < x < %d\n", low, high);
+
+ /*
+ * Set a temperature window. When this window is left the driver
+ * must inform the thermal core via thermal_zone_device_update.
+ */
+ ret = tz->ops->set_trips(tz, low, high);
+ if (ret)
+ dev_err(&tz->device, "Failed to set trips: %d\n", ret);
+
+exit:
+ mutex_unlock(&tz->lock);
+}
+EXPORT_SYMBOL_GPL(thermal_zone_set_trips);
+
+void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+ struct thermal_instance *instance;
+ unsigned long target = 0;
+
+ mutex_lock(&cdev->lock);
+ /* cooling device is updated*/
+ if (cdev->updated) {
+ mutex_unlock(&cdev->lock);
+ return;
+ }
+
+ /* Make sure cdev enters the deepest cooling state */
+ list_for_each_entry(instance, &cdev->thermal_instances, cdev_node) {
+ dev_dbg(&cdev->device, "zone%d->target=%lu\n",
+ instance->tz->id, instance->target);
+ if (instance->target == THERMAL_NO_TARGET)
+ continue;
+ if (instance->target > target)
+ target = instance->target;
+ }
+ cdev->ops->set_cur_state(cdev, target);
+ cdev->updated = true;
+ mutex_unlock(&cdev->lock);
+ trace_cdev_update(cdev, target);
+ dev_dbg(&cdev->device, "set to state %lu\n", target);
+}
+EXPORT_SYMBOL(thermal_cdev_update);
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 07:10 +0100 |
| Subject | [PATCHv2 47/49] thermal: core: use kzalloc(sizeof(*ptr),...) |
| Message-ID | <sB7Lz-5AX-1@gated-at.bofh.it> |
| In reply to | #1516777 |
As a safety check, this patch changes thermal core to check for pointer content size, instead of type size, while allocating memory. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <edubezval@gmail.com> --- drivers/thermal/thermal_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 2db21e5..4f93844 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -674,8 +674,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, if (lower > upper || upper > max_state) return -EINVAL; - dev = - kzalloc(sizeof(struct thermal_instance), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; dev->tz = tz; @@ -917,7 +916,7 @@ __thermal_cooling_device_register(struct device_node *np, !ops->set_cur_state) return ERR_PTR(-EINVAL); - cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL); + cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); if (!cdev) return ERR_PTR(-ENOMEM); @@ -1163,7 +1162,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) return ERR_PTR(-EINVAL); - tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL); + tz = kzalloc(sizeof(*tz), GFP_KERNEL); if (!tz) return ERR_PTR(-ENOMEM); -- 2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 07:20 +0100 |
| Subject | [PATCHv2 15/49] thermal: core: remove unnecessary device_remove() calls |
| Message-ID | <sB7Vg-5Hp-29@gated-at.bofh.it> |
| In reply to | #1516777 |
Given that cdevs sysfs properties are already registered using the dev.groups, there is no need to explicitly call device_remove() for each property. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <edubezval@gmail.com> --- drivers/thermal/thermal_core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index b1d6de9..6100ae7 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1876,11 +1876,6 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) mutex_unlock(&thermal_list_lock); - if (cdev->type[0]) - device_remove_file(&cdev->device, &dev_attr_cdev_type); - device_remove_file(&cdev->device, &dev_attr_max_state); - device_remove_file(&cdev->device, &dev_attr_cur_state); - release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); device_unregister(&cdev->device); return; -- 2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 10:00 +0100 |
| Subject | [PATCHv2 08/49] thermal: core: improve power actor documentation |
| Message-ID | <sBaq6-76t-39@gated-at.bofh.it> |
| In reply to | #1516777 |
Simple improvement on clarity and removal of checkpatch warning in the documentation of power actor kernel doc. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <edubezval@gmail.com> --- drivers/thermal/thermal_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index f3d9fe9..3d2adfa 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1206,12 +1206,13 @@ int power_actor_get_min_power(struct thermal_cooling_device *cdev, } /** - * power_actor_set_power() - limit the maximum power that a cooling device can consume + * 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. + * 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. -- 2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-11-08 10:10 +0100 |
| Subject | [PATCHv2 34/49] thermal: core: move __bind() to where it is used |
| Message-ID | <sBazL-7oC-3@gated-at.bofh.it> |
| In reply to | #1516777 |
Moving the helper to closer where it is used.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/thermal_core.c | 66 +++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 33 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index ebec7ce..258962b 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -286,39 +286,6 @@ static void thermal_unregister_governors(void)
thermal_gov_power_allocator_unregister();
}
-static void print_bind_err_msg(struct thermal_zone_device *tz,
- struct thermal_cooling_device *cdev, int ret)
-{
- dev_err(&tz->device, "binding zone %s with cdev %s failed:%d\n",
- tz->type, cdev->type, ret);
-}
-
-static void __bind(struct thermal_zone_device *tz, int mask,
- struct thermal_cooling_device *cdev,
- unsigned long *limits,
- unsigned int weight)
-{
- int i, ret;
-
- for (i = 0; i < tz->trips; i++) {
- if (mask & (1 << i)) {
- unsigned long upper, lower;
-
- upper = THERMAL_NO_LIMIT;
- lower = THERMAL_NO_LIMIT;
- if (limits) {
- lower = limits[i * 2];
- upper = limits[i * 2 + 1];
- }
- ret = thermal_zone_bind_cooling_device(tz, i, cdev,
- upper, lower,
- weight);
- if (ret)
- print_bind_err_msg(tz, cdev, ret);
- }
- }
-}
-
static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
int delay)
{
@@ -811,6 +778,39 @@ static struct class thermal_class = {
.dev_release = thermal_release,
};
+static void print_bind_err_msg(struct thermal_zone_device *tz,
+ struct thermal_cooling_device *cdev, int ret)
+{
+ dev_err(&tz->device, "binding zone %s with cdev %s failed:%d\n",
+ tz->type, cdev->type, ret);
+}
+
+static void __bind(struct thermal_zone_device *tz, int mask,
+ struct thermal_cooling_device *cdev,
+ unsigned long *limits,
+ unsigned int weight)
+{
+ int i, ret;
+
+ for (i = 0; i < tz->trips; i++) {
+ if (mask & (1 << i)) {
+ unsigned long upper, lower;
+
+ upper = THERMAL_NO_LIMIT;
+ lower = THERMAL_NO_LIMIT;
+ if (limits) {
+ lower = limits[i * 2];
+ upper = limits[i * 2 + 1];
+ }
+ ret = thermal_zone_bind_cooling_device(tz, i, cdev,
+ upper, lower,
+ weight);
+ if (ret)
+ print_bind_err_msg(tz, cdev, ret);
+ }
+ }
+}
+
static void bind_cdev(struct thermal_cooling_device *cdev)
{
int i, ret;
--
2.1.4
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | linux.kernel
csiph-web