diff options
-rw-r--r-- | drivers/thermal/ti-soc-thermal/ti-bandgap.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index f20c1cfe9800..219c051d2e68 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c | |||
@@ -992,9 +992,12 @@ int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend) | |||
992 | goto exit; | 992 | goto exit; |
993 | } | 993 | } |
994 | 994 | ||
995 | spin_lock(&bgp->lock); | ||
996 | |||
995 | tsr = bgp->conf->sensors[id].registers; | 997 | tsr = bgp->conf->sensors[id].registers; |
996 | 998 | ||
997 | /* Freeze and read the last 2 valid readings */ | 999 | /* Freeze and read the last 2 valid readings */ |
1000 | RMW_BITS(bgp, id, bgap_mask_ctrl, mask_freeze_mask, 1); | ||
998 | reg1 = tsr->ctrl_dtemp_1; | 1001 | reg1 = tsr->ctrl_dtemp_1; |
999 | reg2 = tsr->ctrl_dtemp_2; | 1002 | reg2 = tsr->ctrl_dtemp_2; |
1000 | 1003 | ||
@@ -1008,22 +1011,25 @@ int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend) | |||
1008 | /* Convert from adc values to mCelsius temperature */ | 1011 | /* Convert from adc values to mCelsius temperature */ |
1009 | ret = ti_bandgap_adc_to_mcelsius(bgp, temp1, &t1); | 1012 | ret = ti_bandgap_adc_to_mcelsius(bgp, temp1, &t1); |
1010 | if (ret) | 1013 | if (ret) |
1011 | goto exit; | 1014 | goto unfreeze; |
1012 | 1015 | ||
1013 | ret = ti_bandgap_adc_to_mcelsius(bgp, temp2, &t2); | 1016 | ret = ti_bandgap_adc_to_mcelsius(bgp, temp2, &t2); |
1014 | if (ret) | 1017 | if (ret) |
1015 | goto exit; | 1018 | goto unfreeze; |
1016 | 1019 | ||
1017 | /* Fetch the update interval */ | 1020 | /* Fetch the update interval */ |
1018 | ret = ti_bandgap_read_update_interval(bgp, id, &interval); | 1021 | ret = ti_bandgap_read_update_interval(bgp, id, &interval); |
1019 | if (ret || !interval) | 1022 | if (ret || !interval) |
1020 | goto exit; | 1023 | goto unfreeze; |
1021 | 1024 | ||
1022 | *trend = (t1 - t2) / interval; | 1025 | *trend = (t1 - t2) / interval; |
1023 | 1026 | ||
1024 | dev_dbg(bgp->dev, "The temperatures are t1 = %d and t2 = %d and trend =%d\n", | 1027 | dev_dbg(bgp->dev, "The temperatures are t1 = %d and t2 = %d and trend =%d\n", |
1025 | t1, t2, *trend); | 1028 | t1, t2, *trend); |
1026 | 1029 | ||
1030 | unfreeze: | ||
1031 | RMW_BITS(bgp, id, bgap_mask_ctrl, mask_freeze_mask, 0); | ||
1032 | spin_unlock(&bgp->lock); | ||
1027 | exit: | 1033 | exit: |
1028 | return ret; | 1034 | return ret; |
1029 | } | 1035 | } |