Merge lp:~lihow731/ubuntu/saucy/cpufreqd/fix-for-1162160 into lp:ubuntu/trusty/cpufreqd
- Saucy (13.10)
- fix-for-1162160
- Merge into trusty
Proposed by
Leon Liao
Status: | Rejected |
---|---|
Rejected by: | Jamie Strandboge |
Proposed branch: | lp:~lihow731/ubuntu/saucy/cpufreqd/fix-for-1162160 |
Merge into: | lp:ubuntu/trusty/cpufreqd |
Diff against target: |
553 lines (+11/-481) 6 files modified
.pc/619913.patch/src/cpufreqd_acpi_battery.c (+0/-401) .pc/applied-patches (+0/-2) .pc/path_max.patch/src/cpufreqd.h (+0/-59) debian/changelog (+7/-0) src/cpufreqd.h (+1/-7) src/cpufreqd_acpi_battery.c (+3/-12) |
To merge this branch: | bzr merge lp:~lihow731/ubuntu/saucy/cpufreqd/fix-for-1162160 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jamie Strandboge | Disapprove | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed directory '.pc/619913.patch' | |||
2 | === removed directory '.pc/619913.patch/src' | |||
3 | === removed file '.pc/619913.patch/src/cpufreqd_acpi_battery.c' | |||
4 | --- .pc/619913.patch/src/cpufreqd_acpi_battery.c 2013-03-23 21:42:31 +0000 | |||
5 | +++ .pc/619913.patch/src/cpufreqd_acpi_battery.c 1970-01-01 00:00:00 +0000 | |||
6 | @@ -1,401 +0,0 @@ | |||
7 | 1 | /* | ||
8 | 2 | * Copyright (C) 2002-2006 Mattia Dongili <malattia@linux.it> | ||
9 | 3 | * George Staikos <staikos@0wned.org> | ||
10 | 4 | * | ||
11 | 5 | * This program is free software; you can redistribute it and/or modify | ||
12 | 6 | * it under the terms of the GNU General Public License as published by | ||
13 | 7 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | 8 | * (at your option) any later version. | ||
15 | 9 | * | ||
16 | 10 | * This program is distributed in the hope that it will be useful, | ||
17 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | 13 | * GNU General Public License for more details. | ||
20 | 14 | * | ||
21 | 15 | * You should have received a copy of the GNU General Public License | ||
22 | 16 | * along with this program; if not, write to the Free Software | ||
23 | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | 18 | */ | ||
25 | 19 | |||
26 | 20 | #include <dirent.h> | ||
27 | 21 | #include <errno.h> | ||
28 | 22 | #include <stdio.h> | ||
29 | 23 | #include <stdlib.h> | ||
30 | 24 | #include <string.h> | ||
31 | 25 | #include "cpufreqd_plugin.h" | ||
32 | 26 | #include "cpufreqd_acpi.h" | ||
33 | 27 | #include "cpufreqd_acpi_event.h" | ||
34 | 28 | #include "cpufreqd_acpi_battery.h" | ||
35 | 29 | |||
36 | 30 | #define POWER_SUPPLY "power_supply" | ||
37 | 31 | #define BATTERY_TYPE "Battery" | ||
38 | 32 | #define ENERGY_FULL "energy_full" | ||
39 | 33 | #define ENERGY_NOW "energy_now" | ||
40 | 34 | #define CHARGE_FULL "charge_full" | ||
41 | 35 | #define CHARGE_NOW "charge_now" | ||
42 | 36 | #define PRESENT "present" | ||
43 | 37 | #define STATUS "status" | ||
44 | 38 | #define CURRENT_NOW "current_now" | ||
45 | 39 | |||
46 | 40 | struct battery_info { | ||
47 | 41 | int capacity; | ||
48 | 42 | int remaining; | ||
49 | 43 | int present_rate; | ||
50 | 44 | int level; /* computed percentage */ | ||
51 | 45 | int is_present; | ||
52 | 46 | |||
53 | 47 | struct sysfs_class_device *cdev; | ||
54 | 48 | struct sysfs_attribute *energy_full; /* last full capacity */ | ||
55 | 49 | struct sysfs_attribute *energy_now; /* remaining capacity */ | ||
56 | 50 | struct sysfs_attribute *present; | ||
57 | 51 | struct sysfs_attribute *status; | ||
58 | 52 | struct sysfs_attribute *current_now; /* present rate */ | ||
59 | 53 | |||
60 | 54 | int open; | ||
61 | 55 | }; | ||
62 | 56 | |||
63 | 57 | struct battery_interval { | ||
64 | 58 | int min, max; | ||
65 | 59 | struct battery_info *bat; | ||
66 | 60 | }; | ||
67 | 61 | |||
68 | 62 | /* don't want to handle more than 8 batteries... yet */ | ||
69 | 63 | static struct battery_info info[8]; | ||
70 | 64 | static int bat_dir_num; | ||
71 | 65 | static int avg_battery_level; | ||
72 | 66 | static double check_timeout; | ||
73 | 67 | static double old_time; | ||
74 | 68 | extern struct acpi_configuration acpi_config; | ||
75 | 69 | |||
76 | 70 | /* validate if the requested battery exists */ | ||
77 | 71 | static struct battery_info *get_battery_info(const char *name) | ||
78 | 72 | { | ||
79 | 73 | int i; | ||
80 | 74 | struct battery_info *ret = NULL; | ||
81 | 75 | |||
82 | 76 | for (i = 0; i < bat_dir_num; i++) { | ||
83 | 77 | if (strncmp(info[i].cdev->name, name, SYSFS_NAME_LEN) == 0) { | ||
84 | 78 | ret = &info[i]; | ||
85 | 79 | break; | ||
86 | 80 | } | ||
87 | 81 | } | ||
88 | 82 | return ret; | ||
89 | 83 | } | ||
90 | 84 | |||
91 | 85 | /* close all the attributes and reset the open status */ | ||
92 | 86 | static void close_battery(struct battery_info *binfo) { | ||
93 | 87 | |||
94 | 88 | if (!binfo->open) return; | ||
95 | 89 | |||
96 | 90 | if (binfo->energy_full) | ||
97 | 91 | put_attribute(binfo->energy_full); | ||
98 | 92 | if (binfo->energy_now) | ||
99 | 93 | put_attribute(binfo->energy_now); | ||
100 | 94 | if (binfo->present) | ||
101 | 95 | put_attribute(binfo->present); | ||
102 | 96 | if (binfo->status) | ||
103 | 97 | put_attribute(binfo->status); | ||
104 | 98 | if (binfo->current_now) | ||
105 | 99 | put_attribute(binfo->current_now); | ||
106 | 100 | |||
107 | 101 | binfo->open = 0; | ||
108 | 102 | } | ||
109 | 103 | /* read battery levels as reported by hw */ | ||
110 | 104 | static int read_battery(struct battery_info *binfo) { | ||
111 | 105 | clog(LOG_DEBUG, "%s - reading battery levels\n", binfo->cdev->name); | ||
112 | 106 | |||
113 | 107 | if (read_int(binfo->current_now, &binfo->present_rate) != 0) { | ||
114 | 108 | clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name); | ||
115 | 109 | return -1; | ||
116 | 110 | } | ||
117 | 111 | if (read_int(binfo->energy_now, &binfo->remaining) != 0) { | ||
118 | 112 | clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name); | ||
119 | 113 | return -1; | ||
120 | 114 | } | ||
121 | 115 | if (read_value(binfo->status) != 0) { | ||
122 | 116 | clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name); | ||
123 | 117 | return -1; | ||
124 | 118 | } | ||
125 | 119 | clog(LOG_DEBUG, "%s - remaining capacity: %d\n", | ||
126 | 120 | binfo->cdev->name, binfo->remaining); | ||
127 | 121 | return 0; | ||
128 | 122 | } | ||
129 | 123 | /* open all the required attributes and set the open status */ | ||
130 | 124 | static int open_battery(struct battery_info *binfo) { | ||
131 | 125 | binfo->open = 1; | ||
132 | 126 | |||
133 | 127 | binfo->energy_full = get_class_device_attribute(binfo->cdev, ENERGY_FULL); | ||
134 | 128 | if (!binfo->energy_full) { | ||
135 | 129 | /* try the "charge_full" name */ | ||
136 | 130 | binfo->energy_full = get_class_device_attribute(binfo->cdev, | ||
137 | 131 | CHARGE_FULL); | ||
138 | 132 | if (!binfo->energy_full) | ||
139 | 133 | return -1; | ||
140 | 134 | } | ||
141 | 135 | binfo->energy_now = get_class_device_attribute(binfo->cdev, ENERGY_NOW); | ||
142 | 136 | if (!binfo->energy_now) { | ||
143 | 137 | /* try the "charge_now" name */ | ||
144 | 138 | binfo->energy_now = get_class_device_attribute(binfo->cdev, CHARGE_NOW); | ||
145 | 139 | if (!binfo->energy_now) | ||
146 | 140 | return -1; | ||
147 | 141 | } | ||
148 | 142 | binfo->present = get_class_device_attribute(binfo->cdev, PRESENT); | ||
149 | 143 | if (!binfo->present) | ||
150 | 144 | return -1; | ||
151 | 145 | binfo->status = get_class_device_attribute(binfo->cdev, STATUS); | ||
152 | 146 | if (!binfo->status) | ||
153 | 147 | return -1; | ||
154 | 148 | binfo->current_now = get_class_device_attribute(binfo->cdev, CURRENT_NOW); | ||
155 | 149 | if (!binfo->current_now) | ||
156 | 150 | return -1; | ||
157 | 151 | |||
158 | 152 | /* read the last full capacity, this is not going to change | ||
159 | 153 | * very often, so no need to poke it later */ | ||
160 | 154 | if (read_int(binfo->energy_full, &binfo->capacity) != 0) { | ||
161 | 155 | clog(LOG_WARNING, "Couldn't read %s capacity (%s)\n", | ||
162 | 156 | binfo->cdev->name, strerror(errno)); | ||
163 | 157 | return -1; | ||
164 | 158 | } | ||
165 | 159 | return 0; | ||
166 | 160 | } | ||
167 | 161 | |||
168 | 162 | /* set the battery class device into the battery_info array */ | ||
169 | 163 | static int clsdev_callback(struct sysfs_class_device *cdev) { | ||
170 | 164 | clog(LOG_DEBUG, "Got device %s\n", cdev->name); | ||
171 | 165 | info[bat_dir_num].cdev = cdev; | ||
172 | 166 | bat_dir_num++; | ||
173 | 167 | return 0; | ||
174 | 168 | } | ||
175 | 169 | |||
176 | 170 | /* int acpi_battery_init(void) | ||
177 | 171 | * | ||
178 | 172 | * this never fails since batteries are hotpluggable and | ||
179 | 173 | * we can easily rescan for availability later (see acpi_battery_update | ||
180 | 174 | * when an event is pending) | ||
181 | 175 | */ | ||
182 | 176 | short int acpi_battery_init(void) { | ||
183 | 177 | int i; | ||
184 | 178 | |||
185 | 179 | find_class_device(POWER_SUPPLY, BATTERY_TYPE, &clsdev_callback); | ||
186 | 180 | if (bat_dir_num <= 0) { | ||
187 | 181 | clog(LOG_INFO, "No Batteries found\n"); | ||
188 | 182 | return 0; | ||
189 | 183 | } | ||
190 | 184 | /* open the required attributes */ | ||
191 | 185 | for (i = 0; i < bat_dir_num; i++) { | ||
192 | 186 | clog(LOG_DEBUG, "Opening %s attributes\n", info[i].cdev->name); | ||
193 | 187 | if (open_battery(&info[i]) != 0) { | ||
194 | 188 | clog(LOG_WARNING, "Couldn't open %s attributes\n", | ||
195 | 189 | info[i].cdev->name); | ||
196 | 190 | close_battery(&info[i]); | ||
197 | 191 | } | ||
198 | 192 | } | ||
199 | 193 | clog(LOG_INFO, "found %d Batter%s\n", bat_dir_num, | ||
200 | 194 | bat_dir_num > 1 ? "ies" : "y"); | ||
201 | 195 | return 0; | ||
202 | 196 | } | ||
203 | 197 | short int acpi_battery_exit(void) { | ||
204 | 198 | /* also reset values since this is called on pending | ||
205 | 199 | * acpi events to rescan batteries | ||
206 | 200 | */ | ||
207 | 201 | while (--bat_dir_num >= 0) { | ||
208 | 202 | close_battery(&info[bat_dir_num]); | ||
209 | 203 | put_class_device(info[bat_dir_num].cdev); | ||
210 | 204 | info[bat_dir_num].cdev = NULL; | ||
211 | 205 | } | ||
212 | 206 | bat_dir_num = 0; | ||
213 | 207 | clog(LOG_INFO, "exited.\n"); | ||
214 | 208 | return 0; | ||
215 | 209 | } | ||
216 | 210 | /* | ||
217 | 211 | * Parses entries of the form %d-%d (min-max) | ||
218 | 212 | */ | ||
219 | 213 | int acpi_battery_parse(const char *ev, void **obj) { | ||
220 | 214 | char battery_name[32]; | ||
221 | 215 | struct battery_interval *ret = calloc(1, sizeof(struct battery_interval)); | ||
222 | 216 | if (ret == NULL) { | ||
223 | 217 | clog(LOG_ERR, "couldn't make enough room for battery_interval (%s)\n", | ||
224 | 218 | strerror(errno)); | ||
225 | 219 | return -1; | ||
226 | 220 | } | ||
227 | 221 | |||
228 | 222 | clog(LOG_DEBUG, "called with: %s\n", ev); | ||
229 | 223 | |||
230 | 224 | /* try to parse the %[a-zA-Z0-9]:%d-%d format first */ | ||
231 | 225 | if (sscanf(ev, "%32[a-zA-Z0-9]:%d-%d", battery_name, &(ret->min), &(ret->max)) == 3) { | ||
232 | 226 | /* validate battery name and assign pointer to struct battery_info */ | ||
233 | 227 | if ((ret->bat = get_battery_info(battery_name)) == NULL) { | ||
234 | 228 | clog(LOG_ERR, "non existent battery %s!\n", | ||
235 | 229 | battery_name); | ||
236 | 230 | free(ret); | ||
237 | 231 | return -1; | ||
238 | 232 | } | ||
239 | 233 | clog(LOG_INFO, "parsed %s %d-%d\n", ret->bat->cdev->name, ret->min, ret->max); | ||
240 | 234 | |||
241 | 235 | } else if (sscanf(ev, "%32[a-zA-Z0-9]:%d", battery_name, &(ret->min)) == 2) { | ||
242 | 236 | /* validate battery name and assign pointer to struct battery_info */ | ||
243 | 237 | if ((ret->bat = get_battery_info(battery_name)) == NULL) { | ||
244 | 238 | clog(LOG_ERR, "non existent battery %s!\n", | ||
245 | 239 | battery_name); | ||
246 | 240 | free(ret); | ||
247 | 241 | return -1; | ||
248 | 242 | } | ||
249 | 243 | ret->max = ret->min; | ||
250 | 244 | clog(LOG_INFO, "parsed %s %d\n", ret->bat->cdev->name, ret->min); | ||
251 | 245 | |||
252 | 246 | } else if (sscanf(ev, "%d-%d", &(ret->min), &(ret->max)) == 2) { | ||
253 | 247 | clog(LOG_INFO, "parsed %d-%d\n", ret->min, ret->max); | ||
254 | 248 | |||
255 | 249 | } else if (sscanf(ev, "%d", &(ret->min)) == 1) { | ||
256 | 250 | ret->max = ret->min; | ||
257 | 251 | clog(LOG_INFO, "parsed %d\n", ret->min); | ||
258 | 252 | |||
259 | 253 | } else { | ||
260 | 254 | free(ret); | ||
261 | 255 | return -1; | ||
262 | 256 | } | ||
263 | 257 | |||
264 | 258 | if (ret->min > ret->max) { | ||
265 | 259 | clog(LOG_ERR, "Min higher than Max?\n"); | ||
266 | 260 | free(ret); | ||
267 | 261 | return -1; | ||
268 | 262 | } | ||
269 | 263 | |||
270 | 264 | *obj = ret; | ||
271 | 265 | return 0; | ||
272 | 266 | } | ||
273 | 267 | |||
274 | 268 | |||
275 | 269 | int acpi_battery_evaluate(const void *s) { | ||
276 | 270 | const struct battery_interval *bi = (const struct battery_interval *)s; | ||
277 | 271 | int level = avg_battery_level; | ||
278 | 272 | |||
279 | 273 | if (bi != NULL && bi->bat != NULL) { | ||
280 | 274 | level = bi->bat->present->value ? bi->bat->level : -1; | ||
281 | 275 | } | ||
282 | 276 | |||
283 | 277 | clog(LOG_DEBUG, "called %d-%d [%s:%d]\n", bi->min, bi->max, | ||
284 | 278 | bi != NULL && bi->bat != NULL ? bi->bat->cdev->name : "Avg", level); | ||
285 | 279 | |||
286 | 280 | return (level >= bi->min && level <= bi->max) ? MATCH : DONT_MATCH; | ||
287 | 281 | } | ||
288 | 282 | |||
289 | 283 | /* static int acpi_battery_update(void) | ||
290 | 284 | * | ||
291 | 285 | * reads temperature valuse ant compute a medium value | ||
292 | 286 | */ | ||
293 | 287 | int acpi_battery_update(void) { | ||
294 | 288 | int i = 0, total_capacity = 0, total_remaining = 0, n_read = 0; | ||
295 | 289 | double elapsed_time = 0.0; | ||
296 | 290 | double current_time = 0.0; | ||
297 | 291 | #if 0 | ||
298 | 292 | int remaining_hours=0, remaining_minutes=0; | ||
299 | 293 | double remaining_secs = 0.0; | ||
300 | 294 | #endif | ||
301 | 295 | struct cpufreqd_info * cinfo = get_cpufreqd_info(); | ||
302 | 296 | |||
303 | 297 | current_time = (double)cinfo->timestamp.tv_sec + (cinfo->timestamp.tv_usec/1000000.0); | ||
304 | 298 | elapsed_time = current_time - old_time; | ||
305 | 299 | old_time = current_time; | ||
306 | 300 | /* decrement timeout */ | ||
307 | 301 | check_timeout -= elapsed_time; | ||
308 | 302 | |||
309 | 303 | /* if there is a pending event rescan batteries */ | ||
310 | 304 | if (is_event_pending()) { | ||
311 | 305 | clog(LOG_NOTICE, "Re-scanning available batteries\n"); | ||
312 | 306 | acpi_battery_exit(); | ||
313 | 307 | acpi_battery_init(); | ||
314 | 308 | /* force timeout expiration */ | ||
315 | 309 | check_timeout = -1; | ||
316 | 310 | } | ||
317 | 311 | |||
318 | 312 | /* Read battery informations */ | ||
319 | 313 | for (i = 0; i < bat_dir_num; i++) { | ||
320 | 314 | |||
321 | 315 | if (read_int(info[i].present, &info[i].is_present) != 0) { | ||
322 | 316 | clog(LOG_INFO, "Skipping %s\n", info[i].cdev->name); | ||
323 | 317 | continue; | ||
324 | 318 | } | ||
325 | 319 | |||
326 | 320 | /* if battery not open or not present skip to the next one */ | ||
327 | 321 | if (!info[i].open || !info[i].is_present || info[i].capacity <= 0) { | ||
328 | 322 | continue; | ||
329 | 323 | } | ||
330 | 324 | clog(LOG_INFO, "%s - present\n", info[i].cdev->name); | ||
331 | 325 | |||
332 | 326 | /* if check_timeout is expired */ | ||
333 | 327 | if (check_timeout <= 0) { | ||
334 | 328 | if (read_battery(&info[i]) == 0) | ||
335 | 329 | n_read++; | ||
336 | 330 | else | ||
337 | 331 | clog(LOG_INFO, "Unable to read battery %s\n", | ||
338 | 332 | info[i].cdev->name); | ||
339 | 333 | } else { | ||
340 | 334 | /* estimate battery life */ | ||
341 | 335 | clog(LOG_DEBUG, "%s - estimating battery life (timeout: %0.2f" | ||
342 | 336 | " - status: %s)\n", | ||
343 | 337 | info[i].cdev->name, check_timeout, | ||
344 | 338 | info[i].status->value); | ||
345 | 339 | |||
346 | 340 | if (strncmp(info[i].status->value, "Discharging", 11) == 0) | ||
347 | 341 | info[i].remaining -= ((float)info[i].present_rate * elapsed_time) / 3600.0; | ||
348 | 342 | |||
349 | 343 | else if (strncmp(info[i].status->value, "Full", 4) != 0 && | ||
350 | 344 | (int)info[i].remaining < info[i].capacity) | ||
351 | 345 | info[i].remaining += ((float)info[i].present_rate * elapsed_time) / 3600.0; | ||
352 | 346 | |||
353 | 347 | clog(LOG_DEBUG, "%s - remaining capacity: %d\n", | ||
354 | 348 | info[i].cdev->name, info[i].remaining); | ||
355 | 349 | } | ||
356 | 350 | n_read++; | ||
357 | 351 | total_remaining += info[i].remaining; | ||
358 | 352 | total_capacity += info[i].capacity; | ||
359 | 353 | |||
360 | 354 | info[i].level = 100 * (info[i].remaining / (double)info[i].capacity); | ||
361 | 355 | clog(LOG_INFO, "battery life for %s is %d%%\n", info[i].cdev->name, info[i].level); | ||
362 | 356 | #if 0 | ||
363 | 357 | if (info[i].present_rate > 0) { | ||
364 | 358 | remaining_secs = 3600 * info[i].remaining / info[i].present_rate; | ||
365 | 359 | remaining_hours = (int) remaining_secs / 3600; | ||
366 | 360 | remaining_minutes = (remaining_secs - (remaining_hours * 3600)) / 60; | ||
367 | 361 | clog(LOG_INFO, "battery time for %s is %d:%0.2d\n", | ||
368 | 362 | info[i].cdev->name, remaining_hours, remaining_minutes); | ||
369 | 363 | } | ||
370 | 364 | #endif | ||
371 | 365 | } /* end info loop */ | ||
372 | 366 | |||
373 | 367 | /* check_timeout is global for all batteries, so update it after all batteries got updated */ | ||
374 | 368 | if (check_timeout <= 0) { | ||
375 | 369 | check_timeout = acpi_config.battery_update_interval; | ||
376 | 370 | } | ||
377 | 371 | |||
378 | 372 | /* calculates medium battery life between all batteries */ | ||
379 | 373 | if (total_capacity > 0) | ||
380 | 374 | avg_battery_level = 100 * (total_remaining / (double)total_capacity); | ||
381 | 375 | else | ||
382 | 376 | avg_battery_level = -1; | ||
383 | 377 | |||
384 | 378 | clog(LOG_INFO, "average battery life %d%%\n", avg_battery_level); | ||
385 | 379 | |||
386 | 380 | return 0; | ||
387 | 381 | } | ||
388 | 382 | |||
389 | 383 | |||
390 | 384 | #if 0 | ||
391 | 385 | static struct cpufreqd_keyword kw[] = { | ||
392 | 386 | { .word = "battery_interval", .parse = &acpi_battery_parse, .evaluate = &acpi_battery_evaluate }, | ||
393 | 387 | { .word = NULL, .parse = NULL, .evaluate = NULL, .free = NULL } | ||
394 | 388 | }; | ||
395 | 389 | |||
396 | 390 | static struct cpufreqd_plugin acpi_battery = { | ||
397 | 391 | .plugin_name = "acpi_battery_plugin", /* plugin_name */ | ||
398 | 392 | .keywords = kw, /* config_keywords */ | ||
399 | 393 | .plugin_init = &acpi_battery_init, /* plugin_init */ | ||
400 | 394 | .plugin_exit = &acpi_battery_exit, /* plugin_exit */ | ||
401 | 395 | .plugin_update = &acpi_battery_update, /* plugin_update */ | ||
402 | 396 | }; | ||
403 | 397 | |||
404 | 398 | struct cpufreqd_plugin *create_plugin (void) { | ||
405 | 399 | return &acpi_battery; | ||
406 | 400 | } | ||
407 | 401 | #endif | ||
408 | 402 | 0 | ||
409 | === removed file '.pc/applied-patches' | |||
410 | --- .pc/applied-patches 2014-01-04 03:51:23 +0000 | |||
411 | +++ .pc/applied-patches 1970-01-01 00:00:00 +0000 | |||
412 | @@ -1,2 +0,0 @@ | |||
413 | 1 | 619913.patch | ||
414 | 2 | path_max.patch | ||
415 | 3 | 0 | ||
416 | === removed directory '.pc/path_max.patch' | |||
417 | === removed directory '.pc/path_max.patch/src' | |||
418 | === removed file '.pc/path_max.patch/src/cpufreqd.h' | |||
419 | --- .pc/path_max.patch/src/cpufreqd.h 2014-01-04 03:51:23 +0000 | |||
420 | +++ .pc/path_max.patch/src/cpufreqd.h 1970-01-01 00:00:00 +0000 | |||
421 | @@ -1,59 +0,0 @@ | |||
422 | 1 | /* | ||
423 | 2 | * Copyright (C) 2002-2008 Mattia Dongili <malattia@linux.it> | ||
424 | 3 | * George Staikos <staikos@0wned.org> | ||
425 | 4 | * | ||
426 | 5 | * This program is free software; you can redistribute it and/or modify | ||
427 | 6 | * it under the terms of the GNU General Public License as published by | ||
428 | 7 | * the Free Software Foundation; either version 2 of the License, or | ||
429 | 8 | * (at your option) any later version. | ||
430 | 9 | * | ||
431 | 10 | * This program is distributed in the hope that it will be useful, | ||
432 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
433 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
434 | 13 | * GNU General Public License for more details. | ||
435 | 14 | * | ||
436 | 15 | * You should have received a copy of the GNU General Public License | ||
437 | 16 | * along with this program; if not, write to the Free Software | ||
438 | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
439 | 18 | */ | ||
440 | 19 | |||
441 | 20 | #ifdef HAVE_CONFIG_H | ||
442 | 21 | #include "config.h" | ||
443 | 22 | #endif | ||
444 | 23 | |||
445 | 24 | #ifndef __CPUFREQD_H__ | ||
446 | 25 | #define __CPUFREQD_H__ | ||
447 | 26 | |||
448 | 27 | #define __CPUFREQD_VERSION__ VERSION | ||
449 | 28 | #define __CPUFREQD_MAINTAINER__ "malattia@linux.it" | ||
450 | 29 | |||
451 | 30 | #ifdef __GNUC__ | ||
452 | 31 | # define __UNUSED__ __attribute__((unused)) | ||
453 | 32 | #else | ||
454 | 33 | # define __UNUSED__ | ||
455 | 34 | #endif | ||
456 | 35 | |||
457 | 36 | #ifndef CPUFREQD_CONFDIR | ||
458 | 37 | # define CPUFREQD_CONFDIR "/etc/" | ||
459 | 38 | #endif | ||
460 | 39 | |||
461 | 40 | #ifndef CPUFREQD_LIBDIR | ||
462 | 41 | # define CPUFREQD_LIBDIR "/usr/lib/cpufreqd/" | ||
463 | 42 | #endif | ||
464 | 43 | |||
465 | 44 | #ifndef CPUFREQD_STATEDIR | ||
466 | 45 | # define CPUFREQD_STATEDIR "/var/" | ||
467 | 46 | #endif | ||
468 | 47 | |||
469 | 48 | #define CPUFREQD_CONFIG CPUFREQD_CONFDIR"cpufreqd.conf" | ||
470 | 49 | # define CPUFREQD_PIDFILE CPUFREQD_STATEDIR"run/cpufreqd.pid" | ||
471 | 50 | #define CPUFREQD_SOCKFILE "/tmp/cpufreqd.sock" | ||
472 | 51 | |||
473 | 52 | |||
474 | 53 | #define DEFAULT_POLL 1 | ||
475 | 54 | #define DEFAULT_VERBOSITY 3 | ||
476 | 55 | |||
477 | 56 | #define MAX_STRING_LEN 255 | ||
478 | 57 | #define MAX_PATH_LEN 512 | ||
479 | 58 | |||
480 | 59 | #endif /* __CPUFREQD_H__ */ | ||
481 | 60 | 0 | ||
482 | === modified file 'debian/changelog' | |||
483 | --- debian/changelog 2014-01-04 03:51:23 +0000 | |||
484 | +++ debian/changelog 2014-01-18 09:14:08 +0000 | |||
485 | @@ -1,3 +1,10 @@ | |||
486 | 1 | cpufreqd (2.4.2-2ubuntu1ppa) saucy; urgency=low | ||
487 | 2 | |||
488 | 3 | * Merge 2.4.2-2ubuntu1 from trusty for the buffer overflow bug. | ||
489 | 4 | - fix bug LP: #1190389 , too. | ||
490 | 5 | |||
491 | 6 | -- Li-Hao Liao (Leon Liao) <lihow731@gmail.com> Sat, 18 Jan 2014 15:16:52 +0800 | ||
492 | 7 | |||
493 | 1 | cpufreqd (2.4.2-2ubuntu1) trusty; urgency=medium | 8 | cpufreqd (2.4.2-2ubuntu1) trusty; urgency=medium |
494 | 2 | 9 | ||
495 | 3 | * path_max.patch: Pull upstream patch to fix MAX_PATH_LEN (LP: #1162160) | 10 | * path_max.patch: Pull upstream patch to fix MAX_PATH_LEN (LP: #1162160) |
496 | 4 | 11 | ||
497 | === modified file 'src/cpufreqd.h' | |||
498 | --- src/cpufreqd.h 2014-01-04 03:51:23 +0000 | |||
499 | +++ src/cpufreqd.h 2014-01-18 09:14:08 +0000 | |||
500 | @@ -54,12 +54,6 @@ | |||
501 | 54 | #define DEFAULT_VERBOSITY 3 | 54 | #define DEFAULT_VERBOSITY 3 |
502 | 55 | 55 | ||
503 | 56 | #define MAX_STRING_LEN 255 | 56 | #define MAX_STRING_LEN 255 |
511 | 57 | 57 | #define MAX_PATH_LEN 512 | |
505 | 58 | #ifdef HAVE_LIMITS_H | ||
506 | 59 | #include <limits.h> | ||
507 | 60 | #define MAX_PATH_LEN PATH_MAX | ||
508 | 61 | #else | ||
509 | 62 | #define MAX_PATH_LEN 512 | ||
510 | 63 | #endif | ||
512 | 64 | 58 | ||
513 | 65 | #endif /* __CPUFREQD_H__ */ | 59 | #endif /* __CPUFREQD_H__ */ |
514 | 66 | 60 | ||
515 | === modified file 'src/cpufreqd_acpi_battery.c' | |||
516 | --- src/cpufreqd_acpi_battery.c 2013-03-23 21:42:31 +0000 | |||
517 | +++ src/cpufreqd_acpi_battery.c 2014-01-18 09:14:08 +0000 | |||
518 | @@ -36,7 +36,6 @@ | |||
519 | 36 | #define PRESENT "present" | 36 | #define PRESENT "present" |
520 | 37 | #define STATUS "status" | 37 | #define STATUS "status" |
521 | 38 | #define CURRENT_NOW "current_now" | 38 | #define CURRENT_NOW "current_now" |
522 | 39 | #define POWER_NOW "power_now" | ||
523 | 40 | 39 | ||
524 | 41 | struct battery_info { | 40 | struct battery_info { |
525 | 42 | int capacity; | 41 | int capacity; |
526 | @@ -146,13 +145,9 @@ | |||
527 | 146 | binfo->status = get_class_device_attribute(binfo->cdev, STATUS); | 145 | binfo->status = get_class_device_attribute(binfo->cdev, STATUS); |
528 | 147 | if (!binfo->status) | 146 | if (!binfo->status) |
529 | 148 | return -1; | 147 | return -1; |
537 | 149 | binfo->current_now = get_class_device_attribute(binfo->cdev, POWER_NOW); | 148 | binfo->current_now = get_class_device_attribute(binfo->cdev, CURRENT_NOW); |
538 | 150 | if (!binfo->current_now) { | 149 | if (!binfo->current_now) |
539 | 151 | /* try the "current_now" name */ | 150 | return -1; |
533 | 152 | binfo->current_now = get_class_device_attribute(binfo->cdev, CURRENT_NOW); | ||
534 | 153 | if (!binfo->current_now) | ||
535 | 154 | return -1; | ||
536 | 155 | } | ||
540 | 156 | 151 | ||
541 | 157 | /* read the last full capacity, this is not going to change | 152 | /* read the last full capacity, this is not going to change |
542 | 158 | * very often, so no need to poke it later */ | 153 | * very often, so no need to poke it later */ |
543 | @@ -316,10 +311,6 @@ | |||
544 | 316 | 311 | ||
545 | 317 | /* Read battery informations */ | 312 | /* Read battery informations */ |
546 | 318 | for (i = 0; i < bat_dir_num; i++) { | 313 | for (i = 0; i < bat_dir_num; i++) { |
547 | 319 | if (!info[i].open) { | ||
548 | 320 | clog(LOG_INFO, "Skipping %s (closed)\n", info[i].cdev->name); | ||
549 | 321 | continue; | ||
550 | 322 | } | ||
551 | 323 | 314 | ||
552 | 324 | if (read_int(info[i].present, &info[i].is_present) != 0) { | 315 | if (read_int(info[i].present, &info[i].is_present) != 0) { |
553 | 325 | clog(LOG_INFO, "Skipping %s\n", info[i].cdev->name); | 316 | clog(LOG_INFO, "Skipping %s\n", info[i].cdev->name); |
Thanks for the patch! I am going to reject this for now because https:/ /launchpad. net/ubuntu/ +source/ cpufreqd/ 2.4.2-2ubuntu0. 1 was uploaded to saucy-proposed yesterday. Note, normally when preparing an SRU you will provide an isolated patch rather than do a merge like you.