tsadc: define INVALID_TEMP and return it when some err happen
author陈亮 <cl@rock-chips.com>
Wed, 17 Sep 2014 01:17:27 +0000 (18:17 -0700)
committer陈亮 <cl@rock-chips.com>
Wed, 17 Sep 2014 01:17:27 +0000 (18:17 -0700)
Signed-off-by: 陈亮 <cl@rock-chips.com>
drivers/hwmon/rockchip-hwmon.c
drivers/hwmon/rockchip_tsadc.c
include/linux/rockchip/common.h

index 4aa4d480743e2ef73d9ffb05e5d2f7c3c832859e..bed728ed4e49d7fb5eb82f7d2d4be0f871959e1e 100755 (executable)
@@ -23,6 +23,7 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/workqueue.h>
+#include <linux/rockchip/common.h>
 #include "hwmon-rockchip.h"
 
 
@@ -68,7 +69,7 @@ static void tsadc_monitor(struct work_struct *work)
                        continue;
 
                temp = data->ops.read_sensor(i);
-               if (temp == 150) {
+               if (temp == INVALID_TEMP) {
                        dev_err(&data->pdev->dev, "TSADC read failed\n");
                        continue;
                }
index eb7002042490e965356d3bc09085c11d013f5ecb..4290f1a6ae518268165081e6a59d3c233a4a4ade 100755 (executable)
@@ -41,6 +41,7 @@
 #include <linux/of_platform.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/rockchip/common.h>
 #include "hwmon-rockchip.h"
 
 
@@ -317,7 +318,7 @@ static void rockchip_tsadc_get(int chn, int *temp, int *code)
        *code = 0;
 
        if (!g_dev || chn > 4){
-               *temp = 150;
+               *temp = INVALID_TEMP;
                return ;
        }
 #if 0
index 0a1eb0647a860bc7b74b2e35a7c042efe7bf861e..986943afa2f148d45ee0c4320c60cac3df63a395 100644 (file)
@@ -77,10 +77,11 @@ int rockchip_set_system_status(unsigned long status);
 int rockchip_clear_system_status(unsigned long status);
 unsigned long rockchip_get_system_status(void);
 
+#define INVALID_TEMP INT_MAX
 #if IS_ENABLED(CONFIG_SENSORS_ROCKCHIP_TSADC)
 int rockchip_tsadc_get_temp(int chn);
 #else
-static inline int rockchip_tsadc_get_temp(int chn) { return 0; }
+static inline int rockchip_tsadc_get_temp(int chn) { return INVALID_TEMP; }
 #endif
 
 #ifdef CONFIG_RK_LAST_LOG