All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] thermal: lookup temperature
@ 2013-03-22 21:13 ` Eduardo Valentin
  0 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-22 21:13 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel, Eduardo Valentin

hello Rui,

Here is a temperature lookup helper function.

The usage of it is exemplified on patch 02.

Please review. This may overlap with Durgas recent work. But I am resending
as no one has commented my RFC.

Cheers,

Eduardo Valentin (2):
  thermal: introduce thermal_zone_lookup_temperature helper function
  staging: ti-soc-thermal: remove external heat while extrapolating
    hotspot

 drivers/staging/ti-soc-thermal/ti-thermal-common.c |    5 +--
 drivers/thermal/thermal_sys.c                      |   32 ++++++++++++++++++++
 include/linux/thermal.h                            |    1 +
 3 files changed, 35 insertions(+), 3 deletions(-)

-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 0/2] thermal: lookup temperature
@ 2013-03-22 21:13 ` Eduardo Valentin
  0 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-22 21:13 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel, Eduardo Valentin

hello Rui,

Here is a temperature lookup helper function.

The usage of it is exemplified on patch 02.

Please review. This may overlap with Durgas recent work. But I am resending
as no one has commented my RFC.

Cheers,

Eduardo Valentin (2):
  thermal: introduce thermal_zone_lookup_temperature helper function
  staging: ti-soc-thermal: remove external heat while extrapolating
    hotspot

 drivers/staging/ti-soc-thermal/ti-thermal-common.c |    5 +--
 drivers/thermal/thermal_sys.c                      |   32 ++++++++++++++++++++
 include/linux/thermal.h                            |    1 +
 3 files changed, 35 insertions(+), 3 deletions(-)

-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/2] thermal: introduce thermal_zone_lookup_temperature helper function
  2013-03-22 21:13 ` Eduardo Valentin
@ 2013-03-22 21:13   ` Eduardo Valentin
  -1 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-22 21:13 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel, Eduardo Valentin

This patch adds a helper function to get temperature of
a thermal zone, based on the zone type name.

It will perform a zone name lookup and return the last
sensor temperature reading. In case the zone is not found
or if the required parameters are invalid, it will return
the corresponding error code.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/thermal/thermal_sys.c |   32 ++++++++++++++++++++++++++++++++
 include/linux/thermal.h       |    1 +
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 5bd95d4..f0caa13 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -1790,6 +1790,38 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
 
