diff mbox series

[3/3] thermal: rcar_thermal: Remove lock in rcar_thermal_get_current_temp()

Message ID 20200310170029.1648996-4-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State New, archived
Delegated to: Daniel Lezcano
Headers show
Series thermal: rcar_thermal: Update how temperature is read | expand

Commit Message

Niklas Söderlund March 10, 2020, 5 p.m. UTC
With the ctemp value returned instead of cached in the private data
structure their is no need to take the lock when translating ctemp into
a temperature.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/thermal/rcar_thermal.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Comments

Geert Uytterhoeven March 11, 2020, 12:43 p.m. UTC | #1
On Tue, Mar 10, 2020 at 6:02 PM Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> With the ctemp value returned instead of cached in the private data
> structure their is no need to take the lock when translating ctemp into
> a temperature.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 953dc28d1dd1d499..8bdcb449bd280a18 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -254,24 +254,20 @@  static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
 static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv,
 					 int *temp)
 {
-	int ctemp, tmp;
+	int ctemp;
 
 	ctemp = rcar_thermal_update_temp(priv);
 	if (ctemp < 0)
 		return ctemp;
 
-	mutex_lock(&priv->lock);
+	/* Guaranteed operating range is -45C to 125C. */
+
 	if (priv->chip->ctemp_bands == 1)
-		tmp = MCELSIUS((ctemp * 5) - 65);
+		*temp = MCELSIUS((ctemp * 5) - 65);
 	else if (ctemp < 24)
-		tmp = MCELSIUS(((ctemp * 55) - 720) / 10);
+		*temp = MCELSIUS(((ctemp * 55) - 720) / 10);
 	else
-		tmp = MCELSIUS((ctemp * 5) - 60);
-	mutex_unlock(&priv->lock);
-
-	/* Guaranteed operating range is -45C to 125C. */
-
-	*temp = tmp;
+		*temp = MCELSIUS((ctemp * 5) - 60);
 
 	return 0;
 }