.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de> |
---|
3 | | - * |
---|
4 | | - * Licensed under the terms of the GNU GPL License version 2. |
---|
5 | 4 | */ |
---|
6 | 5 | |
---|
7 | 6 | |
---|
.. | .. |
---|
286 | 285 | } else { |
---|
287 | 286 | first = malloc(sizeof(*first)); |
---|
288 | 287 | if (!first) |
---|
289 | | - goto error_out; |
---|
| 288 | + return NULL; |
---|
290 | 289 | current = first; |
---|
291 | 290 | } |
---|
292 | 291 | current->first = first; |
---|
.. | .. |
---|
344 | 343 | unsigned int len; |
---|
345 | 344 | |
---|
346 | 345 | len = sysfs_cpufreq_read_file(cpu, "scaling_available_frequencies", |
---|
347 | | - linebuf, sizeof(linebuf)); |
---|
| 346 | + linebuf, sizeof(linebuf)); |
---|
348 | 347 | if (len == 0) |
---|
349 | 348 | return NULL; |
---|
350 | 349 | |
---|
.. | .. |
---|
363 | 362 | } else { |
---|
364 | 363 | first = malloc(sizeof(*first)); |
---|
365 | 364 | if (!first) |
---|
366 | | - goto error_out; |
---|
| 365 | + return NULL; |
---|
367 | 366 | current = first; |
---|
368 | 367 | } |
---|
369 | 368 | current->first = first; |
---|
.. | .. |
---|
389 | 388 | return NULL; |
---|
390 | 389 | } |
---|
391 | 390 | |
---|
392 | | -void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies |
---|
393 | | - *any) { |
---|
| 391 | +struct cpufreq_available_frequencies |
---|
| 392 | +*cpufreq_get_boost_frequencies(unsigned int cpu) |
---|
| 393 | +{ |
---|
| 394 | + struct cpufreq_available_frequencies *first = NULL; |
---|
| 395 | + struct cpufreq_available_frequencies *current = NULL; |
---|
| 396 | + char one_value[SYSFS_PATH_MAX]; |
---|
| 397 | + char linebuf[MAX_LINE_LEN]; |
---|
| 398 | + unsigned int pos, i; |
---|
| 399 | + unsigned int len; |
---|
| 400 | + |
---|
| 401 | + len = sysfs_cpufreq_read_file(cpu, "scaling_boost_frequencies", |
---|
| 402 | + linebuf, sizeof(linebuf)); |
---|
| 403 | + if (len == 0) |
---|
| 404 | + return NULL; |
---|
| 405 | + |
---|
| 406 | + pos = 0; |
---|
| 407 | + for (i = 0; i < len; i++) { |
---|
| 408 | + if (linebuf[i] == ' ' || linebuf[i] == '\n') { |
---|
| 409 | + if (i - pos < 2) |
---|
| 410 | + continue; |
---|
| 411 | + if (i - pos >= SYSFS_PATH_MAX) |
---|
| 412 | + goto error_out; |
---|
| 413 | + if (current) { |
---|
| 414 | + current->next = malloc(sizeof(*current)); |
---|
| 415 | + if (!current->next) |
---|
| 416 | + goto error_out; |
---|
| 417 | + current = current->next; |
---|
| 418 | + } else { |
---|
| 419 | + first = malloc(sizeof(*first)); |
---|
| 420 | + if (!first) |
---|
| 421 | + return NULL; |
---|
| 422 | + current = first; |
---|
| 423 | + } |
---|
| 424 | + current->first = first; |
---|
| 425 | + current->next = NULL; |
---|
| 426 | + |
---|
| 427 | + memcpy(one_value, linebuf + pos, i - pos); |
---|
| 428 | + one_value[i - pos] = '\0'; |
---|
| 429 | + if (sscanf(one_value, "%lu", ¤t->frequency) != 1) |
---|
| 430 | + goto error_out; |
---|
| 431 | + |
---|
| 432 | + pos = i + 1; |
---|
| 433 | + } |
---|
| 434 | + } |
---|
| 435 | + |
---|
| 436 | + return first; |
---|
| 437 | + |
---|
| 438 | + error_out: |
---|
| 439 | + while (first) { |
---|
| 440 | + current = first->next; |
---|
| 441 | + free(first); |
---|
| 442 | + first = current; |
---|
| 443 | + } |
---|
| 444 | + return NULL; |
---|
| 445 | +} |
---|
| 446 | + |
---|
| 447 | +void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies *any) |
---|
| 448 | +{ |
---|
394 | 449 | struct cpufreq_available_frequencies *tmp, *next; |
---|
395 | 450 | |
---|
396 | 451 | if (!any) |
---|
.. | .. |
---|
402 | 457 | free(tmp); |
---|
403 | 458 | tmp = next; |
---|
404 | 459 | } |
---|
| 460 | +} |
---|
| 461 | + |
---|
| 462 | +void cpufreq_put_boost_frequencies(struct cpufreq_available_frequencies *any) |
---|
| 463 | +{ |
---|
| 464 | + cpufreq_put_available_frequencies(any); |
---|
405 | 465 | } |
---|
406 | 466 | |
---|
407 | 467 | static struct cpufreq_affected_cpus *sysfs_get_cpu_list(unsigned int cpu, |
---|
.. | .. |
---|
433 | 493 | } else { |
---|
434 | 494 | first = malloc(sizeof(*first)); |
---|
435 | 495 | if (!first) |
---|
436 | | - goto error_out; |
---|
| 496 | + return NULL; |
---|
437 | 497 | current = first; |
---|
438 | 498 | } |
---|
439 | 499 | current->first = first; |
---|
.. | .. |
---|
666 | 726 | } else { |
---|
667 | 727 | first = malloc(sizeof(*first)); |
---|
668 | 728 | if (!first) |
---|
669 | | - goto error_out; |
---|
| 729 | + return NULL; |
---|
670 | 730 | current = first; |
---|
671 | 731 | } |
---|
672 | 732 | current->first = first; |
---|