+/**
+ * thermal_lookup_temperature - search for a zone and returns its temperature
+ * @name: thermal zone name to fetch the temperature
+ * @temperature: pointer to store the zone temperature, in case it is found
+ *
+ * When the zone is found, updates @temperature and returns 0.
+ *
+ * Return: -EINVAL in case of wrong parameters, -ENODEV in case the zone
+ * is not found and 0 when it is successfully found.
+ */
+int thermal_zone_lookup_temperature(const char *name, int *temperature)
+{
+	struct thermal_zone_device *pos = NULL;
+	bool found = false;
+
+	if (!name || !temperature)
+		return -EINVAL;
+
+	mutex_lock(&thermal_list_lock);
+	list_for_each_entry(pos, &thermal_tz_list, node)
+		if (!strcmp(pos->type, name)) {
+			found = true;
+			break;
+		}
+	if (found)
+		*temperature = pos->last_temperature;
+	mutex_unlock(&thermal_list_lock);
+
+	return found ? 0 : -ENODEV;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_lookup_temperature);
+
 #ifdef CONFIG_NET
 static struct genl_family thermal_event_genl_family = {
 	.id = GENL_ID_GENERATE,
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 542a39c..2b2f902 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -237,6 +237,7 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
+int thermal_zone_lookup_temperature(const char *name, int *temperature);
 
 int thermal_zone_trend_get(struct thermal_zone_device *, int);
 struct thermal_instance *thermal_instance_get(struct thermal_zone_device *,
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 1/2] thermal: introduce thermal_zone_lookup_temperature helper function
@ 2013-03-22 21:13   ` Eduardo Valentin
  0 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-22 21:13 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel, Eduardo Valentin

This patch adds a helper function to get temperature of
a thermal zone, based on the zone type name.

It will perform a zone name lookup and return the last
sensor temperature reading. In case the zone is not found
or if the required parameters are invalid, it will return
the corresponding error code.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/thermal/thermal_sys.c |   32 ++++++++++++++++++++++++++++++++
 include/linux/thermal.h       |    1 +
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 5bd95d4..f0caa13 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -1790,6 +1790,38 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
 
+/**
+ * thermal_lookup_temperature - search for a zone and returns its temperature
+ * @name: thermal zone name to fetch the temperature
+ * @temperature: pointer to store the zone temperature, in case it is found
+ *
+ * When the zone is found, updates @temperature and returns 0.
+ *
+ * Return: -EINVAL in case of wrong parameters, -ENODEV in case the zone
+ * is not found and 0 when it is successfully found.
+ */
+int thermal_zone_lookup_temperature(const char *name, int *temperature)
+{
+	struct thermal_zone_device *pos = NULL;
+	bool found = false;
+
+	if (!name || !temperature)
+		return -EINVAL;
+
+	mutex_lock(&thermal_list_lock);
+	list_for_each_entry(pos, &thermal_tz_list, node)
+		if (!strcmp(pos->type, name)) {
+			found = true;
+			break;
+		}
+	if (found)
+		*temperature = pos->last_temperature;
+	mutex_unlock(&thermal_list_lock);
+
+	return found ? 0 : -ENODEV;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_lookup_temperature);
+
 #ifdef CONFIG_NET
 static struct genl_family thermal_event_genl_family = {
 	.id = GENL_ID_GENERATE,
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 542a39c..2b2f902 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -237,6 +237,7 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
+int thermal_zone_lookup_temperature(const char *name, int *temperature);
 
 int thermal_zone_trend_get(struct thermal_zone_device *, int);
 struct thermal_instance *thermal_instance_get(struct thermal_zone_device *,
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/2] staging: ti-soc-thermal: remove external heat while extrapolating hotspot
  2013-03-22 21:13 ` Eduardo Valentin
@ 2013-03-22 21:13   ` Eduardo Valentin
  -1 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-22 21:13 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel, Eduardo Valentin

For boards that provide a PCB sensor close to SoC junction
temperature, it is possible to remove the cumulative heat
reported by the SoC temperature sensor.

This patch changes the extrapolation computation to consider
an external sensor in the extrapolation equations.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/ti-soc-thermal/ti-thermal-common.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ti-soc-thermal/ti-thermal-common.c b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
index 231c549..52d3c1b 100644
--- a/drivers/staging/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
@@ -92,10 +92,9 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
 	if (ret)
 		return ret;
 
-	pcb_temp = 0;
-	/* TODO: Introduce pcb temperature lookup */
+	ret = thermal_zone_lookup_temperature("pcb", &pcb_temp);
 	/* In case pcb zone is available, use the extrapolation rule with it */
-	if (pcb_temp) {
+	if (!ret) {
 		tmp -= pcb_temp;
 		slope = s->slope_pcb;
 		constant = s->constant_pcb;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/2] staging: ti-soc-thermal: remove external heat while extrapolating hotspot
@ 2013-03-22 21:13   ` Eduardo Valentin
  0 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-22 21:13 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel, Eduardo Valentin

For boards that provide a PCB sensor close to SoC junction
temperature, it is possible to remove the cumulative heat
reported by the SoC temperature sensor.

This patch changes the extrapolation computation to consider
an external sensor in the extrapolation equations.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/ti-soc-thermal/ti-thermal-common.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ti-soc-thermal/ti-thermal-common.c b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
index 231c549..52d3c1b 100644
--- a/drivers/staging/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
@@ -92,10 +92,9 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
 	if (ret)
 		return ret;
 
-	pcb_temp = 0;
-	/* TODO: Introduce pcb temperature lookup */
+	ret = thermal_zone_lookup_temperature("pcb", &pcb_temp);
 	/* In case pcb zone is available, use the extrapolation rule with it */
-	if (pcb_temp) {
+	if (!ret) {
 		tmp -= pcb_temp;
 		slope = s->slope_pcb;
 		constant = s->constant_pcb;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] thermal: introduce thermal_zone_lookup_temperature helper function
  2013-03-22 21:13   ` Eduardo Valentin
  (?)
@ 2013-03-25  6:10   ` Zhang Rui
  2013-03-25  6:20       ` R, Durgadoss
  -1 siblings, 1 reply; 14+ messages in thread
From: Zhang Rui @ 2013-03-25  6:10 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: linux-pm, linux-kernel

On Fri, 2013-03-22 at 17:13 -0400, Eduardo Valentin wrote:
> This patch adds a helper function to get temperature of
> a thermal zone, based on the zone type name.
> 
> It will perform a zone name lookup and return the last
> sensor temperature reading. In case the zone is not found
> or if the required parameters are invalid, it will return
> the corresponding error code.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
> ---
>  drivers/thermal/thermal_sys.c |   32 ++++++++++++++++++++++++++++++++
>  include/linux/thermal.h       |    1 +
>  2 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 5bd95d4..f0caa13 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -1790,6 +1790,38 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
>  
> +/**
> + * thermal_lookup_temperature - search for a zone and returns its temperature
> + * @name: thermal zone name to fetch the temperature
> + * @temperature: pointer to store the zone temperature, in case it is found
> + *
> + * When the zone is found, updates @temperature and returns 0.
> + *
> + * Return: -EINVAL in case of wrong parameters, -ENODEV in case the zone
> + * is not found and 0 when it is successfully found.
> + */
> +int thermal_zone_lookup_temperature(const char *name, int *temperature)
> +{
> +	struct thermal_zone_device *pos = NULL;
> +	bool found = false;
> +
> +	if (!name || !temperature)
> +		return -EINVAL;
> +
> +	mutex_lock(&thermal_list_lock);
> +	list_for_each_entry(pos, &thermal_tz_list, node)
> +		if (!strcmp(pos->type, name)) {
> +			found = true;
> +			break;
> +		}
> +	if (found)
> +		*temperature = pos->last_temperature;
> +	mutex_unlock(&thermal_list_lock);
> +
> +	return found ? 0 : -ENODEV;
> +}
> +EXPORT_SYMBOL_GPL(thermal_zone_lookup_temperature);
> +
please do not use thermal zone type as the parameter because unique
thermal zone type string is not a hard rule.
If this is really needed, I'd prefer two APIs instead
1. struct thermal_zone_device * thermal_zone_get_zone_by_name(char
*name);
2. int thermal_zone_get_temperature(struct thermal_zone_device *, int
*temperature);

And in thermal_zone_get_zone_by_name(), you should parse all the thermal
zone list and return an error code instead if multiple zones are found.

thanks,
rui
>  #ifdef CONFIG_NET
>  static struct genl_family thermal_event_genl_family = {
>  	.id = GENL_ID_GENERATE,
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 542a39c..2b2f902 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -237,6 +237,7 @@ void thermal_zone_device_update(struct thermal_zone_device *);
>  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
>  		const struct thermal_cooling_device_ops *);
>  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
> +int thermal_zone_lookup_temperature(const char *name, int *temperature);
>  
>  int thermal_zone_trend_get(struct thermal_zone_device *, int);
>  struct thermal_instance *thermal_instance_get(struct thermal_zone_device *,



^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 1/2] thermal: introduce thermal_zone_lookup_temperature helper function
  2013-03-25  6:10   ` Zhang Rui
@ 2013-03-25  6:20       ` R, Durgadoss
  0 siblings, 0 replies; 14+ messages in thread
From: R, Durgadoss @ 2013-03-25  6:20 UTC (permalink / raw)
  To: Zhang, Rui, Eduardo Valentin; +Cc: linux-pm, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3169 bytes --]

> -----Original Message-----
> From: linux-pm-owner@vger.kernel.org [mailto:linux-pm-
> owner@vger.kernel.org] On Behalf Of Zhang Rui
> Sent: Monday, March 25, 2013 11:41 AM
> To: Eduardo Valentin
> Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 1/2] thermal: introduce
> thermal_zone_lookup_temperature helper function
> 
> On Fri, 2013-03-22 at 17:13 -0400, Eduardo Valentin wrote:
> > This patch adds a helper function to get temperature of
> > a thermal zone, based on the zone type name.
> >
> > It will perform a zone name lookup and return the last
> > sensor temperature reading. In case the zone is not found
> > or if the required parameters are invalid, it will return
> > the corresponding error code.
> >
> > Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
> > ---
> >  drivers/thermal/thermal_sys.c |   32
> ++++++++++++++++++++++++++++++++
> >  include/linux/thermal.h       |    1 +
> >  2 files changed, 33 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> > index 5bd95d4..f0caa13 100644
> > --- a/drivers/thermal/thermal_sys.c
> > +++ b/drivers/thermal/thermal_sys.c
> > @@ -1790,6 +1790,38 @@ void thermal_zone_device_unregister(struct
> thermal_zone_device *tz)
> >  }
> >  EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
> >
> > +/**
> > + * thermal_lookup_temperature - search for a zone and returns its
> temperature
> > + * @name: thermal zone name to fetch the temperature
> > + * @temperature: pointer to store the zone temperature, in case it is
> found
> > + *
> > + * When the zone is found, updates @temperature and returns 0.
> > + *
> > + * Return: -EINVAL in case of wrong parameters, -ENODEV in case the
> zone
> > + * is not found and 0 when it is successfully found.
> > + */
> > +int thermal_zone_lookup_temperature(const char *name, int
> *temperature)
> > +{
> > +	struct thermal_zone_device *pos = NULL;
> > +	bool found = false;
> > +
> > +	if (!name || !temperature)
> > +		return -EINVAL;
> > +
> > +	mutex_lock(&thermal_list_lock);
> > +	list_for_each_entry(pos, &thermal_tz_list, node)
> > +		if (!strcmp(pos->type, name)) {
> > +			found = true;
> > +			break;
> > +		}
> > +	if (found)
> > +		*temperature = pos->last_temperature;
> > +	mutex_unlock(&thermal_list_lock);
> > +
> > +	return found ? 0 : -ENODEV;
> > +}
> > +EXPORT_SYMBOL_GPL(thermal_zone_lookup_temperature);
> > +
> please do not use thermal zone type as the parameter because unique
> thermal zone type string is not a hard rule.

Okay, agree with this. This is what I am implementing in
my changes as well.

> If this is really needed, I'd prefer two APIs instead
> 1. struct thermal_zone_device * thermal_zone_get_zone_by_name(char
> *name);
> 2. int thermal_zone_get_temperature(struct thermal_zone_device *, int
> *temperature);

Why do we need this second API?
If the driver has a 'tz' pointer, it can use tz->ops->get_temp
to retrieve the temperature, right ?

Thanks,
Durga
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 1/2] thermal: introduce thermal_zone_lookup_temperature helper function
@ 2013-03-25  6:20       ` R, Durgadoss
  0 siblings, 0 replies; 14+ messages in thread
From: R, Durgadoss @ 2013-03-25  6:20 UTC (permalink / raw)
  To: Zhang, Rui, Eduardo Valentin; +Cc: linux-pm, linux-kernel

> -----Original Message-----
> From: linux-pm-owner@vger.kernel.org [mailto:linux-pm-
> owner@vger.kernel.org] On Behalf Of Zhang Rui
> Sent: Monday, March 25, 2013 11:41 AM
> To: Eduardo Valentin
> Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 1/2] thermal: introduce
> thermal_zone_lookup_temperature helper function
> 
> On Fri, 2013-03-22 at 17:13 -0400, Eduardo Valentin wrote:
> > This patch adds a helper function to get temperature of
> > a thermal zone, based on the zone type name.
> >
> > It will perform a zone name lookup and return the last
> > sensor temperature reading. In case the zone is not found
> > or if the required parameters are invalid, it will return
> > the corresponding error code.
> >
> > Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
> > ---
> >  drivers/thermal/thermal_sys.c |   32
> ++++++++++++++++++++++++++++++++
> >  include/linux/thermal.h       |    1 +
> >  2 files changed, 33 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> > index 5bd95d4..f0caa13 100644
> > --- a/drivers/thermal/thermal_sys.c
> > +++ b/drivers/thermal/thermal_sys.c
> > @@ -1790,6 +1790,38 @@ void thermal_zone_device_unregister(struct
> thermal_zone_device *tz)
> >  }
> >  EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
> >
> > +/**
> > + * thermal_lookup_temperature - search for a zone and returns its
> temperature
> > + * @name: thermal zone name to fetch the temperature
> > + * @temperature: pointer to store the zone temperature, in case it is
> found
> > + *
> > + * When the zone is found, updates @temperature and returns 0.
> > + *
> > + * Return: -EINVAL in case of wrong parameters, -ENODEV in case the
> zone
> > + * is not found and 0 when it is successfully found.
> > + */
> > +int thermal_zone_lookup_temperature(const char *name, int
> *temperature)
> > +{
> > +	struct thermal_zone_device *pos = NULL;
> > +	bool found = false;
> > +
> > +	if (!name || !temperature)
> > +		return -EINVAL;
> > +
> > +	mutex_lock(&thermal_list_lock);
> > +	list_for_each_entry(pos, &thermal_tz_list, node)
> > +		if (!strcmp(pos->type, name)) {
> > +			found = true;
> > +			break;
> > +		}
> > +	if (found)
> > +		*temperature = pos->last_temperature;
> > +	mutex_unlock(&thermal_list_lock);
> > +
> > +	return found ? 0 : -ENODEV;
> > +}
> > +EXPORT_SYMBOL_GPL(thermal_zone_lookup_temperature);
> > +
> please do not use thermal zone type as the parameter because unique
> thermal zone type string is not a hard rule.

