diff options
author | rbuj <[email protected]> | 2020-11-28 20:26:22 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-12-09 21:16:36 +0100 |
commit | 4cb6f915b1a91497df1b13cdab887df1bdaed101 (patch) | |
tree | ef32f9e4d6f6f75de2e15da5bff69562ac7581dc | |
parent | 66b18c097d5ae6e7bcf712820bc3e6594c8cb79a (diff) | |
download | mate-applets-4cb6f915b1a91497df1b13cdab887df1bdaed101.tar.bz2 mate-applets-4cb6f915b1a91497df1b13cdab887df1bdaed101.tar.xz |
cpufreq: Remove /proc/cpufreq support (Linux 2.4)
-rw-r--r-- | cpufreq/README | 1 | ||||
-rw-r--r-- | cpufreq/src/Makefile.am | 22 | ||||
-rw-r--r-- | cpufreq/src/cpufreq-monitor-factory.c | 12 | ||||
-rw-r--r-- | cpufreq/src/cpufreq-monitor-procfs.c | 219 | ||||
-rw-r--r-- | cpufreq/src/cpufreq-monitor-procfs.h | 54 | ||||
-rw-r--r-- | cpufreq/src/cpufreq-selector/Makefile.am | 17 | ||||
-rw-r--r-- | cpufreq/src/cpufreq-selector/cpufreq-selector-factory.c | 16 | ||||
-rw-r--r-- | cpufreq/src/cpufreq-selector/cpufreq-selector-procfs.c | 242 | ||||
-rw-r--r-- | cpufreq/src/cpufreq-selector/cpufreq-selector-procfs.h | 54 | ||||
-rw-r--r-- | po/POTFILES.in | 1 |
10 files changed, 35 insertions, 603 deletions
diff --git a/cpufreq/README b/cpufreq/README index a4d516af..371256a3 100644 --- a/cpufreq/README +++ b/cpufreq/README @@ -6,7 +6,6 @@ MATE CPUFreq Applet is a CPU Frequency Scaling Monitor for MATE Panel. FEATURES -------- - - Support for proc or sys filesystems - Support for multiprocessor systems - It can be used as frequency selector diff --git a/cpufreq/src/Makefile.am b/cpufreq/src/Makefile.am index cd64db9e..e7b42722 100644 --- a/cpufreq/src/Makefile.am +++ b/cpufreq/src/Makefile.am @@ -10,10 +10,6 @@ AM_CPPFLAGS = \ libexec_PROGRAMS = mate-cpufreq-applet -if HAVE_LIBCPUFREQ -cpufreq_files=cpufreq-monitor-libcpufreq.c cpufreq-monitor-libcpufreq.h -endif - BUILT_SOURCES = \ cpufreq-resources.c cpufreq-resources.h @@ -27,11 +23,19 @@ mate_cpufreq_applet_SOURCES = \ cpufreq-selector.c cpufreq-selector.h \ cpufreq-popup.c cpufreq-popup.h \ cpufreq-monitor.c cpufreq-monitor.h \ - cpufreq-monitor-factory.c cpufreq-monitor-factory.h \ - cpufreq-monitor-procfs.c cpufreq-monitor-procfs.h \ - cpufreq-monitor-sysfs.c cpufreq-monitor-sysfs.h \ - $(cpufreq_files) \ - cpufreq-monitor-cpuinfo.c cpufreq-monitor-cpuinfo.h + cpufreq-monitor-factory.c cpufreq-monitor-factory.h + +if HAVE_LIBCPUFREQ +mate_cpufreq_applet_SOURCES += \ + cpufreq-monitor-libcpufreq.c \ + cpufreq-monitor-libcpufreq.h +else +mate_cpufreq_applet_SOURCES += \ + cpufreq-monitor-cpuinfo.c \ + cpufreq-monitor-cpuinfo.h \ + cpufreq-monitor-sysfs.c \ + cpufreq-monitor-sysfs.h +endif mate_cpufreq_applet_CFLAGS = \ ${WARN_CFLAGS} diff --git a/cpufreq/src/cpufreq-monitor-factory.c b/cpufreq/src/cpufreq-monitor-factory.c index 2c6bf0b6..0c809671 100644 --- a/cpufreq/src/cpufreq-monitor-factory.c +++ b/cpufreq/src/cpufreq-monitor-factory.c @@ -28,13 +28,13 @@ #include "cpufreq-applet.h" #include "cpufreq-utils.h" -#include "cpufreq-monitor-sysfs.h" -#include "cpufreq-monitor-procfs.h" -#include "cpufreq-monitor-cpuinfo.h" +#include "cpufreq-monitor-factory.h" #ifdef HAVE_LIBCPUFREQ #include "cpufreq-monitor-libcpufreq.h" +#else +#include "cpufreq-monitor-sysfs.h" +#include "cpufreq-monitor-cpuinfo.h" #endif -#include "cpufreq-monitor-factory.h" CPUFreqMonitor * cpufreq_monitor_factory_create_monitor (guint cpu) @@ -44,10 +44,8 @@ cpufreq_monitor_factory_create_monitor (guint cpu) #else CPUFreqMonitor *monitor = NULL; - if (g_file_test ("/sys/devices/system/cpu/cpu0/cpufreq", G_FILE_TEST_EXISTS)) { /* 2.6 kernel */ + if (g_file_test ("/sys/devices/system/cpu/cpu0/cpufreq", G_FILE_TEST_EXISTS)) { monitor = cpufreq_monitor_sysfs_new (cpu); - } else if (g_file_test ("/proc/cpufreq", G_FILE_TEST_EXISTS)) { /* 2.4 kernel (Deprecated)*/ - monitor = cpufreq_monitor_procfs_new (cpu); } else if (g_file_test ("/proc/cpuinfo", G_FILE_TEST_EXISTS)) { /* If there is no cpufreq support it shows only the cpu frequency, * I think is better than do nothing. I have to notify it to the user, because diff --git a/cpufreq/src/cpufreq-monitor-procfs.c b/cpufreq/src/cpufreq-monitor-procfs.c deleted file mode 100644 index 0c7b3b9c..00000000 --- a/cpufreq/src/cpufreq-monitor-procfs.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * MATE CPUFreq Applet - * Copyright (C) 2004 Carlos Garcia Campos <[email protected]> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Authors : Carlos Garc�a Campos <[email protected]> - */ - -#include <glib.h> -#include <glib/gi18n.h> - -#include <string.h> -#include <stdlib.h> -#include <stdio.h> - -#include "cpufreq-monitor-procfs.h" -#include "cpufreq-utils.h" - -static gboolean cpufreq_monitor_procfs_run (CPUFreqMonitor *monitor); -static GList *cpufreq_monitor_procfs_get_available_frequencies (CPUFreqMonitor *monitor); - -G_DEFINE_TYPE (CPUFreqMonitorProcfs, cpufreq_monitor_procfs, CPUFREQ_TYPE_MONITOR) - -static void -cpufreq_monitor_procfs_init (CPUFreqMonitorProcfs *monitor) -{ -} - -static void -cpufreq_monitor_procfs_class_init (CPUFreqMonitorProcfsClass *klass) -{ - CPUFreqMonitorClass *monitor_class = CPUFREQ_MONITOR_CLASS (klass); - - monitor_class->run = cpufreq_monitor_procfs_run; - monitor_class->get_available_frequencies = cpufreq_monitor_procfs_get_available_frequencies; -} - -CPUFreqMonitor * -cpufreq_monitor_procfs_new (guint cpu) -{ - CPUFreqMonitorProcfs *monitor; - - monitor = g_object_new (TYPE_CPUFREQ_MONITOR_PROCFS, "cpu", cpu, NULL); - - return CPUFREQ_MONITOR (monitor); -} - -static gint -cpufreq_monitor_procfs_get_freq_from_userspace (guint cpu) -{ - gchar *buffer = NULL; - gchar *path; - gchar *p; - gchar *frequency; - gint freq; - gint len; - GError *error = NULL; - - path = g_strdup_printf ("/proc/sys/cpu/%u/speed", cpu); - - if (!cpufreq_file_get_contents (path, &buffer, NULL, &error)) { - g_warning ("%s", error->message); - g_error_free (error); - - g_free (path); - - return -1; - } - - g_free (path); - - /* Try to remove the '\n' */ - p = g_strrstr (buffer, "\n"); - len = strlen (buffer); - if (p) - len -= strlen (p); - - frequency = g_strndup (buffer, len); - g_free (buffer); - - freq = atoi (frequency); - g_free (frequency); - - return freq; -} - -static gboolean -cpufreq_monitor_procfs_parse (CPUFreqMonitorProcfs *monitor, - gint *cpu, - gint *fmax, - gint *pmin, - gint *pmax, - gint *fmin, - gchar *mode) -{ - gchar **lines; - gchar *buffer = NULL; - gint i, count; - guint mon_cpu; - GError *error = NULL; - - if (!cpufreq_file_get_contents ("/proc/cpufreq", &buffer, NULL, &error)) { - g_warning ("%s", error->message); - g_error_free (error); - - return FALSE; - } - - g_object_get (G_OBJECT (monitor), - "cpu", &mon_cpu, NULL); - - count = 0; - lines = g_strsplit (buffer, "\n", -1); - for (i = 0; lines[i]; i++) { - if (g_ascii_strncasecmp (lines[i], "CPU", 3) == 0) { - /* CPU 0 650000 kHz ( 81 %) - 800000 kHz (100 %) - powersave */ - count = sscanf (lines[i], "CPU %d %d kHz (%d %%) - %d kHz (%d %%) - %20s", - cpu, fmin, pmin, fmax, pmax, mode); - - if ((guint)(*cpu) == mon_cpu) - break; - } - } - - g_strfreev (lines); - g_free (buffer); - - return (count == 6); -} - -static gboolean -cpufreq_procfs_cpu_is_online (void) -{ - return g_file_test ("/proc/cpufreq", - G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR); -} - -static gboolean -cpufreq_monitor_procfs_run (CPUFreqMonitor *monitor) -{ - gint fmax, fmin, cpu; - gint pmin, pmax; - gchar mode[21]; - gint cur_freq, max_freq; - gchar *governor; - - if (!cpufreq_monitor_procfs_parse (CPUFREQ_MONITOR_PROCFS (monitor), - &cpu, &fmax, &pmin, &pmax, &fmin, mode)) { - /* Check whether it failed because - * cpu is not online. - */ - if (!cpufreq_procfs_cpu_is_online ()) { - g_object_set (G_OBJECT (monitor), "online", FALSE, NULL); - return TRUE; - } - return FALSE; - } - - governor = mode; - max_freq = fmax; - - if (g_ascii_strcasecmp (governor, "powersave") == 0) { - cur_freq = fmin; - } else if (g_ascii_strcasecmp (governor, "performance") == 0) { - cur_freq = fmax; - } else if (g_ascii_strcasecmp (governor, "userspace") == 0) { - cur_freq = cpufreq_monitor_procfs_get_freq_from_userspace (cpu); - } else { - cur_freq = fmax; - } - - g_object_set (G_OBJECT (monitor), - "online", TRUE, - "governor", governor, - "frequency", cur_freq, - "max-frequency", max_freq, - NULL); - - return TRUE; -} - -static GList * -cpufreq_monitor_procfs_get_available_frequencies (CPUFreqMonitor *monitor) -{ - gint fmax, fmin, cpu, freq; - gint pmin, pmax; - gchar mode[21]; - GList *list = NULL; - - if (!cpufreq_monitor_procfs_parse (CPUFREQ_MONITOR_PROCFS (monitor), &cpu, - &fmax, &pmin, &pmax, &fmin, mode)) { - return NULL; - } - - if ((pmax > 0) && (pmax != 100)) { - freq = (fmax * 100) / pmax; - list = g_list_prepend (list, g_strdup_printf ("%d", freq)); - } - - list = g_list_prepend (list, g_strdup_printf ("%d", fmax)); - if (fmax != fmin) - list = g_list_prepend (list, g_strdup_printf ("%d", fmin)); - - return g_list_reverse (list); -} - diff --git a/cpufreq/src/cpufreq-monitor-procfs.h b/cpufreq/src/cpufreq-monitor-procfs.h deleted file mode 100644 index 1e6e4a71..00000000 --- a/cpufreq/src/cpufreq-monitor-procfs.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * MATE CPUFreq Applet - * Copyright (C) 2004 Carlos Garcia Campos <[email protected]> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Authors : Carlos Garc�a Campos <[email protected]> - */ - -#ifndef __CPUFREQ_MONITOR_PROCFS_H__ -#define __CPUFREQ_MONITOR_PROCFS_H__ - -#include <glib-object.h> - -#include "cpufreq-monitor.h" - -G_BEGIN_DECLS - -#define TYPE_CPUFREQ_MONITOR_PROCFS (cpufreq_monitor_procfs_get_type ()) -#define CPUFREQ_MONITOR_PROCFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CPUFREQ_MONITOR_PROCFS, CPUFreqMonitorProcfs)) -#define CPUFREQ_MONITOR_PROCFS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_CPUFREQ_MONITOR_PROCFS, CPUFreqMonitorProcfsClass)) -#define IS_CPUFREQ_MONITOR_PROCFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CPUFREQ_MONITOR_PROCFS)) -#define IS_CPUFREQ_MONITOR_PROCFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CPUFREQ_MONITOR_PROCFS)) -#define CPUFREQ_MONITOR_PROCFS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CPUFREQ_MONITOR_PROCFS, CPUFreqMonitorProcfsClass)) - -typedef struct _CPUFreqMonitorProcfs CPUFreqMonitorProcfs; -typedef struct _CPUFreqMonitorProcfsClass CPUFreqMonitorProcfsClass; - -struct _CPUFreqMonitorProcfs { - CPUFreqMonitor parent; -}; - -struct _CPUFreqMonitorProcfsClass { - CPUFreqMonitorClass parent_class; -}; - -GType cpufreq_monitor_procfs_get_type (void) G_GNUC_CONST; -CPUFreqMonitor *cpufreq_monitor_procfs_new (guint cpu); - -G_END_DECLS - -#endif /* __CPUFREQ_MONITOR_PROCFS_H__ */ diff --git a/cpufreq/src/cpufreq-selector/Makefile.am b/cpufreq/src/cpufreq-selector/Makefile.am index b75a26c4..375d0371 100644 --- a/cpufreq/src/cpufreq-selector/Makefile.am +++ b/cpufreq/src/cpufreq-selector/Makefile.am @@ -15,11 +15,6 @@ if CPUFREQ_SELECTOR_SUID chmod 4755 $(DESTDIR)$(bindir)/mate-cpufreq-selector endif - -if HAVE_LIBCPUFREQ -cpufreq_files=cpufreq-selector-libcpufreq.c cpufreq-selector-libcpufreq.h -endif - if HAVE_POLKIT service_files=cpufreq-selector-service.c cpufreq-selector-service.h endif @@ -27,13 +22,21 @@ endif mate_cpufreq_selector_SOURCES = \ cpufreq-selector.c cpufreq-selector.h \ cpufreq-selector-sysfs.c cpufreq-selector-sysfs.h \ - cpufreq-selector-procfs.c cpufreq-selector-procfs.h \ - $(cpufreq_files) \ $(service_files) \ cpufreq-selector-factory.c cpufreq-selector-factory.h \ $(BUILT_SOURCES) \ main.c +if HAVE_LIBCPUFREQ +mate_cpufreq_selector_SOURCES += \ + cpufreq-selector-libcpufreq.c \ + cpufreq-selector-libcpufreq.h +else +mate_cpufreq_selector_SOURCES += \ + cpufreq-selector-sysfs.h \ + cpufreq-selector-sysfs.c +endif + mate_cpufreq_selector_LDADD = \ $(CPUFREQ_SELECTOR_LIBS) \ $(LIBCPUFREQ_LIBS) diff --git a/cpufreq/src/cpufreq-selector/cpufreq-selector-factory.c b/cpufreq/src/cpufreq-selector/cpufreq-selector-factory.c index 9f9bd29d..0328ea40 100644 --- a/cpufreq/src/cpufreq-selector/cpufreq-selector-factory.c +++ b/cpufreq/src/cpufreq-selector/cpufreq-selector-factory.c @@ -22,26 +22,24 @@ #endif #include "cpufreq-selector-factory.h" -#include "cpufreq-selector-sysfs.h" -#include "cpufreq-selector-procfs.h" #ifdef HAVE_LIBCPUFREQ #include "cpufreq-selector-libcpufreq.h" +#else +#include "cpufreq-selector-sysfs.h" #endif CPUFreqSelector * cpufreq_selector_factory_create_selector (guint cpu) { - CPUFreqSelector *selector = NULL; - #ifdef HAVE_LIBCPUFREQ - selector = cpufreq_selector_libcpufreq_new (cpu); + return cpufreq_selector_libcpufreq_new (cpu); #else - if (g_file_test ("/sys/devices/system/cpu/cpu0/cpufreq", G_FILE_TEST_EXISTS)) { /* 2.6 kernel */ + CPUFreqSelector *selector = NULL; + + if (g_file_test ("/sys/devices/system/cpu/cpu0/cpufreq", G_FILE_TEST_EXISTS)) { selector = cpufreq_selector_sysfs_new (cpu); - } else if (g_file_test ("/proc/cpufreq", G_FILE_TEST_EXISTS)) { /* 2.4 kernel */ - selector = cpufreq_selector_procfs_new (cpu); } -#endif /* HAVE_LIBCPUFREQ */ return selector; +#endif /* HAVE_LIBCPUFREQ */ } diff --git a/cpufreq/src/cpufreq-selector/cpufreq-selector-procfs.c b/cpufreq/src/cpufreq-selector/cpufreq-selector-procfs.c deleted file mode 100644 index 002c387c..00000000 --- a/cpufreq/src/cpufreq-selector/cpufreq-selector-procfs.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * MATE CPUFreq Applet - * Copyright (C) 2004 Carlos Garcia Campos <[email protected]> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Authors : Carlos Garc�a Campos <[email protected]> - */ - -#include <glib.h> -#include <glib/gstdio.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> - -#include "cpufreq-selector-procfs.h" - -static gboolean -cpufreq_selector_procfs_set_frequency (CPUFreqSelector *selector, - guint frequency, - GError **error); -static gboolean -cpufreq_selector_procfs_set_governor (CPUFreqSelector *selector, - const gchar *governor, - GError **error); - -G_DEFINE_TYPE (CPUFreqSelectorProcfs, cpufreq_selector_procfs, CPUFREQ_TYPE_SELECTOR) - -static void -cpufreq_selector_procfs_init (CPUFreqSelectorProcfs *selector) -{ -} - -static void -cpufreq_selector_procfs_class_init (CPUFreqSelectorProcfsClass *klass) -{ - CPUFreqSelectorClass *selector_class = CPUFREQ_SELECTOR_CLASS (klass); - - selector_class->set_frequency = cpufreq_selector_procfs_set_frequency; - selector_class->set_governor = cpufreq_selector_procfs_set_governor; -} - -CPUFreqSelector * -cpufreq_selector_procfs_new (guint cpu) -{ - CPUFreqSelector *selector; - - selector = CPUFREQ_SELECTOR (g_object_new (CPUFREQ_TYPE_SELECTOR_PROCFS, - "cpu", cpu, - NULL)); - - return selector; -} - -static gboolean -cpufreq_procfs_read (guint selector_cpu, - guint *fmax, - guint *pmin, - guint *pmax, - guint *fmin, - gchar *mode, - GError **error) -{ - gchar **lines; - gchar *buffer = NULL; - gint i; - guint cpu; - gboolean found = FALSE; - - if (!g_file_get_contents ("/proc/cpufreq", &buffer, NULL, error)) { - return FALSE; - } - - lines = g_strsplit (buffer, "\n", -1); - for (i = 0; lines[i]; i++) { - if (g_ascii_strncasecmp (lines[i], "CPU", 3) == 0) { - /* CPU 0 650000 kHz ( 81 %) - 800000 kHz (100 %) - powersave */ - sscanf (lines[i], "CPU %u %u kHz (%u %%) - %u kHz (%u %%) - %20s", - &cpu, fmin, pmin, fmax, pmax, mode); - - if (cpu == selector_cpu) { - found = TRUE; - break; - } - } - } - - g_strfreev (lines); - g_free (buffer); - - if (!found) { - g_set_error (error, - CPUFREQ_SELECTOR_ERROR, - SELECTOR_ERROR_INVALID_CPU, - "Invalid CPU number '%d'", - selector_cpu); - - return FALSE; - } - - return TRUE; -} - -static gboolean -cpufreq_procfs_write (const gchar *path, - const gchar *setting, - GError **error) -{ - FILE *fd; - - fd = g_fopen (path, "w"); - - if (!fd) { - g_set_error (error, - G_FILE_ERROR, - g_file_error_from_errno (errno), - "Failed to open '%s' for writing: " - "g_fopen() failed: %s", - path, - g_strerror (errno)); - - return FALSE; - } - - if (g_fprintf (fd, "%s", setting) < 0) { - g_set_error (error, - G_FILE_ERROR, - g_file_error_from_errno (errno), - "Failed to write '%s': " - "g_fprintf() failed: %s", - path, - g_strerror (errno)); - - fclose (fd); - - return FALSE; - } - - fclose (fd); - - return TRUE; -} - -static gboolean -cpufreq_selector_procfs_set_frequency (CPUFreqSelector *selector, - guint frequency, - GError **error) -{ - gchar *str; - gchar *path; - guint freq; - guint cpu; - guint pmin, pmax; - guint sc_max, sc_min; - gchar mode[21]; - - g_object_get (G_OBJECT (selector), - "cpu", &cpu, - NULL); - - if (!cpufreq_procfs_read (cpu, &sc_max, &pmin, &pmax, &sc_min, mode, error)) { - return FALSE; - } - - if (g_ascii_strcasecmp (mode, "userspace") != 0) { - if (!cpufreq_selector_procfs_set_governor (selector, - "userspace", - error)) { - return FALSE; - } - } - - if (frequency != sc_max && frequency != sc_min) { - if (abs ((int)sc_max - (int)frequency) < abs ((int)frequency - (int)sc_min)) - freq = sc_max; - else - freq = sc_min; - } else { - freq = frequency; - } - - path = g_strdup_printf ("/proc/sys/cpu/%u/speed", cpu); - str = g_strdup_printf ("%u", freq); - if (!cpufreq_procfs_write (path, str, error)) { - g_free (path); - g_free (str); - - return FALSE; - } - - g_free (path); - g_free (str); - - return TRUE; -} - -static gboolean -cpufreq_selector_procfs_set_governor (CPUFreqSelector *selector, - const gchar *governor, - GError **error) -{ - gchar *str; - guint cpu; - guint pmin, pmax; - guint sc_max, sc_min; - gchar mode[21]; - - g_object_get (G_OBJECT (selector), - "cpu", &cpu, - NULL); - - if (!cpufreq_procfs_read (cpu, &sc_max, &pmin, &pmax, &sc_min, mode, error)) { - return FALSE; - } - - if (g_ascii_strcasecmp (governor, mode) == 0) - return TRUE; - - str = g_strdup_printf ("%u:%u:%u:%s", cpu, sc_min, sc_max, governor); - - if (!cpufreq_procfs_write ("/proc/cpufreq", str, error)) { - g_free (str); - - return FALSE; - } - - g_free (str); - - return TRUE; -} diff --git a/cpufreq/src/cpufreq-selector/cpufreq-selector-procfs.h b/cpufreq/src/cpufreq-selector/cpufreq-selector-procfs.h deleted file mode 100644 index 7d516b43..00000000 --- a/cpufreq/src/cpufreq-selector/cpufreq-selector-procfs.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * MATE CPUFreq Applet - * Copyright (C) 2004 Carlos Garcia Campos <[email protected]> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Authors : Carlos Garc�a Campos <[email protected]> - */ - -#ifndef __CPUFREQ_SELECTOR_PROCFS_H__ -#define __CPUFREQ_SELECTOR_PROCFS_H__ - -#include <glib-object.h> - -#include "cpufreq-selector.h" - -G_BEGIN_DECLS - -#define CPUFREQ_TYPE_SELECTOR_PROCFS (cpufreq_selector_procfs_get_type ()) -#define CPUFREQ_SELECTOR_PROCFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CPUFREQ_TYPE_SELECTOR_PROCFS, CPUFreqSelectorProcfs)) -#define CPUFREQ_SELECTOR_PROCFS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CPUFREQ_TYPE_SELECTOR_PROCFS, CPUFreqSelectorProcfsClass)) -#define CPUFREQ_IS_SELECTOR_PROCFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CPUFREQ_TYPE_SELECTOR_PROCFS)) -#define CPUFREQ_IS_SELECTOR_PROCFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CPUFREQ_TYPE_SELECTOR_PROCFS)) -#define CPUFREQ_SELECTOR_PROCFS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CPUFREQ_TYPE_SELECTOR_PROCFS, CPUFreqSelectorProcfsClass)) - -typedef struct _CPUFreqSelectorProcfs CPUFreqSelectorProcfs; -typedef struct _CPUFreqSelectorProcfsClass CPUFreqSelectorProcfsClass; - -struct _CPUFreqSelectorProcfs { - CPUFreqSelector parent; -}; - -struct _CPUFreqSelectorProcfsClass { - CPUFreqSelectorClass parent_class; -}; - -GType cpufreq_selector_procfs_get_type (void) G_GNUC_CONST; -CPUFreqSelector *cpufreq_selector_procfs_new (guint cpu); - -G_END_DECLS - -#endif /* __CPUFREQ_SELECTOR_PROCFS_H__ */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 191e1898..dcdf24c4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -24,7 +24,6 @@ cpufreq/src/cpufreq-applet.c cpufreq/src/cpufreq-prefs.c cpufreq/src/cpufreq-monitor-cpuinfo.c cpufreq/src/cpufreq-monitor-factory.c -cpufreq/src/cpufreq-monitor-procfs.c cpufreq/src/cpufreq-popup.c cpufreq/src/cpufreq-selector/org.mate.cpufreqselector.policy.in drivemount/drive-button.c |