All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Simon <horms@verge.net.au>, Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>
Cc: Magnus <magnus.damm@gmail.com>,
	linux-sh@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/8 v2] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update
Date: Fri, 04 Dec 2015 08:33:47 +0000	[thread overview]
Message-ID: <87bna6fwdr.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87h9jyfwj7.wl%kuninori.morimoto.gx@renesas.com>

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current rcar_thermal_get_temp() returns latest temperature, but it might
not be updated if some HW issue happend. This means user might get
wrong temperature. This patch solved this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

 - new patch

 drivers/thermal/rcar_thermal.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index aaedf37..52493b4 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -199,9 +199,9 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
 
 	dev_dbg(dev, "thermal%d  %d -> %d\n", priv->id, priv->ctemp, ctemp);
 
-	priv->ctemp = ctemp;
 	ret = 0;
 err_out_unlock:
+	priv->ctemp = ctemp;
 	mutex_unlock(&priv->lock);
 	return ret;
 }
@@ -209,6 +209,7 @@ err_out_unlock:
 static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 {
 	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+	int tmp;
 
 	if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) {
 		int ret = rcar_thermal_update_temp(priv);
@@ -217,9 +218,18 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 	}
 
 	mutex_lock(&priv->lock);
-	*temp =  MCELSIUS((priv->ctemp * 5) - 65);
+	tmp =  MCELSIUS((priv->ctemp * 5) - 65);
 	mutex_unlock(&priv->lock);
 
+	if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) {
+		struct device *dev = rcar_priv_to_dev(priv);
+
+		dev_err(dev, "it couldn't measure temperature correctly\n");
+		return -EIO;
+	}
+
+	*temp = tmp;
+
 	return 0;
 }
 
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Simon <horms@verge.net.au>, Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>
Cc: Magnus <magnus.damm@gmail.com>, <linux-sh@vger.kernel.org>,
	<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/8 v2] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update
Date: Fri, 4 Dec 2015 08:33:47 +0000	[thread overview]
Message-ID: <87bna6fwdr.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87h9jyfwj7.wl%kuninori.morimoto.gx@renesas.com>

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current rcar_thermal_get_temp() returns latest temperature, but it might
not be updated if some HW issue happend. This means user might get
wrong temperature. This patch solved this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

 - new patch

 drivers/thermal/rcar_thermal.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index aaedf37..52493b4 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -199,9 +199,9 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
 
 	dev_dbg(dev, "thermal%d  %d -> %d\n", priv->id, priv->ctemp, ctemp);
 
-	priv->ctemp = ctemp;
 	ret = 0;
 err_out_unlock:
+	priv->ctemp = ctemp;
 	mutex_unlock(&priv->lock);
 	return ret;
 }
@@ -209,6 +209,7 @@ err_out_unlock:
 static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 {
 	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+	int tmp;
 
 	if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) {
 		int ret = rcar_thermal_update_temp(priv);
@@ -217,9 +218,18 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 	}
 
 	mutex_lock(&priv->lock);
-	*temp =  MCELSIUS((priv->ctemp * 5) - 65);
+	tmp =  MCELSIUS((priv->ctemp * 5) - 65);
 	mutex_unlock(&priv->lock);
 
+	if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) {
+		struct device *dev = rcar_priv_to_dev(priv);
+
+		dev_err(dev, "it couldn't measure temperature correctly\n");
+		return -EIO;
+	}
+
+	*temp = tmp;
+
 	return 0;
 }
 
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Simon <horms@verge.net.au>, Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>
Cc: Magnus <magnus.damm@gmail.com>,
	linux-sh@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/8 v2] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update
Date: Fri, 4 Dec 2015 08:33:47 +0000	[thread overview]
Message-ID: <87bna6fwdr.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87h9jyfwj7.wl%kuninori.morimoto.gx@renesas.com>

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current rcar_thermal_get_temp() returns latest temperature, but it might
not be updated if some HW issue happend. This means user might get
wrong temperature. This patch solved this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

 - new patch

 drivers/thermal/rcar_thermal.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index aaedf37..52493b4 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -199,9 +199,9 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
 
 	dev_dbg(dev, "thermal%d  %d -> %d\n", priv->id, priv->ctemp, ctemp);
 
-	priv->ctemp = ctemp;
 	ret = 0;
 err_out_unlock:
+	priv->ctemp = ctemp;
 	mutex_unlock(&priv->lock);
 	return ret;
 }
@@ -209,6 +209,7 @@ err_out_unlock:
 static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 {
 	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+	int tmp;
 
 	if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) {
 		int ret = rcar_thermal_update_temp(priv);
@@ -217,9 +218,18 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 	}
 
 	mutex_lock(&priv->lock);
-	*temp =  MCELSIUS((priv->ctemp * 5) - 65);
+	tmp =  MCELSIUS((priv->ctemp * 5) - 65);
 	mutex_unlock(&priv->lock);
 
+	if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) {
+		struct device *dev = rcar_priv_to_dev(priv);
+
+		dev_err(dev, "it couldn't measure temperature correctly\n");
+		return -EIO;
+	}
+
+	*temp = tmp;
+
 	return 0;
 }
 
-- 
1.9.1

  parent reply	other threads:[~2015-12-04  8:33 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04  8:30 [PATCH 0/8 v2] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
2015-12-04  8:30 ` Kuninori Morimoto
2015-12-04  8:30 ` Kuninori Morimoto
2015-12-04  8:29 ` [PATCH 1/8 v2] thermal: rcar: move rcar_thermal_dt_ids to upside Kuninori Morimoto
2015-12-04  8:29   ` Kuninori Morimoto
2015-12-04  8:29   ` Kuninori Morimoto
2015-12-04  8:32 ` [PATCH 2/8 v2] thermal: rcar: check every rcar_thermal_update_temp() return value Kuninori Morimoto
2015-12-04  8:32   ` Kuninori Morimoto
2015-12-04  8:32   ` Kuninori Morimoto
2015-12-04  8:32 ` [PATCH 3/8 v2] thermal: rcar: check irq possibility in rcar_thermal_irq_xxx() Kuninori Morimoto
2015-12-04  8:32   ` Kuninori Morimoto
2015-12-04  8:32   ` Kuninori Morimoto
2015-12-04  8:33 ` Kuninori Morimoto [this message]
2015-12-04  8:33   ` [PATCH 4/8 v2] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update Kuninori Morimoto
2015-12-04  8:33   ` Kuninori Morimoto
2015-12-04  8:34 ` [PATCH 5/8 v2] thermal: rcar: enable to use thermal-zone on DT Kuninori Morimoto
2015-12-04  8:34   ` Kuninori Morimoto
2015-12-04  8:34   ` Kuninori Morimoto
2015-12-04  8:35 ` [PATCH 6/8 v2] ARM: shmobile: r8a7790: enable to use thermal-zone Kuninori Morimoto
2015-12-04  8:35   ` Kuninori Morimoto
2015-12-04  8:35   ` Kuninori Morimoto
2015-12-04  8:35 ` [PATCH 7/8 v2] ARM: shmobile: r8a7791: " Kuninori Morimoto
2015-12-04  8:35   ` Kuninori Morimoto
2015-12-04  8:35   ` Kuninori Morimoto
2015-12-04  8:36 ` [PATCH 8/8 v2] thermal: of-thermal: of_thermal_set_trip_temp() call thermal_zone_device_update() Kuninori Morimoto
2015-12-04  8:36   ` Kuninori Morimoto
2015-12-04  8:36   ` Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bna6fwdr.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=edubezval@gmail.com \
    --cc=horms@verge.net.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.