From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Cc: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH 2/3] thermal: rcar_thermal: Do not store ctemp in rcar_thermal_priv
Date: Tue, 10 Mar 2020 18:00:28 +0100 [thread overview]
Message-ID: <20200310170029.1648996-3-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20200310170029.1648996-1-niklas.soderlund+renesas@ragnatech.se>
There is no need to cache the ctemp value in the private data structure
as it's always prefetched before it's used. Remove it from the structure
and have rcar_thermal_update_temp return the value instead of storing
it.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/thermal/rcar_thermal.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index f379eb5f8b9ecd14..953dc28d1dd1d499 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -95,7 +95,6 @@ struct rcar_thermal_priv {
struct mutex lock;
struct list_head list;
int id;
- u32 ctemp;
};
#define rcar_thermal_for_each_priv(pos, common) \
@@ -201,7 +200,6 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
struct device *dev = rcar_priv_to_dev(priv);
int i;
u32 ctemp, old, new;
- int ret = -EINVAL;
mutex_lock(&priv->lock);
@@ -247,32 +245,28 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
((ctemp - 1) << 0)));
}
- dev_dbg(dev, "thermal%d %d -> %d\n", priv->id, priv->ctemp, ctemp);
-
- priv->ctemp = ctemp;
- ret = 0;
err_out_unlock:
mutex_unlock(&priv->lock);
- return ret;
+
+ return ctemp ? ctemp : -EINVAL;
}
static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv,
int *temp)
{
- int tmp;
- int ret;
+ int ctemp, tmp;
- ret = rcar_thermal_update_temp(priv);
- if (ret < 0)
- return ret;
+ ctemp = rcar_thermal_update_temp(priv);
+ if (ctemp < 0)
+ return ctemp;
mutex_lock(&priv->lock);
if (priv->chip->ctemp_bands == 1)
- tmp = MCELSIUS((priv->ctemp * 5) - 65);
- else if (priv->ctemp < 24)
- tmp = MCELSIUS(((priv->ctemp * 55) - 720) / 10);
+ tmp = MCELSIUS((ctemp * 5) - 65);
+ else if (ctemp < 24)
+ tmp = MCELSIUS(((ctemp * 55) - 720) / 10);
else
- tmp = MCELSIUS((priv->ctemp * 5) - 60);
+ tmp = MCELSIUS((ctemp * 5) - 60);
mutex_unlock(&priv->lock);
/* Guaranteed operating range is -45C to 125C. */
--
2.25.1
next prev parent reply other threads:[~2020-03-10 17:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 17:00 [PATCH 0/3] thermal: rcar_thermal: Update how temperature is read Niklas Söderlund
2020-03-10 17:00 ` [PATCH 1/3] thermal: rcar_thermal: Always update thermal zone on interrupt Niklas Söderlund
2020-03-11 12:38 ` Geert Uytterhoeven
2020-03-10 17:00 ` Niklas Söderlund [this message]
2020-03-11 12:40 ` [PATCH 2/3] thermal: rcar_thermal: Do not store ctemp in rcar_thermal_priv Geert Uytterhoeven
2020-03-10 17:00 ` [PATCH 3/3] thermal: rcar_thermal: Remove lock in rcar_thermal_get_current_temp() Niklas Söderlund
2020-03-11 12:43 ` Geert Uytterhoeven
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=20200310170029.1648996-3-niklas.soderlund+renesas@ragnatech.se \
--to=niklas.soderlund+renesas@ragnatech.se \
--cc=linux-pm@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).