aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2013-04-17 18:00:25 +0300
committerFathi Boudra <fathi.boudra@linaro.org>2013-04-17 18:00:25 +0300
commit55db054a18a2b2ce7499bdc082c8f047f0bce78d (patch)
treeccf348787b7a5af5985c61872e582eb6316cc0b6
parent3e6f303e0fa0b62525a578d06f71818a0939832a (diff)
Imported Upstream version 0.6.3-2013.04upstream
-rw-r--r--.gitignore46
-rw-r--r--Android.mk2
-rw-r--r--display.c9
-rw-r--r--powerdebug.c16
-rw-r--r--powerdebug.h2
-rw-r--r--regulator.c12
-rw-r--r--tree.c4
7 files changed, 37 insertions, 54 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 217aabb..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# NOTE! Don't add files that are generated in specific
-# subdirectories here. Add them in the ".gitignore" file
-# in that subdirectory instead.
-#
-# NOTE! Please use 'git ls-files -i --exclude-standard'
-# command after changing this file, to see if there are
-# any tracked files which get ignored after the change.
-#
-# Normal rules
-#
-.*
-*.o
-*.o.*
-*.a
-*.s
-*.patch
-
-#
-# Top-level generic files
-#
-/tags
-/TAGS
-
-#
-# git files that we don't want to ignore even it they are dot-files
-#
-!.gitignore
-
-# quilt's files
-patches
-series
-
-# cscope files
-cscope.*
-ncscope.*
-
-# gnu global files
-GPATH
-GRTAGS
-GSYMS
-GTAGS
-
-*.orig
-*~
-\#*#
diff --git a/Android.mk b/Android.mk
index e062c1c..36c73cd 100644
--- a/Android.mk
+++ b/Android.mk
@@ -29,6 +29,6 @@ LOCAL_C_INCLUDES += external/stlport/stlport/ \
LOCAL_SRC_FILES += \
powerdebug.c sensor.c clocks.c regulator.c \
- display.c tree.c utils.c mainloop.c
+ display.c tree.c utils.c mainloop.c gpio.c
include $(BUILD_EXECUTABLE)
diff --git a/display.c b/display.c
index f06387c..e9f4bf6 100644
--- a/display.c
+++ b/display.c
@@ -137,6 +137,11 @@ int display_refresh_pad(int win)
0, 2, 0, maxy - 2, maxx);
}
+void sigwinch_handler(int signo)
+{
+ display_refresh(current_win, true);
+}
+
static int display_show_unselection(int win, int line, bool bold)
{
if (mvwchgat(windata[win].pad, line, 0, -1,
@@ -593,8 +598,10 @@ int display_register(int win, struct display_ops *ops)
{
size_t array_size = sizeof(windata) / sizeof(windata[0]);
- if (win < 0 || win >= array_size)
+ if (win < 0 || win >= array_size) {
+ printf("error: invalid window");
return -1;
+ }
windata[win].ops = ops;
diff --git a/powerdebug.c b/powerdebug.c
index cc9e871..6cf3a1b 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <errno.h>
#include <ncurses.h>
+#include <signal.h>
#include "regulator.h"
#include "display.h"
#include "clocks.h"
@@ -28,6 +29,8 @@
#include "mainloop.h"
#include "powerdebug.h"
+extern void sigwinch_handler(int);
+
void usage(void)
{
printf("Usage: powerdebug [OPTIONS]\n");
@@ -207,6 +210,7 @@ static struct powerdebug_options *powerdebug_init(void)
return NULL;
memset(options, 0, sizeof(*options));
+ signal(SIGWINCH, sigwinch_handler);
return options;
}
@@ -216,6 +220,16 @@ int main(int argc, char **argv)
struct powerdebug_options *options;
int ret;
+#ifdef __ANDROID__
+ if (setenv("TERM", "xterm", 1) < 0) {
+ fprintf(stderr, "setenv failure");
+ return 1;
+ }
+ if (setenv("TERMINFO", "/system/etc/terminfo", 1) < 0) {
+ fprintf(stderr, "setenv failure");
+ return 1;
+ }
+#endif
options = powerdebug_init();
if (!options) {
fprintf(stderr, "not enough memory to allocate options\n");
@@ -233,7 +247,7 @@ int main(int argc, char **argv)
}
if (regulator_init()) {
- printf("not enough memory to allocate regulators info\n");
+ printf("failed to initialize regulator\n");
options->regulators = false;
}
diff --git a/powerdebug.h b/powerdebug.h
index e2c1699..642d4e4 100644
--- a/powerdebug.h
+++ b/powerdebug.h
@@ -13,4 +13,4 @@
* - initial API and implementation
*******************************************************************************/
-#define VERSION "0.6.2"
+#define VERSION "0.6.3"
diff --git a/regulator.c b/regulator.c
index 55bd3e9..68c686f 100644
--- a/regulator.c
+++ b/regulator.c
@@ -90,13 +90,17 @@ static int regulator_dump_cb(struct tree *tree, void *data)
printf("\n%s:\n", tree->name);
for (i = 0; i < nregdata; i++) {
+ int val;
if (file_read_value(tree->path, regdata[i].name,
regdata[i].ifmt, buffer))
continue;
- printf(regdata[i].ofmt, regdata[i].derefme ?
- *((int *)buffer) : buffer);
+ if (regdata[i].derefme) {
+ val = atoi(buffer);
+ printf(regdata[i].ofmt, val);
+ } else
+ printf(regdata[i].ofmt, buffer);
}
return 0;
@@ -214,8 +218,10 @@ static int fill_regulator_cb(struct tree *t, void *data)
struct regulator_info *reg;
reg = regulator_alloc();
- if (!reg)
+ if (!reg) {
+ printf("error: unable to allocate memory for regulator\n");
return -1;
+ }
t->private = reg;
/* we skip the root node but we set it expanded for its children */
diff --git a/tree.c b/tree.c
index d331c60..686e846 100644
--- a/tree.c
+++ b/tree.c
@@ -121,8 +121,10 @@ static int tree_scan(struct tree *tree, tree_filter_t filter, bool follow)
int ret = 0;
dir = opendir(tree->path);
- if (!dir)
+ if (!dir) {
+ printf("error: unable to open directory %s\n", tree->path);
return -1;
+ }
while (!readdir_r(dir, &dirent, &direntp)) {