Okay, agree with this. This is what I am implementing in
my changes as well.

> If this is really needed, I'd prefer two APIs instead
> 1. struct thermal_zone_device * thermal_zone_get_zone_by_name(char
> *name);
> 2. int thermal_zone_get_temperature(struct thermal_zone_device *, int
> *temperature);

Why do we need this second API?
If the driver has a 'tz' pointer, it can use tz->ops->get_temp
to retrieve the temperature, right ?

Thanks,
Durga

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] staging: ti-soc-thermal: remove external heat while extrapolating hotspot
  2013-03-22 21:13   ` Eduardo Valentin
  (?)
@ 2013-03-25  6:23   ` Zhang Rui
  2013-03-25 11:18       ` Eduardo Valentin
  -1 siblings, 1 reply; 14+ messages in thread
From: Zhang Rui @ 2013-03-25  6:23 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: linux-pm, linux-kernel

On Fri, 2013-03-22 at 17:13 -0400, Eduardo Valentin wrote:
> For boards that provide a PCB sensor close to SoC junction
> temperature, it is possible to remove the cumulative heat
> reported by the SoC temperature sensor.
> 
> This patch changes the extrapolation computation to consider
> an external sensor in the extrapolation equations.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
> ---
>  drivers/staging/ti-soc-thermal/ti-thermal-common.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/ti-soc-thermal/ti-thermal-common.c b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
> index 231c549..52d3c1b 100644
> --- a/drivers/staging/ti-soc-thermal/ti-thermal-common.c
> +++ b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
> @@ -92,10 +92,9 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
>  	if (ret)
>  		return ret;
>  
> -	pcb_temp = 0;
> -	/* TODO: Introduce pcb temperature lookup */
> +	ret = thermal_zone_lookup_temperature("pcb", &pcb_temp);
>  	/* In case pcb zone is available, use the extrapolation rule with it */
> -	if (pcb_temp) {
> +	if (!ret) {
>  		tmp -= pcb_temp;
>  		slope = s->slope_pcb;
>  		constant = s->constant_pcb;

I can not see this piece of code.
But I assume that the thermal_zone_device is registered in another
driver, right?
or else you can use the thermal_zone_device pointer directly instead.

thanks,
rui


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 1/2] thermal: introduce thermal_zone_lookup_temperature helper function
  2013-03-25  6:20       ` R, Durgadoss
  (?)
