[powerdebug 17/35] Reduce the usage of the dump variable
Daniel Lezcano
daniel.lezcano at free.fr
Sat Mar 26 21:06:05 UTC 2011
When we reach the mainloop, that means we are not in dump-mode,
so we can remove the test with the dump mode.
In the other side, let's use the dump function when we are in dump-mode.
Signed-off-by: Daniel Lezcano <daniel.lezcano at free.fr>
---
powerdebug.c | 57 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c
index bb024fc..ca7db7a 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -254,23 +254,16 @@ int mainloop(struct powerdebug_options *options,
struct timeval tval;
fd_set readfds;
- if (!options->dump) {
- if (firsttime[0])
- init_curses();
- create_windows(options->selectedwindow);
- show_header(options->selectedwindow);
- }
+ if (firsttime[0])
+ init_curses();
+ create_windows(options->selectedwindow);
+ show_header(options->selectedwindow);
if (options->regulators || options->selectedwindow == REGULATOR) {
regulator_read_info(reg_info, nr_reg);
- if (!options->dump) {
- create_selectedwindow(options->selectedwindow);
- show_regulator_info(reg_info, nr_reg,
- options->verbose);
- }
- else
- regulator_print_info(reg_info, nr_reg,
- options->verbose);
+ create_selectedwindow(options->selectedwindow);
+ show_regulator_info(reg_info, nr_reg,
+ options->verbose);
}
if (options->clocks || options->selectedwindow == CLOCK) {
@@ -282,7 +275,7 @@ int mainloop(struct powerdebug_options *options,
firsttime[CLOCK] = 0;
strcpy(clkname_str, "");
}
- if (!ret && !options->dump) {
+ if (!ret) {
int hrow;
create_selectedwindow(options->selectedwindow);
@@ -304,25 +297,13 @@ int mainloop(struct powerdebug_options *options,
enter_hit,
options->dump);
}
- if (!ret && options->dump) {
- if (options->findparent)
- read_and_dump_clock_info_one(options->clkarg, options->dump);
- else
- read_and_dump_clock_info(options->verbose);
- }
}
if (options->sensors || options->selectedwindow == SENSOR) {
- if (!options->dump) {
- create_selectedwindow(options->selectedwindow);
- print_sensor_header();
- } else
- read_and_print_sensor_info(options->verbose);
+ create_selectedwindow(options->selectedwindow);
+ print_sensor_header();
}
- if (options->dump)
- break;
-
FD_ZERO(&readfds);
FD_SET(0, &readfds);
tval.tv_sec = options->ticktime;
@@ -344,6 +325,24 @@ int mainloop(struct powerdebug_options *options,
static int powerdebug_dump(struct powerdebug_options *options,
struct regulator_info *reg_info, int nr_reg)
{
+ if (options->regulators) {
+ regulator_read_info(reg_info, nr_reg);
+ regulator_print_info(reg_info, nr_reg, options->verbose);
+ }
+
+ if (options->clocks) {
+ init_clock_details(options->dump, options->selectedwindow);
+
+ if (options->findparent)
+ read_and_dump_clock_info_one(options->clkarg,
+ options->dump);
+ else
+ read_and_dump_clock_info(options->verbose);
+ }
+
+ if (options->sensors)
+ read_and_print_sensor_info(options->verbose);
+
return 0;
}
--
1.7.1
More information about the linaro-dev
mailing list