From 925dacf96dca1ca09c58024df2e41aaea524c722 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Wed, 4 Jan 2012 00:34:02 +0000 Subject: *frequency_linux(): factorize git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31555 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/hosted/cpuinfo-linux.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'firmware/target/hosted/cpuinfo-linux.c') diff --git a/firmware/target/hosted/cpuinfo-linux.c b/firmware/target/hosted/cpuinfo-linux.c index 70d0e25139..e0a6bd76da 100644 --- a/firmware/target/hosted/cpuinfo-linux.c +++ b/firmware/target/hosted/cpuinfo-linux.c @@ -3,7 +3,7 @@ * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ * @@ -137,27 +137,14 @@ int cpucount_linux(void) return get_nprocs(); } -int cpufrequency_linux(int cpu) +int frequency_linux(int cpu, bool scaling) { char path[64]; char temp[10]; int cpu_dev, ret = -1; - snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_cur_freq", cpu); - cpu_dev = open(path, O_RDONLY); - if (cpu_dev < 0) - return -1; - if (read(cpu_dev, temp, sizeof(temp)) >= 0) - ret = atoi(temp); - close(cpu_dev); - return ret; -} - -int scalingfrequency_linux(int cpu) -{ - char path[64]; - char temp[10]; - int cpu_dev, ret = -1; - snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", cpu); + snprintf(path, sizeof(path), + "/sys/devices/system/cpu/cpu%d/cpufreq/%s_cur_freq", + cpu, scaling ? "scaling" : "cpuinfo"); cpu_dev = open(path, O_RDONLY); if (cpu_dev < 0) return -1; -- cgit v1.2.3