[PATCH 1/2] thermal: exynos: Check the range of temperature code

From: Jonghwan Choi
Date: Tue Nov 27 2012 - 19:48:07 EST


The temperature code should range between 46 and 146.

Signed-off-by: Jonghwan Choi <jhbird.choi@xxxxxxxxxxx>
---
drivers/thermal/exynos_thermal.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c
b/drivers/thermal/exynos_thermal.c
index 6dd29e4..dc2ad6c 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -530,14 +530,21 @@ out:
static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code)
{
struct exynos_tmu_platform_data *pdata = data->pdata;
- int temp;
+ int min, max, temp;

- if (data->soc == SOC_ARCH_EXYNOS4210)
- /* temp_code should range between 75 and 175 */
- if (temp_code < 75 || temp_code > 175) {
- temp = -ENODATA;
- goto out;
- }
+ if (data->soc == SOC_ARCH_EXYNOS4210) {
+ min = 75;
+ max = 175;
+ } else {
+ min = 46;
+ max = 146;
+ }
+
+ /* temp_code should range between min and max */
+ if (temp_code < min || temp_code > max) {
+ temp = -ENODATA;
+ goto out;
+ }

switch (pdata->cal_type) {
case TYPE_TWO_POINT_TRIMMING:
--
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/