@ 2013-03-25  6:26       ` Zhang Rui
  2013-03-25 11:25         ` Eduardo Valentin
  -1 siblings, 1 reply; 14+ messages in thread
From: Zhang Rui @ 2013-03-25  6:26 UTC (permalink / raw)
  To: R, Durgadoss; +Cc: Eduardo Valentin, linux-pm, linux-kernel

On Mon, 2013-03-25 at 00:20 -0600, R, Durgadoss wrote:
> > -----Original Message-----
> > From: linux-pm-owner@vger.kernel.org [mailto:linux-pm-
> > owner@vger.kernel.org] On Behalf Of Zhang Rui
> > Sent: Monday, March 25, 2013 11:41 AM
> > To: Eduardo Valentin
> > Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH 1/2] thermal: introduce
> > thermal_zone_lookup_temperature helper function
> > 
> > On Fri, 2013-03-22 at 17:13 -0400, Eduardo Valentin wrote:
> > > This patch adds a helper function to get temperature of
> > > a thermal zone, based on the zone type name.
> > >
> > > It will perform a zone name lookup and return the last
> > > sensor temperature reading. In case the zone is not found
> > > or if the required parameters are invalid, it will return
> > > the corresponding error code.
> > >
> > > Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
> > > ---
> > >  drivers/thermal/thermal_sys.c |   32
> > ++++++++++++++++++++++++++++++++
> > >  include/linux/thermal.h       |    1 +
> > >  2 files changed, 33 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> > > index 5bd95d4..f0caa13 100644
> > > --- a/drivers/thermal/thermal_sys.c
> > > +++ b/drivers/thermal/thermal_sys.c
> > > @@ -1790,6 +1790,38 @@ void thermal_zone_device_unregister(struct
> > thermal_zone_device *tz)
> > >  }
> > >  EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
> > >
> > > +/**
> > > + * thermal_lookup_temperature - search for a zone and returns its
> > temperature
> > > + * @name: thermal zone name to fetch the temperature
> > > + * @temperature: pointer to store the zone temperature, in case it is
> > found
> > > + *
> > > + * When the zone is found, updates @temperature and returns 0.
> > > + *
> > > + * Return: -EINVAL in case of wrong parameters, -ENODEV in case the
> > zone
> > > + * is not found and 0 when it is successfully found.
> > > + */
> > > +int thermal_zone_lookup_temperature(const char *name, int
> > *temperature)
> > > +{
> > > +	struct thermal_zone_device *pos = NULL;
> > > +	bool found = false;
> > > +
> > > +	if (!name || !temperature)
> > > +		return -EINVAL;
> > > +
> > > +	mutex_lock(&thermal_list_lock);
> > > +	list_for_each_entry(pos, &thermal_tz_list, node)
> > > +		if (!strcmp(pos->type, name)) {
> > > +			found = true;
> > > +			break;
> > > +		}
> > > +	if (found)
> > > +		*temperature = pos->last_temperature;
> > > +	mutex_unlock(&thermal_list_lock);
> > > +
> > > +	return found ? 0 : -ENODEV;
> > > +}
> > > +EXPORT_SYMBOL_GPL(thermal_zone_lookup_temperature);
> > > +
> > please do not use thermal zone type as the parameter because unique
> > thermal zone type string is not a hard rule.
> 
> Okay, agree with this. This is what I am implementing in
> my changes as well.
> 
> > If this is really needed, I'd prefer two APIs instead
> > 1. struct thermal_zone_device * thermal_zone_get_zone_by_name(char
> > *name);
> > 2. int thermal_zone_get_temperature(struct thermal_zone_device *, int
> > *temperature);
> 
> Why do we need this second API?
> If the driver has a 'tz' pointer, it can use tz->ops->get_temp
> to retrieve the temperature, right ?
> 

