aboutsummaryrefslogtreecommitdiff
path: root/sensor.c
diff options
context:
space:
mode:
authorSanjay Singh Rawat <sanjay.rawat@linaro.org>2014-05-26 11:35:02 +0530
committerSanjay Singh Rawat <sanjay.rawat@linaro.org>2014-05-26 11:36:33 +0530
commit96f6e050107da5d258280b785e5ed410d534a775 (patch)
treebc7d7ee8c131fbf7b061a0eefb8324e4a77cbcca /sensor.c
parent1540b3c8a3ddfd0d2d592bfe47eae5024b3b9df3 (diff)
downloadpowerdebug-96f6e050107da5d258280b785e5ed410d534a775.tar.gz
display error on module window
- Currently errors are displayed on stdout. This patch puts the error on subscreens also. - bug 1298171 Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
Diffstat (limited to 'sensor.c')
-rw-r--r--sensor.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sensor.c b/sensor.c
index 0645d25..bf67277 100644
--- a/sensor.c
+++ b/sensor.c
@@ -31,6 +31,7 @@
#define SYSFS_SENSOR "/sys/class/hwmon"
static struct tree *sensor_tree;
+static bool sensor_error = false;
struct temp_info {
char name[NAME_MAX];
@@ -272,6 +273,12 @@ static int sensor_print_info(struct tree *tree)
static int sensor_display(bool refresh)
{
+ if (sensor_error) {
+ display_message(SENSOR,
+ "error: path " SYSFS_SENSOR " not found");
+ return -2;
+ }
+
if (refresh && read_sensor_info(sensor_tree))
return -1;
@@ -284,6 +291,15 @@ static struct display_ops sensor_ops = {
int sensor_init(void)
{
+ int ret = 0;
+
+ ret = display_register(SENSOR, &sensor_ops);
+ if (!ret)
+ printf("error: sensor display register failed");
+
+ if (access(SYSFS_SENSOR, F_OK))
+ sensor_error = true; /* set the flag */
+
sensor_tree = tree_load(SYSFS_SENSOR, sensor_filter_cb, false);
if (!sensor_tree)
return -1;
@@ -291,5 +307,5 @@ int sensor_init(void)
if (fill_sensor_tree())
return -1;
- return display_register(SENSOR, &sensor_ops);
+ return ret;
}