summaryrefslogtreecommitdiffstats
path: root/tools/power/x86
diff options
context:
space:
mode:
Diffstat (limited to 'tools/power/x86')
-rw-r--r--tools/power/x86/turbostat/turbostat.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index c0596ccf92cd..e5b100b8db24 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -5764,27 +5764,24 @@ int snapshot_proc_interrupts(void)
*/
int snapshot_graphics(int idx)
{
- FILE *fp;
int retval;
+ if (gfx_info[idx].fp == NULL)
+ gfx_info[idx].fp = fopen_or_die(gfx_info[idx].path, "r");
+ else
+ rewind(gfx_info[idx].fp);
+
switch (idx) {
case GFX_rc6:
case SAM_mc6:
- fp = fopen_or_die(gfx_info[idx].path, "r");
- retval = fscanf(fp, "%lld", &gfx_info[idx].val_ull);
+ retval = fscanf(gfx_info[idx].fp, "%lld", &gfx_info[idx].val_ull);
if (retval != 1)
err(1, "rc6");
- fclose(fp);
return 0;
case GFX_MHz:
case GFX_ACTMHz:
case SAM_MHz:
case SAM_ACTMHz:
- if (gfx_info[idx].fp == NULL)
- gfx_info[idx].fp = fopen_or_die(gfx_info[idx].path, "r");
- else
- rewind(gfx_info[idx].fp);
-
retval = fscanf(gfx_info[idx].fp, "%d", &gfx_info[idx].val);
if (retval != 1)
err(1, "MHz");