aboutsummaryrefslogtreecommitdiff
path: root/freq_tray/getgov.c
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-05-01 12:33:34 +1200
committerDavid <dbphillipsnz@gmail.com>2014-05-01 12:33:34 +1200
commitc6a855363bfc59fbe197bba73bf64b5d920946a1 (patch)
tree4233a6c01283b4bb718d62dec240f33845aae7b1 /freq_tray/getgov.c
parentfe30fcc86801beec76acf219ad339afcbec36dff (diff)
downloadparamano-c6a855363bfc59fbe197bba73bf64b5d920946a1.tar.xz
Completed debug stuff
Diffstat (limited to 'freq_tray/getgov.c')
-rw-r--r--freq_tray/getgov.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/freq_tray/getgov.c b/freq_tray/getgov.c
index 8fe44a5..181ad41 100644
--- a/freq_tray/getgov.c
+++ b/freq_tray/getgov.c
@@ -39,18 +39,18 @@ void gg_init()
memset(gov_string, '\0', 500);
gg_available(i, gov_string, 500);
- /* go through every governor in gov_string */
+ // go through every governor in gov_string
j = 0;
gchar* curr = &gov_string[0];
gchar* end_of_curr = g_strstr_len(curr, strlen(curr), " ");
while(end_of_curr)
{
- memset(AVAILABLE_GOVERNORS[i][j], '\0', 13);
- memmove(AVAILABLE_GOVERNORS[i][j], curr, end_of_curr - curr);
+ memset(AVAILABLE_GOVERNORS[i][j], '\0', 13);
+ memmove(AVAILABLE_GOVERNORS[i][j], curr, end_of_curr - curr);
- curr = end_of_curr+1;
- end_of_curr = g_strstr_len(curr, strlen(curr), " ");
- ++j;
+ curr = end_of_curr+1;
+ end_of_curr = g_strstr_len(curr, strlen(curr), " ");
+ ++j;
}
}
NUMBER_OF_AVAILABLE_GOVERNORS = j;
@@ -67,14 +67,18 @@ int gg_current(int core, char* out, int size)
sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_governor", corestr);
if(!(fd = fopen(path, "r")))
+ {
+ debug("Couldn't open '%s'\n",path);
return -1;
+ }
fgets(out, size, fd);
-
- /* remove newline at the end */
+ // Chomp
gchar* newline = g_strrstr(out, "\n");
*newline = '\0';
+ debug("Current gov for core %d is '%s'\n",core,out);
+
fclose(fd);
return 0;
}
@@ -83,14 +87,14 @@ int gg_available(int core, char* out, int size)
{
FILE* fd;
char path[80];
- char corestr[4];
- sprintf(corestr, "%i", core);
-
- sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_available_governors", corestr);
+ sprintf(path, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_governors", core);
if(!(fd = fopen(path, "r")))
+ {
+ debug("Couldn't open '%s'\n",path);
return -1;
+ }
fgets(out, size, fd);