probably it is because one driver want to get the temperature of a
sensor registered by another driver.

thanks,
rui


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] staging: ti-soc-thermal: remove external heat while extrapolating hotspot
  2013-03-25  6:23   ` Zhang Rui
@ 2013-03-25 11:18       ` Eduardo Valentin
  0 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-25 11:18 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel

On 25-03-2013 02:23, Zhang Rui wrote:
> On Fri, 2013-03-22 at 17:13 -0400, Eduardo Valentin wrote:
>> For boards that provide a PCB sensor close to SoC junction
>> temperature, it is possible to remove the cumulative heat
>> reported by the SoC temperature sensor.
>>
>> This patch changes the extrapolation computation to consider
>> an external sensor in the extrapolation equations.
>>
>> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
>> ---
>>   drivers/staging/ti-soc-thermal/ti-thermal-common.c |    5 ++---
>>   1 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/ti-soc-thermal/ti-thermal-common.c b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
>> index 231c549..52d3c1b 100644
>> --- a/drivers/staging/ti-soc-thermal/ti-thermal-common.c
>> +++ b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
>> @@ -92,10 +92,9 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
>>   	if (ret)
>>   		return ret;
>>
>> -	pcb_temp = 0;
>> -	/* TODO: Introduce pcb temperature lookup */
>> +	ret = thermal_zone_lookup_temperature("pcb", &pcb_temp);
>>   	/* In case pcb zone is available, use the extrapolation rule with it */
>> -	if (pcb_temp) {
>> +	if (!ret) {
>>   		tmp -= pcb_temp;
>>   		slope = s->slope_pcb;
>>   		constant = s->constant_pcb;
>
> I can not see this piece of code.
> But I assume that the thermal_zone_device is registered in another
> driver, right?

It is because I made this patch based on staging-next. But you will find 
the same under drivers/stating/omap-thermal/omap-bandgap.c


Yes. The sensor managed by another driver. And the temperature lookup is 
assumed to be done by the fw.

> or else you can use the thermal_zone_device pointer directly instead.
>

I'd not recommend this because of the above statements

> thanks,
> rui
>
>
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] staging: ti-soc-thermal: remove external heat while extrapolating hotspot
@ 2013-03-25 11:18       ` Eduardo Valentin
  0 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-25 11:18 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel

On 25-03-2013 02:23, Zhang Rui wrote:
> On Fri, 2013-03-22 at 17:13 -0400, Eduardo Valentin wrote:
>> For boards that provide a PCB sensor close to SoC junction
>> temperature, it is possible to remove the cumulative heat
>> reported by the SoC temperature sensor.
>>
>> This patch changes the extrapolation computation to consider
>> an external sensor in the extrapolation equations.
>>
>> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
>> ---
>>   drivers/staging/ti-soc-thermal/ti-thermal-common.c |    5 ++---
>>   1 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/ti-soc-thermal/ti-thermal-common.c b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
>> index 231c549..52d3c1b 100644
>> --- a/drivers/staging/ti-soc-thermal/ti-thermal-common.c
>> +++ b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
>> @@ -92,10 +92,9 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
>>   	if (ret)
>>   		return ret;
>>
>> -	pcb_temp = 0;
>> -	/* TODO: Introduce pcb temperature lookup */
>> +	ret = thermal_zone_lookup_temperature("pcb", &pcb_temp);
>>   	/* In case pcb zone is available, use the extrapolation rule with it */
>> -	if (pcb_temp) {
>> +	if (!ret) {
>>   		tmp -= pcb_temp;
>>   		slope = s->slope_pcb;
>>   		constant = s->constant_pcb;
>
> I can not see this piece of code.
> But I assume that the thermal_zone_device is registered in another
> driver, right?

It is because I made this patch based on staging-next. But you will find 
the same under drivers/stating/omap-thermal/omap-bandgap.c


Yes. The sensor managed by another driver. And the temperature lookup is 
assumed to be done by the fw.

> or else you can use the thermal_zone_device pointer directly instead.
>

I'd not recommend this because of the above statements

> thanks,
> rui
>
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] thermal: introduce thermal_zone_lookup_temperature helper function
  2013-03-25  6:26       ` Zhang Rui
@ 2013-03-25 11:25         ` Eduardo Valentin
  0 siblings, 0 replies; 14+ messages in thread
From: Eduardo Valentin @ 2013-03-25 11:25 UTC (permalink / raw)
  To: Zhang Rui; +Cc: R, Durgadoss, linux-pm, linux-kernel

On 25-03-2013 02:26, Zhang Rui wrote:
> On Mon, 2013-03-25 at 00:20 -0600, R, Durgadoss wrote:
>>> -----Original Message-----
>>> From: linux-pm-owner@vger.kernel.org [mailto:linux-pm-
>>> owner@vger.kernel.org] On Behalf Of Zhang Rui
>>> Sent: Monday, March 25, 2013 11:41 AM
>>> To: Eduardo Valentin
>>> Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org
>>> Subject: Re: [PATCH 1/2] thermal: introduce
>>> thermal_zone_lookup_temperature helper function
>>>
>>> On Fri, 2013-03-22 at 17:13 -0400, Eduardo Valentin wrote:
>>>> This patch adds a helper function to get temperature of
>>>> a thermal zone, based on the zone type name.
>>>>
>>>> It will perform a zone name lookup and return the last
>>>> sensor temperature reading. In case the zone is not found
>>>> or if the required parameters are invalid, it will return
>>>> the corresponding error code.
>>>>
>>>> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
>>>> ---
>>>>   drivers/thermal/thermal_sys.c |   32
>>> ++++++++++++++++++++++++++++++++
>>>>   include/linux/thermal.h       |    1 +
>>>>   2 files changed, 33 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
>>>> index 5bd95d4..f0caa13 100644
>>>> --- a/drivers/thermal/thermal_sys.c
>>>> +++ b/drivers/thermal/thermal_sys.c
>>>> @@ -1790,6 +1790,38 @@ void thermal_zone_device_unregister(struct
>>> thermal_zone_device *tz)
>>>>   }
>>>>   EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
>>>>
>>>> +/**
>>>> + * thermal_lookup_temperature - search for a zone and returns its
>>> temperature
>>>> + * @name: thermal zone name to fetch the temperature
>>>> + * @temperature: pointer to store the zone temperature, in case it is
>>> found
>>>> + *
>>>> + * When the zone is found, updates @temperature and returns 0.
>>>> + *
>>>> + * Return: -EINVAL in case of wrong parameters, -ENODEV in case the
>>> zone
>>>> + * is not found and 0 when it is successfully found.
>>>> + */
>>>> +int thermal_zone_lookup_temperature(const char *name, int
>>> *temperature)
>>>> +{
>>>> +	struct thermal_zone_device *pos = NULL;
>>>> +	bool found = false;
>>>> +
>>>> +	if (!name || !temperature)
>>>> +		return -EINVAL;
>>>> +
>>>> +	mutex_lock(&thermal_list_lock);
>>>> +	list_for_each_entry(pos, &thermal_tz_list, node)
>>>> +		if (!strcmp(pos->type, name)) {
>>>> +			found = true;
>>>> +			break;
>>>> +		}
>>>> +	if (found)
>>>> +		*temperature = pos->last_temperature;
>>>> +	mutex_unlock(&thermal_list_lock);
>>>> +
>>>> +	return found ? 0 : -ENODEV;
>>>> +}
>>>> +EXPORT_SYMBOL_GPL(thermal_zone_lookup_temperature);
>>>> +
>>> please do not use thermal zone type as the parameter because unique
>>> thermal zone type string is not a hard rule.

OK. I didn't consider this, as I was just resending the patch and the FW 
has evolve since last time I sent it.

>>
>> Okay, agree with this. This is what I am implementing in
>> my changes as well.
>>
>>> If this is really needed, I'd prefer two APIs instead
>>> 1. struct thermal_zone_device * thermal_zone_get_zone_by_name(char
>>> *name);
>>> 2. int thermal_zone_get_temperature(struct thermal_zone_device *, int
>>> *temperature);
>>
>> Why do we need this second API?
>> If the driver has a 'tz' pointer, it can use tz->ops->get_temp
>> to retrieve the temperature, right ?
>>
>
> probably it is because one driver want to get the temperature of a
> sensor registered by another driver.

Unless API 1. can be used on other cases, why do we need two APIs? Why 
not keep the same signature I proposed, but with the same care on 'type' 
you mentioned for 1.?

>
> thanks,
> rui
>
>
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-03-25 11:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-22 21:13 [PATCH 0/2] thermal: lookup temperature Eduardo Valentin
2013-03-22 21:13 ` Eduardo Valentin
2013-03-22 21:13 ` [PATCH 1/2] thermal: introduce thermal_zone_lookup_temperature helper function Eduardo Valentin
2013-03-22 21:13   ` Eduardo Valentin
2013-03-25  6:10   ` Zhang Rui
2013-03-25  6:20     ` R, Durgadoss
2013-03-25  6:20       ` R, Durgadoss
2013-03-25  6:26       ` Zhang Rui
2013-03-25 11:25         ` Eduardo Valentin
2013-03-22 21:13 ` [PATCH 2/2] staging: ti-soc-thermal: remove external heat while extrapolating hotspot Eduardo Valentin
2013-03-22 21:13   ` Eduardo Valentin
2013-03-25  6:23   ` Zhang Rui
2013-03-25 11:18     ` Eduardo Valentin
2013-03-25 11:18       ` Eduardo Valentin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.