1 |
bangert 09/10/27 09:07:13 |
2 |
|
3 |
Added: cpufreqd-2.3.4-lm_sensors-3.patch |
4 |
2.2.1-cpu_all.patch |
5 |
Log: |
6 |
fix logical error for CPU_ALL in cpu_evaluate (bug #187581), fix building with >lm_sensors-3 (bug #233481) |
7 |
(Portage version: 2.2_rc46/cvs/Linux i686) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 sys-power/cpufreqd/files/cpufreqd-2.3.4-lm_sensors-3.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-power/cpufreqd/files/cpufreqd-2.3.4-lm_sensors-3.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-power/cpufreqd/files/cpufreqd-2.3.4-lm_sensors-3.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: cpufreqd-2.3.4-lm_sensors-3.patch |
16 |
=================================================================== |
17 |
--- src/cpufreqd_sensors.c.orig 2009-03-21 12:17:15.000000000 +0100 |
18 |
+++ src/cpufreqd_sensors.c 2009-08-14 14:39:52.894513594 +0200 |
19 |
@@ -23,10 +23,22 @@ |
20 |
#include <string.h> |
21 |
#include "cpufreqd_plugin.h" |
22 |
|
23 |
+#if !defined __GNUC__ || __GNUC__ < 3 |
24 |
+#define __attribute__(x) |
25 |
+#endif |
26 |
+ |
27 |
+#if SENSORS_API_VERSION < 0x400 |
28 |
+typedef sensors_feature_data sensors_feature; |
29 |
+#endif |
30 |
+ |
31 |
/* to hold monitored feature list and avoid reading all sensors */ |
32 |
struct sensors_monitor { |
33 |
const sensors_chip_name *chip; |
34 |
- const sensors_feature_data *feat; |
35 |
+ char chip_string[MAX_STRING_LEN]; |
36 |
+ const sensors_feature *feat; |
37 |
+#if SENSORS_API_VERSION >= 0x400 |
38 |
+ const sensors_subfeature *sub_feat; |
39 |
+#endif |
40 |
double value; |
41 |
struct sensors_monitor *next; |
42 |
}; |
43 |
@@ -133,27 +145,74 @@ |
44 |
struct sensors_monitor *list = monitor_list; |
45 |
|
46 |
while (list) { |
47 |
- sensors_get_feature(*(list->chip), list->feat->number, &list->value); |
48 |
- clog(LOG_INFO, "%s: %.3f\n", list->feat->name, list->value); |
49 |
+#if SENSORS_API_VERSION >= 0x400 |
50 |
+ if(sensors_get_value(list->chip, list->sub_feat->number, &list->value) < 0) { |
51 |
+#else |
52 |
+ if(sensors_get_feature(*(list->chip), list->feat->number, &list->value) < 0) { |
53 |
+#endif |
54 |
+ clog(LOG_ERR,"could not read value for %s\n",list->feat->name); |
55 |
+ return -1; |
56 |
+ } |
57 |
+ clog(LOG_INFO, "%s:%s: %.3f\n", list->chip_string, list->feat->name, list->value); |
58 |
list = list->next; |
59 |
} |
60 |
|
61 |
return 0; |
62 |
} |
63 |
|
64 |
+ |
65 |
+#if SENSORS_API_VERSION < 0x400 |
66 |
+/* Adapted from lm-sensors 2.10.8 prog/sensors/main.c */ |
67 |
+static int sensors_snprintf_chip_name(char *str, size_t size, |
68 |
+ const sensors_chip_name *chip) |
69 |
+{ |
70 |
+ switch(chip->bus) { |
71 |
+ case SENSORS_CHIP_NAME_BUS_ISA: |
72 |
+ return snprintf(str,size,"%s-isa-%04x",chip->prefix,chip->addr); |
73 |
+ case SENSORS_CHIP_NAME_BUS_PCI: |
74 |
+ return snprintf(str,size,"%s-pci-%04x",chip->prefix,chip->addr); |
75 |
+ case SENSORS_CHIP_NAME_BUS_DUMMY: |
76 |
+ return snprintf(str,size,"%s-%s-%04x",chip->prefix,chip->busname,chip->addr); |
77 |
+ default: |
78 |
+ return snprintf(str,size,"%s-i2c-%d-%02x",chip->prefix,chip->bus,chip->addr); |
79 |
+ } |
80 |
+} |
81 |
+#endif |
82 |
+ |
83 |
+__attribute__((unused)) static const char* sensors_get_chip_name(const sensors_chip_name *chip); |
84 |
+static const char* sensors_get_chip_name(const sensors_chip_name *chip) { |
85 |
+ static char name[MAX_STRING_LEN]; |
86 |
+ sensors_snprintf_chip_name(name, MAX_STRING_LEN, chip); |
87 |
+ return name; |
88 |
+} |
89 |
+ |
90 |
/* this function can be pretty expensive (CPU time)?? */ |
91 |
static struct sensors_monitor * validate_feature_name(const char *name) { |
92 |
|
93 |
/* get all sensors from first chip */ |
94 |
const sensors_chip_name *chip; |
95 |
- const sensors_feature_data *feat; |
96 |
- int nr = 0, nr1 = 0, nr2 = 0; |
97 |
+ const sensors_feature *feat; |
98 |
+ int nr = 0; |
99 |
+#if SENSORS_API_VERSION >= 0x400 |
100 |
+ const sensors_subfeature *sub_feat; |
101 |
+#else |
102 |
+ int nr1 = 0, nr2 = 0; |
103 |
+#endif |
104 |
struct sensors_monitor *list = monitor_list; |
105 |
struct sensors_monitor *ret = NULL; |
106 |
|
107 |
/* scan the full thing */ |
108 |
+#if SENSORS_API_VERSION >= 0x400 |
109 |
+ while ( (chip = sensors_get_detected_chips(NULL, &nr)) != NULL) { |
110 |
+ while ((feat = sensors_get_features(chip, &nr)) != NULL) { |
111 |
+ /* sensor input? */ |
112 |
+ if((sub_feat = sensors_get_subfeature(chip, feat, feat->type << 8)) == NULL) { |
113 |
+ clog(LOG_DEBUG, "Input subfeature not found for %s, skipping\n", feat->name); |
114 |
+ continue; |
115 |
+ } |
116 |
+#else |
117 |
while ( (chip = sensors_get_detected_chips(&nr)) != NULL) { |
118 |
- nr1 = nr2 = 0; |
119 |
+ nr1 = nr2 = 0; |
120 |
char *label = NULL; |
121 |
clog(LOG_DEBUG, "Examining chip %s(%d)\n", chip->prefix, nr); |
122 |
while ((feat = sensors_get_all_features(*chip, &nr1, &nr2)) != NULL) { |
123 |
@@ -164,22 +223,33 @@ |
124 |
if (sensors_get_label(*chip, feat->number, &label) != 0) |
125 |
clog(LOG_DEBUG, "Couldn't get label for %s (%s)\n", |
126 |
feat->name, strerror(errno)); |
127 |
+ } |
128 |
+#endif |
129 |
|
130 |
/* is it the one we are looking for? */ |
131 |
- if (strncmp(feat->name, name, MAX_STRING_LEN) != 0 && |
132 |
- (label && strncmp(label, name, MAX_STRING_LEN) != 0)) { |
133 |
- free(label); |
134 |
+ if (strncmp(feat->name, name, MAX_STRING_LEN) != 0) { |
135 |
+ continue; |
136 |
+ |
137 |
+/* libsensors4 does this in sensors_get_features() */ |
138 |
+#if SENSORS_API_VERSION < 0x400 |
139 |
+ /* not ignored? */ |
140 |
+ } else if(sensors_get_ignored(*chip, feat->number) == 0) { |
141 |
+ clog(LOG_INFO, "feature %s on chip %s set to ignore in %s, skipping\n", |
142 |
+ feat->name, sensors_get_chip_name(chip), sensors_conffile); |
143 |
continue; |
144 |
+#endif |
145 |
|
146 |
/* cache it */ |
147 |
} else if ((ret = calloc(1, sizeof(struct sensors_monitor))) != NULL) { |
148 |
- clog(LOG_DEBUG, "Creating new sensors_monitor for %s (%s)\n", |
149 |
- label, feat->name); |
150 |
+ sensors_snprintf_chip_name(ret->chip_string, MAX_STRING_LEN, chip); |
151 |
+ clog(LOG_DEBUG, "Creating new sensors_monitor for %s on chip %s\n", |
152 |
+ name, ret->chip_string); |
153 |
ret->chip = chip; |
154 |
ret->feat = feat; |
155 |
+#if SENSORS_API_VERSION >= 0x400 |
156 |
+ ret->sub_feat = sub_feat; |
157 |
+#endif |
158 |
ret->next = NULL; |
159 |
- /* free the label here, we are not using it anymore */ |
160 |
- free(label); |
161 |
/* append monitor to the cache list */ |
162 |
list = monitor_list; |
163 |
if (list != NULL) { |
164 |
@@ -214,7 +284,7 @@ |
165 |
clog(LOG_DEBUG, "called with %s\n", ev); |
166 |
|
167 |
/* try to parse the %[a-zA-Z0-9]:%d-%d format first */ |
168 |
- if (sscanf(ev, "%32[^:]:%lf-%lf", ret->name, &ret->min, &ret->max) == 3) { |
169 |
+ if (sscanf(ev, "%32[a-zA-Z0-9]:%lf-%lf", ret->name, &ret->min, &ret->max) == 3) { |
170 |
/* validate feature name */ |
171 |
if ((ret->monitor = validate_feature_name(ret->name)) != NULL) { |
172 |
clog(LOG_INFO, "parsed %s %.3f-%.3f\n", ret->name, ret->min, ret->max); |
173 |
|
174 |
|
175 |
|
176 |
1.1 sys-power/cpufreqd/files/2.2.1-cpu_all.patch |
177 |
|
178 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-power/cpufreqd/files/2.2.1-cpu_all.patch?rev=1.1&view=markup |
179 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-power/cpufreqd/files/2.2.1-cpu_all.patch?rev=1.1&content-type=text/plain |
180 |
|
181 |
Index: 2.2.1-cpu_all.patch |
182 |
=================================================================== |
183 |
--- cpufreqd-2.2.1.orig/src/cpufreqd_cpu.c 2007-08-03 13:55:54.000000000 +0200 |
184 |
+++ cpufreqd-2.2.1/src/cpufreqd_cpu.c 2007-08-03 14:17:36.000000000 +0200 |
185 |
@@ -222,7 +222,7 @@ |
186 |
/* special handling for CPU_ALL and CPU_ANY */ |
187 |
if (c->cpu == CPU_ANY || c->cpu == CPU_ALL) { |
188 |
for (i = 0; i < cinfo->cpus; i++) { |
189 |
- clog(LOG_DEBUG, "CPU%d user=%d nice=%d sys=%d\n", c->cpu, |
190 |
+ clog(LOG_DEBUG, "CPU%d user=%d nice=%d sys=%d\n", i, |
191 |
cusage[i].c_user, cusage[i].c_nice, cusage[i].c_sys); |
192 |
cpu_percent = calculate_cpu_usage(&cusage[i], &cusage_old[i], c->nice_scale); |
193 |
clog(LOG_DEBUG, "CPU%d %d%% - min=%d max=%d scale=%.2f (%s)\n", i, cpu_percent, |
194 |
@@ -234,14 +234,16 @@ |
195 |
if (c->cpu == CPU_ALL && !(cpu_percent >= c->min && cpu_percent <= c->max)) |
196 |
break; |
197 |
} |
198 |
- /* if this code is reached then either CPU_ANY and none matches |
199 |
- * or CPU_ALL and all match |
200 |
+ /* if this code is reached then |
201 |
+ * either CPU_ANY and none matches |
202 |
+ * or CPU_ALL and all match, where i == cinfo->cpus |
203 |
+ * or CPU_ALL and break was called |
204 |
*/ |
205 |
- if (c->cpu == CPU_ANY) { |
206 |
- c = c->next; |
207 |
- continue; |
208 |
- } |
209 |
- return MATCH; /*if (c->cpu == ALL)*/ |
210 |
+ if (c->cpu == CPU_ALL && i == cinfo->cpus) |
211 |
+ return MATCH; |
212 |
+ |
213 |
+ c = c->next; |
214 |
+ continue; |
215 |
} |
216 |
|
217 |
/* cacluate weighted activity for the requested CPU */ |