aboutsummaryrefslogtreecommitdiff
path: root/idlestat.c
diff options
context:
space:
mode:
authorTuukka Tikkanen <tuukka.tikkanen@linaro.org>2014-12-17 15:23:06 +0200
committerTuukka Tikkanen <tuukka.tikkanen@linaro.org>2014-12-29 10:17:02 +0200
commit9f9e6d2a3491c351a1570ebab331a225d257c177 (patch)
tree5bdc421da7b9abd3673a31d08b5537e187dfefd6 /idlestat.c
parent88ac29328fd2f70196d261d01958e15762d36f89 (diff)
Reports: Add support for allocating and releasing report_data
While passing around the per report data pointer has been previously implemented, there was no mechanism for the report ops to allocate or release the data as needed. This patch moves allocation of report_data pointer from struct options to main() and adds calls necessary for allocating (and initializing) and releasing the data. Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Diffstat (limited to 'idlestat.c')
-rw-r--r--idlestat.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/idlestat.c b/idlestat.c
index 2edf5ef..cfaa098 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -1536,6 +1536,7 @@ int main(int argc, char *argv[], char *const envp[])
struct init_pstates *initp = NULL;
struct report_ops *output_handler = NULL;
struct cpu_topology *cpu_topo = NULL;
+ void *report_data = NULL;
args = getoptions(argc, argv, &options);
if (args <= 0)
@@ -1556,7 +1557,13 @@ int main(int argc, char *argv[], char *const envp[])
output_handler->check_options(&options) < 0)
return 1;
- if (output_handler->check_output(&options, options.report_data))
+ if (output_handler->allocate_report_data) {
+ report_data = output_handler->allocate_report_data(&options);
+ if (is_err(report_data))
+ return 1;
+ }
+
+ if (output_handler->check_output(&options, report_data))
return 1;
if (options.energy_model_filename &&
@@ -1662,35 +1669,38 @@ int main(int argc, char *argv[], char *const envp[])
* the same cluster
*/
if (0 == establish_idledata_to_topo(datas)) {
- if (output_handler->open_report_file(options.outfilename, options.report_data))
+ if (output_handler->open_report_file(options.outfilename, report_data))
return 1;
if (options.display & IDLE_DISPLAY) {
- output_handler->cstate_table_header(options.report_data);
- dump_cpu_topo_info(output_handler, options.report_data, display_cstates, cpu_topo, 1);
- output_handler->cstate_table_footer(options.report_data);
+ output_handler->cstate_table_header(report_data);
+ dump_cpu_topo_info(output_handler, report_data, display_cstates, cpu_topo, 1);
+ output_handler->cstate_table_footer(report_data);
}
if (options.display & FREQUENCY_DISPLAY) {
- output_handler->pstate_table_header(options.report_data);
- dump_cpu_topo_info(output_handler, options.report_data, display_pstates, cpu_topo, 0);
- output_handler->pstate_table_footer(options.report_data);
+ output_handler->pstate_table_header(report_data);
+ dump_cpu_topo_info(output_handler, report_data, display_pstates, cpu_topo, 0);
+ output_handler->pstate_table_footer(report_data);
}
if (options.display & WAKEUP_DISPLAY) {
- output_handler->wakeup_table_header(options.report_data);
- dump_cpu_topo_info(output_handler, options.report_data, display_wakeup, cpu_topo, 1);
- output_handler->wakeup_table_footer(options.report_data);
+ output_handler->wakeup_table_header(report_data);
+ dump_cpu_topo_info(output_handler, report_data, display_wakeup, cpu_topo, 1);
+ output_handler->wakeup_table_footer(report_data);
}
if (options.energy_model_filename)
calculate_energy_consumption(cpu_topo, &options);
- output_handler->close_report_file(options.report_data);
+ output_handler->close_report_file(report_data);
}
release_init_pstates(initp);
release_datas(datas);
+ if (output_handler->release_report_data)
+ output_handler->release_report_data(report_data);
+
return 0;
}