thermal: use device node to get thermal zone
Subsystems (2)
PATCH 1/1 thermal: use device node to get thermal zone
If use name to get the thermal zone, sometimes it can't get the unique thermal zone, because the thermal fw support same name for different thermal zone.
So we can change to use device node to get thermal zone.
--- drivers/thermal/of-thermal.c | 6 ++++-- drivers/thermal/thermal_core.c | 37 ++++++++++++++++--------------------- include/linux/thermal.h | 4 +++- 3 files changed, 23 insertions(+), 24 deletions(-)
drivers/thermal/of-thermal.c +4 -2
@@ -330,7 +330,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,struct thermal_zone_device *tzd;struct __thermal_zone *tz; - tzd =thermal_zone_get_zone_by_name (zone->name); + tzd =thermal_zone_get_zone_by_node (zone);if (IS_ERR (tzd))return ERR_PTR (-EPROBE_DEFER );
@@ -804,6 +804,8 @@ int __init of_parse_thermal_zones(void)of_thermal_free_zone (tz);/* attempting to build remaining zones still */ } + + zone->np = child; }return 0 ;
@@ -837,7 +839,7 @@ void of_thermal_destroy_zones(void)for_each_child_of_node (np, child) {struct thermal_zone_device *zone; - zone =thermal_zone_get_zone_by_name (child->name); + zone =thermal_zone_get_zone_by_node (child);if (IS_ERR (zone))continue ;
drivers/thermal/thermal_core.c +16 -21
@@ -1635,42 +1635,37 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)EXPORT_SYMBOL_GPL (thermal_zone_device_unregister);/** -* thermal_zone_get_zone_by_name() - search for a zone and returns its ref -* @name: thermal zone name to fetch the temperature +* thermal_zone_get_zone_by_node() - search for a zone and returns its ref +* @node: device node of the thermal zone * -* When only one zone is found with the passed name, returns a reference to it. +* When thermal zone is found with the passed device node, returns a reference +* to it. * * Return: On success returns a reference to an unique thermal zone with -* matching name equals to @name, an ERR_PTR otherwise (-EINVAL for invalid -* paramenters, -ENODEV for not found and -EEXIST for multiple matches). +* matching device node, an ERR_PTR otherwise (-EINVAL for invalid +* paramenters, -ENODEV for not found). */ -struct thermal_zone_device *thermal_zone_get_zone_by_name (const char *name) +struct thermal_zone_device * +thermal_zone_get_zone_by_node (struct device_node *node) { -struct thermal_zone_device *pos =NULL , *ref =ERR_PTR (-EINVAL ); -unsigned int found =0 ; +struct thermal_zone_device *pos =NULL , *ref =ERR_PTR (-ENODEV ); +bool found = false; -if (!name) - goto exit; +if (!node) +return ERR_PTR (-EINVAL );mutex_lock (&thermal_list_lock);list_for_each_entry (pos, &thermal_tz_list, node) -if (!strnicmp (name, pos->type,THERMAL_NAME_LENGTH )) { - found++; +if (node == pos->np) { ref = pos; + found = true; +break ; }mutex_unlock (&thermal_list_lock); -/* nothing has been found, thus an error code for it */ -if (found ==0 ) - ref =ERR_PTR (-ENODEV ); -else if (found >1 ) -/* Success only when an unique zone is found */ - ref =ERR_PTR (-EEXIST ); - -exit:return ref; } -EXPORT_SYMBOL_GPL (thermal_zone_get_zone_by_name); +EXPORT_SYMBOL_GPL (thermal_zone_get_zone_by_node);#ifdef CONFIG_NET static const struct genl_multicast_group thermal_event_mcgrps[] = {
include/linux/thermal.h +3 -1
@@ -162,6 +162,7 @@ struct thermal_zone_device {int id;char type[THERMAL_NAME_LENGTH ];struct device device; +struct device_node *np;struct thermal_attr *trip_temp_attrs;struct thermal_attr *trip_type_attrs;struct thermal_attr *trip_hyst_attrs;
@@ -285,7 +286,8 @@ struct thermal_cooling_device * thermal_of_cooling_device_register(struct device_node *np, char *, void *, const struct thermal_cooling_device_ops *);void thermal_cooling_device_unregister (struct thermal_cooling_device *); -struct thermal_zone_device *thermal_zone_get_zone_by_name (const char *name); +struct thermal_zone_device * +thermal_zone_get_zone_by_node (struct device_node *node);int thermal_zone_get_temp (struct thermal_zone_device *tz,unsigned long *temp);int get_tz_trend (struct thermal_zone_device *,int );
Signature · 1 line
1.7.9.5
A message that is not in the archive (sent off-list or not yet received): 1389172011-32107-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
Hi Wei,
Quoted 9 lines
-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] On Behalf Of Wei Ni
Sent: Wednesday, January 08, 2014 2:37 PM
To: [email protected]; Zhang, Rui; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Wei Ni
Subject: [PATCH] thermal: use device node to get thermal zone
Quoted 4 lines
If use name to get the thermal zone, sometimes it can't get the unique thermal zone, because the thermal fw support same name for different thermal zone.
So we can change to use device node to get thermal zone.
Eduardo introduced this API because we wanted to get the tzd pointer by using the name. So, for your case, can you introduce a new API *get_by_node instead of changing this API ?
Thanks,
Durga
Quoted 136 lines
Signed-off-by Wei Ni <[email protected]>--- drivers/thermal/of-thermal.c | 6 ++++-- drivers/thermal/thermal_core.c | 37 ++++++++++++++++--------------------- include/linux/thermal.h | 4 +++- 3 files changed, 23 insertions(+), 24 deletions(-)drivers/thermal/of-thermal.c +4
-2@@ -330,7 +330,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,struct thermal_zone_device *tzd;struct __thermal_zone *tz; - tzd =thermal_zone_get_zone_by_name (zone->name); + tzd =thermal_zone_get_zone_by_node (zone);if (IS_ERR (tzd))return ERR_PTR (-EPROBE_DEFER );@@ -804,6 +804,8 @@ int __init of_parse_thermal_zones(void)of_thermal_free_zone (tz);/* attempting to build remaining zones still */ } + + zone->np = child; }return 0 ;@@ -837,7 +839,7 @@ void of_thermal_destroy_zones(void)for_each_child_of_node (np, child) {struct thermal_zone_device *zone; - zone =thermal_zone_get_zone_by_name (child->name); + zone =thermal_zone_get_zone_by_node (child);if (IS_ERR (zone))continue ;drivers/thermal/thermal_core.c +3
-3@@ -1635,42 +1635,37 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)EXPORT_SYMBOL_GPL (thermal_zone_device_unregister );/** -* thermal_zone_get_zone_by_name() - search for a zone and returns its ref -* @name: thermal zone name to fetch the temperature +* thermal_zone_get_zone_by_node() - search for a zone and returns its ref +* @node: device node of the thermal zone * -* When only one zone is found with the passed name, returns a reference to it. +* When thermal zone is found with the passed device node, returns a reference
+ * to it.
*
* Return: On success returns a reference to an unique thermal zone with
- * matching name equals to @name, anERR_PTRotherwise (-EINVALfor invalid
- * paramenters,-ENODEVfor not found and-EEXISTfor multiple matches).
+ * matching device node, anERR_PTRotherwise (-EINVALfor invalid
+ * paramenters,-ENODEVfor not found).
*/
-structthermal_zone_device*thermal_zone_get_zone_by_name(const char *name)drivers/thermal/thermal_core.c +10
-15+struct thermal_zone_device * +thermal_zone_get_zone_by_node (struct device_node *node) { -struct thermal_zone_device *pos =NULL , *ref =ERR_PTR (-EINVAL ); -unsigned int found =0 ; +struct thermal_zone_device *pos =NULL , *ref =ERR_PTR (-ENODEV ); +bool found = false; -if (!name) - goto exit; +if (!node) +return ERR_PTR (-EINVAL );mutex_lock (&thermal_list_lock);list_for_each_entry (pos, &thermal_tz_list, node) -if (!strnicmp (name, pos->type,THERMAL_NAME_LENGTH )) { - found++; +if (node == pos->np) { ref = pos; + found = true; +break ; }mutex_unlock (&thermal_list_lock); -/* nothing has been found, thus an error code for it */ -if (found ==0 ) - ref =ERR_PTR (-ENODEV ); -else if (found >1 ) -/* Success only when an unique zone is found */ - ref =ERR_PTR (-EEXIST ); - -exit:return ref; } -EXPORT_SYMBOL_GPL (thermal_zone_get_zone_by_name); +EXPORT_SYMBOL_GPL (thermal_zone_get_zone_by_node);#ifdef CONFIG_NET static const struct genl_multicast_group thermal_event_mcgrps[] = {include/linux/thermal.h +3
-1@@ -162,6 +162,7 @@ struct thermal_zone_device {int id;char type[THERMAL_NAME_LENGTH ];struct device device; +struct device_node *np;struct thermal_attr *trip_temp_attrs;struct thermal_attr *trip_type_attrs;struct thermal_attr *trip_hyst_attrs;@@ -285,7 +286,8 @@ struct thermal_cooling_device * thermal_of_cooling_device_register(struct device_node *np, char *, void *, const struct thermal_cooling_device_ops *);void thermal_cooling_device_unregister (struct thermal_cooling_device *); -struct thermal_zone_device *thermal_zone_get_zone_by_name (const char *name); +struct thermal_zone_device * +thermal_zone_get_zone_by_node (struct device_node *node);int thermal_zone_get_temp (struct thermal_zone_device *tz,unsigned long *temp);int
get_tz_trend(struct thermal_zone_device *, int);
--
1.7.9.5--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 4D68720C2E767A4AA6A8796D42C8EB59E09ED1-yHIBzpp8AekElmVAvsQTrbfspsVTdybXVpNB7YpNyf8@public.gmane.org
Quoted 15 lines · Durgadoss
Hi Wei,
Quoted 13 lines
-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] On Behalf Of Wei Ni
Sent: Wednesday, January 08, 2014 2:37 PM
To: [email protected]; Zhang, Rui; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Wei Ni
Subject: [PATCH] thermal: use device node to get thermal zoneIf use name to get the thermal zone, sometimes it can't get the unique thermal zone, because the thermal fw support same name for different thermal zone.
So we can change to use device node to get thermal zone.
Please check the documentation for .*by_name function. There is an error code for the case of multiple instances. In fact, it is designed to be used by users who know that in the system there is going to exist only one zone with that name.
I don't think it is correct to simply remove the existing API and enforce DT usage. What if the system does not use DT?
Quoted 5 lines
Eduardo introduced this API because we wanted to get the tzd pointer by using the name. So, for your case, can you introduce a new API
*get_by_nodeinstead of changing this API ?
Agreed, if you need a search by DT node, then you need to provide the use cases and propose a new one.
Quoted 20 lines
Thanks,
DurgaQuoted 16 lines
Signed-off-by Wei Ni <[email protected]>--- drivers/thermal/of-thermal.c | 6 ++++-- drivers/thermal/thermal_core.c | 37 ++++++++++++++++--------------------- include/linux/thermal.h | 4 +++- 3 files changed, 23 insertions(+), 24 deletions(-)drivers/thermal/of-thermal.c +0
-0@@ -330,7 +330,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,struct thermal_zone_device *tzd;struct __thermal_zone *tz;
Quoted 2 lines
drivers/thermal/of-thermal.c thermal_zone_of_add_sensor(struct device_node *zone, · line 333
Quoted 2 lines
drivers/thermal/of-thermal.c +1
-1- tzd =thermal_zone_get_zone_by_name (zone->name); + tzd =thermal_zone_get_zone_by_node (zone);
In DT, nodes have unique names. Are you seen a problem with the above code?
Quoted 43 lines
Quoted 43 lines
drivers/thermal/of-thermal.c +3
-1if (IS_ERR (tzd))return ERR_PTR (-EPROBE_DEFER );@@ -804,6 +804,8 @@ int __init of_parse_thermal_zones(void)of_thermal_free_zone (tz);/* attempting to build remaining zones still */ } + + zone->np = child; }return 0 ;@@ -837,7 +839,7 @@ void of_thermal_destroy_zones(void)for_each_child_of_node (np, child) {struct thermal_zone_device *zone; - zone =thermal_zone_get_zone_by_name (child->name); + zone =thermal_zone_get_zone_by_node (child);if (IS_ERR (zone))continue ;drivers/thermal/thermal_core.c +3
-3@@ -1635,42 +1635,37 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)EXPORT_SYMBOL_GPL (thermal_zone_device_unregister );/** -* thermal_zone_get_zone_by_name() - search for a zone and returns its ref -* @name: thermal zone name to fetch the temperature +* thermal_zone_get_zone_by_node() - search for a zone and returns its ref +* @node: device node of the thermal zone * -* When only one zone is found with the passed name, returns a reference to it. +* When thermal zone is found with the passed device node, returns a reference
+ * to it.
*
* Return: On success returns a reference to an unique thermal zone with
- * matching name equals to @name, anERR_PTRotherwise (-EINVALfor invalid
- * paramenters,-ENODEVfor not found and-EEXISTfor multiple matches).
Quoted 8 lines
drivers/thermal/thermal_core.c void thermal_zone_device_unregister(struct thermal_zone_device *tz) · line 1650
Quoted 8 lines
+ * matching device node, an
ERR_PTRotherwise (-EINVALfor invalid
+ * paramenters,-ENODEVfor not found).
*/
-structthermal_zone_device*thermal_zone_get_zone_by_name(const char *name)drivers/thermal/thermal_core.c +2
-0+struct thermal_zone_device * +thermal_zone_get_zone_by_node (struct device_node *node) {
You are removing an API, are you checking that all existing users of this API are changed accordingly? I don't think so.
Quoted 34 lines
Quoted 34 lines
drivers/thermal/thermal_core.c +8
-15-struct thermal_zone_device *pos =NULL , *ref =ERR_PTR (-EINVAL ); -unsigned int found =0 ; +struct thermal_zone_device *pos =NULL , *ref =ERR_PTR (-ENODEV ); +bool found = false; -if (!name) - goto exit; +if (!node) +return ERR_PTR (-EINVAL );mutex_lock (&thermal_list_lock);list_for_each_entry (pos, &thermal_tz_list, node) -if (!strnicmp (name, pos->type,THERMAL_NAME_LENGTH )) { - found++; +if (node == pos->np) { ref = pos; + found = true; +break ; }mutex_unlock (&thermal_list_lock); -/* nothing has been found, thus an error code for it */ -if (found ==0 ) - ref =ERR_PTR (-ENODEV ); -else if (found >1 ) -/* Success only when an unique zone is found */ - ref =ERR_PTR (-EEXIST ); - -exit:return ref; } -EXPORT_SYMBOL_GPL (thermal_zone_get_zone_by_name); +EXPORT_SYMBOL_GPL (thermal_zone_get_zone_by_node);
Quoted 11 lines
include/linux/thermal.h struct thermal_zone_device { · line 165
Quoted 11 lines
#ifdef
CONFIG_NET
static const structgenl_multicast_groupthermal_event_mcgrps[] = {include/linux/thermal.h +1
-0@@ -162,6 +162,7 @@ struct thermal_zone_device {int id;char type[THERMAL_NAME_LENGTH ];struct device device; +struct device_node *np;
Please describe better if you want to add this node in here. Better to add it in a separated patch.
Quoted 28 lines
Quoted 14 lines
include/linux/thermal.h +2
-1struct thermal_attr *trip_temp_attrs;struct thermal_attr *trip_type_attrs;struct thermal_attr *trip_hyst_attrs;@@ -285,7 +286,8 @@ struct thermal_cooling_device * thermal_of_cooling_device_register(struct device_node *np, char *, void *, const struct thermal_cooling_device_ops *);void thermal_cooling_device_unregister (struct thermal_cooling_device *); -struct thermal_zone_device *thermal_zone_get_zone_by_name (const char *name); +struct thermal_zone_device * +thermal_zone_get_zone_by_node (struct device_node *node);int thermal_zone_get_temp (struct thermal_zone_device *tz,unsigned long *temp);Quoted 8 lines
int
get_tz_trend(struct thermal_zone_device *, int);
--
1.7.9.5--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport) Eduardo Valentin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 28 lines · Eduardo Valentin
* PGP Signed by an unknown key
Quoted 15 lines · Durgadoss
Hi Wei,
Quoted 13 lines
-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] On Behalf Of Wei Ni
Sent: Wednesday, January 08, 2014 2:37 PM
To: [email protected]; Zhang, Rui; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Wei Ni
Subject: [PATCH] thermal: use device node to get thermal zoneIf use name to get the thermal zone, sometimes it can't get the unique thermal zone, because the thermal fw support same name for different thermal zone.
So we can change to use device node to get thermal zone.Please check the documentation for .*by_name function. There is an error code for the case of multiple instances. In fact, it is designed to be used by users who know that in the system there is going to exist only one zone with that name.
I don't think it is correct to simply remove the existing API and enforce DT usage. What if the system does not use DT?
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Eduardo introduced this API because we wanted to get the tzd pointer by using the name. So, for your case, can you introduce a new API
*get_by_nodeinstead of changing this API ?Agreed, if you need a search by DT node, then you need to provide the use cases and propose a new one.
Yes, you are right, I should not remove it simply, I will add a new API .*by_node.
On the tegra board, it will use two or more sensors to estimate the skin temperature by reading temps from these sensors and calculate them. For example, we have two sensors: sensor1 and sensor2. We can register them to thermal framework by using DT, something like:
thermal-zones {
sensor1: lm90-local {
...
thermal-sensors = <&lm90 0>;
};
sensor2: lm90-remote {
...
thermal-sensors = <&lm90 1>;
};
}Then I will add a device node for my skin temperature driver, something like:
skin_temp {
...
#thermal-sensor-cells = <0>;
sub-devs {
dev@0 {
dev = <&sensor1>;
};
dev@1 {
dev = <&sensor2>;
};
};
};So I can parse the DT in the skin temperature driver to get the nodes of the sensor1 and sensor2, and can use .*get_by_node to get thermal zone device, then use .get_temp() and other callbacks to get temperature and other information. If use the *.get_by_name, it may not get the uniqu one, because I don't know if there has the same name thermal zone, because some other driver may not use DT to register thermal zone, it can define any name by itself.
Quoted 21 lines
Quoted 21 lines
Thanks,
DurgaQuoted 16 lines
Signed-off-by Wei Ni <[email protected]>--- drivers/thermal/of-thermal.c | 6 ++++-- drivers/thermal/thermal_core.c | 37 ++++++++++++++++--------------------- include/linux/thermal.h | 4 +++- 3 files changed, 23 insertions(+), 24 deletions(-)drivers/thermal/of-thermal.c +0
-0@@ -330,7 +330,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,struct thermal_zone_device *tzd;struct __thermal_zone *tz;
Quoted 4 lines
Quoted 2 lines
drivers/thermal/of-thermal.c thermal_zone_of_add_sensor(struct device_node *zone, · line 333
Quoted 2 lines
drivers/thermal/of-thermal.c +1
-1- tzd =thermal_zone_get_zone_by_name (zone->name); + tzd =thermal_zone_get_zone_by_node (zone);In DT, nodes have unique names. Are you seen a problem with the above code?
this file is used for DT parse, I think it's better to use .*by_node instead.
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
drivers/thermal/of-thermal.c +3
-1if (IS_ERR (tzd))return ERR_PTR (-EPROBE_DEFER );@@ -804,6 +804,8 @@ int __init of_parse_thermal_zones(void)of_thermal_free_zone (tz);/* attempting to build remaining zones still */ } + + zone->np = child; }return 0 ;@@ -837,7 +839,7 @@ void of_thermal_destroy_zones(void)for_each_child_of_node (np, child) {struct thermal_zone_device *zone; - zone =thermal_zone_get_zone_by_name (child->name); + zone =thermal_zone_get_zone_by_node (child);if (IS_ERR (zone))continue ;drivers/thermal/thermal_core.c +3
-3@@ -1635,42 +1635,37 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)EXPORT_SYMBOL_GPL (thermal_zone_device_unregister );/** -* thermal_zone_get_zone_by_name() - search for a zone and returns its ref -* @name: thermal zone name to fetch the temperature +* thermal_zone_get_zone_by_node() - search for a zone and returns its ref +* @node: device node of the thermal zone * -* When only one zone is found with the passed name, returns a reference to it. +* When thermal zone is found with the passed device node, returns a reference
+ * to it.
*
* Return: On success returns a reference to an unique thermal zone with
- * matching name equals to @name, anERR_PTRotherwise (-EINVALfor invalid
- * paramenters,-ENODEVfor not found and-EEXISTfor multiple matches).
+ * matching device node, anERR_PTRotherwise (-EINVALfor invalid
+ * paramenters,-ENODEVfor not found).
*/
Quoted 8 lines
Quoted 5 lines
drivers/thermal/thermal_core.c void thermal_zone_device_unregister(struct thermal_zone_device *tz) · line 1650
Quoted 5 lines
-struct
thermal_zone_device*thermal_zone_get_zone_by_name(const char *name)drivers/thermal/thermal_core.c +2
-0+struct thermal_zone_device * +thermal_zone_get_zone_by_node (struct device_node *node) {You are removing an API, are you checking that all existing users of this API are changed accordingly? I don't think so.
Sorry, it's my mistake, I will not remove it in my next pactch.
Quoted 80 lines
Quoted 35 lines
Quoted 35 lines
drivers/thermal/thermal_core.c +8
-15-struct thermal_zone_device *pos =NULL , *ref =ERR_PTR (-EINVAL ); -unsigned int found =0 ; +struct thermal_zone_device *pos =NULL , *ref =ERR_PTR (-ENODEV ); +bool found = false; -if (!name) - goto exit; +if (!node) +return ERR_PTR (-EINVAL );mutex_lock (&thermal_list_lock);list_for_each_entry (pos, &thermal_tz_list, node) -if (!strnicmp (name, pos->type,THERMAL_NAME_LENGTH )) { - found++; +if (node == pos->np) { ref = pos; + found = true; +break ; }mutex_unlock (&thermal_list_lock); -/* nothing has been found, thus an error code for it */ -if (found ==0 ) - ref =ERR_PTR (-ENODEV ); -else if (found >1 ) -/* Success only when an unique zone is found */ - ref =ERR_PTR (-EEXIST ); - -exit:return ref; } -EXPORT_SYMBOL_GPL (thermal_zone_get_zone_by_name); +EXPORT_SYMBOL_GPL (thermal_zone_get_zone_by_node);Quoted 11 lines
include/linux/thermal.h struct thermal_zone_device { · line 165
Quoted 11 lines
#ifdef
CONFIG_NET
static const structgenl_multicast_groupthermal_event_mcgrps[] = {include/linux/thermal.h +1
-0@@ -162,6 +162,7 @@ struct thermal_zone_device {int id;char type[THERMAL_NAME_LENGTH ];struct device device; +struct device_node *np;Please describe better if you want to add this node in here. Better to add it in a separated patch.
Quoted 28 lines
Quoted 14 lines
include/linux/thermal.h +2
-1struct thermal_attr *trip_temp_attrs;struct thermal_attr *trip_type_attrs;struct thermal_attr *trip_hyst_attrs;@@ -285,7 +286,8 @@ struct thermal_cooling_device * thermal_of_cooling_device_register(struct device_node *np, char *, void *, const struct thermal_cooling_device_ops *);void thermal_cooling_device_unregister (struct thermal_cooling_device *); -struct thermal_zone_device *thermal_zone_get_zone_by_name (const char *name); +struct thermal_zone_device * +thermal_zone_get_zone_by_node (struct device_node *node);int thermal_zone_get_temp (struct thermal_zone_device *tz,unsigned long *temp);Quoted 8 lines
int
get_tz_trend(struct thermal_zone_device *, int);
--
1.7.9.5--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
On 01/09/2014 12:56 AM, Wei Ni wrote:
...
Quoted 18 lines
On the tegra board, it will use two or more sensors to estimate the skin temperature by reading temps from these sensors and calculate them. For example, we have two sensors: sensor1 and sensor2. We can register them to thermal framework by using DT, something like:
thermal-zones { sensor1: lm90-local { ... thermal-sensors = <&lm90 0>; }; sensor2: lm90-remote { ... thermal-sensors = <&lm90 1>; }; }Then I will add a device node for my skin temperature driver, something like:
Quoted 14 lines
skin_temp {
...
#thermal-sensor-cells = <0>;
sub-devs {
dev@0 {
dev = <&sensor1>;
};
dev@1 {
dev = <&sensor2>;
};
};
};I haven't read the rest of the thread, but surely that last chunk of DT would be far simpler as:
skin_temp {
sub-devs = <&sensor1 &sensor2>;
};or:
skin_temp {
sensors = <&sensor1 &sensor2>;
sensor-names = "local", "remote";
};Quoted 7 lines
So I can parse the DT in the skin temperature driver to get the nodes of the sensor1 and sensor2, and can use .*get_by_node to get thermal zone device, then use .get_temp() and other callbacks to get temperature and other information. If use the *.get_by_name, it may not get the uniqu one, because I don't know if there has the same name thermal zone, because some other driver may not use DT to register thermal zone, it can define any name by itself.