diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index fb8a5279c5d8..1f93dbd72355 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -15,6 +15,8 @@ | |||
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
19 | |||
18 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
19 | #include <linux/module.h> | 21 | #include <linux/module.h> |
20 | #include <linux/init.h> | 22 | #include <linux/init.h> |
@@ -127,7 +129,7 @@ static int __init init_cpufreq_transition_notifier_list(void) | |||
127 | pure_initcall(init_cpufreq_transition_notifier_list); | 129 | pure_initcall(init_cpufreq_transition_notifier_list); |
128 | 130 | ||
129 | static int off __read_mostly; | 131 | static int off __read_mostly; |
130 | int cpufreq_disabled(void) | 132 | static int cpufreq_disabled(void) |
131 | { | 133 | { |
132 | return off; | 134 | return off; |
133 | } | 135 | } |
@@ -402,7 +404,7 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, | |||
402 | static ssize_t store_##file_name \ | 404 | static ssize_t store_##file_name \ |
403 | (struct cpufreq_policy *policy, const char *buf, size_t count) \ | 405 | (struct cpufreq_policy *policy, const char *buf, size_t count) \ |
404 | { \ | 406 | { \ |
405 | unsigned int ret = -EINVAL; \ | 407 | unsigned int ret; \ |
406 | struct cpufreq_policy new_policy; \ | 408 | struct cpufreq_policy new_policy; \ |
407 | \ | 409 | \ |
408 | ret = cpufreq_get_policy(&new_policy, policy->cpu); \ | 410 | ret = cpufreq_get_policy(&new_policy, policy->cpu); \ |
@@ -445,7 +447,7 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf) | |||
445 | else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) | 447 | else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) |
446 | return sprintf(buf, "performance\n"); | 448 | return sprintf(buf, "performance\n"); |
447 | else if (policy->governor) | 449 | else if (policy->governor) |
448 | return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", | 450 | return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", |
449 | policy->governor->name); | 451 | policy->governor->name); |
450 | return -EINVAL; | 452 | return -EINVAL; |
451 | } | 453 | } |
@@ -457,7 +459,7 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf) | |||
457 | static ssize_t store_scaling_governor(struct cpufreq_policy *policy, | 459 | static ssize_t store_scaling_governor(struct cpufreq_policy *policy, |
458 | const char *buf, size_t count) | 460 | const char *buf, size_t count) |
459 | { | 461 | { |
460 | unsigned int ret = -EINVAL; | 462 | unsigned int ret; |
461 | char str_governor[16]; | 463 | char str_governor[16]; |
462 | struct cpufreq_policy new_policy; | 464 | struct cpufreq_policy new_policy; |
463 | 465 | ||
@@ -491,7 +493,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy, | |||
491 | */ | 493 | */ |
492 | static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf) | 494 | static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf) |
493 | { | 495 | { |
494 | return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", cpufreq_driver->name); | 496 | return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", cpufreq_driver->name); |
495 | } | 497 | } |
496 | 498 | ||
497 | /** | 499 | /** |
@@ -512,7 +514,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, | |||
512 | if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) | 514 | if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) |
513 | - (CPUFREQ_NAME_LEN + 2))) | 515 | - (CPUFREQ_NAME_LEN + 2))) |
514 | goto out; | 516 | goto out; |
515 | i += scnprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name); | 517 | i += scnprintf(&buf[i], CPUFREQ_NAME_PLEN, "%s ", t->name); |
516 | } | 518 | } |
517 | out: | 519 | out: |
518 | i += sprintf(&buf[i], "\n"); | 520 | i += sprintf(&buf[i], "\n"); |
@@ -581,7 +583,7 @@ static ssize_t show_scaling_setspeed(struct cpufreq_policy *policy, char *buf) | |||
581 | } | 583 | } |
582 | 584 | ||
583 | /** | 585 | /** |
584 | * show_scaling_driver - show the current cpufreq HW/BIOS limitation | 586 | * show_bios_limit - show the current cpufreq HW/BIOS limitation |
585 | */ | 587 | */ |
586 | static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf) | 588 | static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf) |
587 | { | 589 | { |
@@ -1468,12 +1470,23 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1468 | unsigned int relation) | 1470 | unsigned int relation) |
1469 | { | 1471 | { |
1470 | int retval = -EINVAL; | 1472 | int retval = -EINVAL; |
1473 | unsigned int old_target_freq = target_freq; | ||
1471 | 1474 | ||
1472 | if (cpufreq_disabled()) | 1475 | if (cpufreq_disabled()) |
1473 | return -ENODEV; | 1476 | return -ENODEV; |
1474 | 1477 | ||
1475 | pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, | 1478 | /* Make sure that target_freq is within supported range */ |
1476 | target_freq, relation); | 1479 | if (target_freq > policy->max) |
1480 | target_freq = policy->max; | ||
1481 | if (target_freq < policy->min) | ||
1482 | target_freq = policy->min; | ||
1483 | |||
1484 | pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", | ||
1485 | policy->cpu, target_freq, relation, old_target_freq); | ||
1486 | |||
1487 | if (target_freq == policy->cur) | ||
1488 | return 0; | ||
1489 | |||
1477 | if (cpu_online(policy->cpu) && cpufreq_driver->target) | 1490 | if (cpu_online(policy->cpu) && cpufreq_driver->target) |
1478 | retval = cpufreq_driver->target(policy, target_freq, relation); | 1491 | retval = cpufreq_driver->target(policy, target_freq, relation); |
1479 | 1492 | ||
@@ -1509,12 +1522,14 @@ int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu) | |||
1509 | { | 1522 | { |
1510 | int ret = 0; | 1523 | int ret = 0; |
1511 | 1524 | ||
1525 | if (!(cpu_online(cpu) && cpufreq_driver->getavg)) | ||
1526 | return 0; | ||
1527 | |||
1512 | policy = cpufreq_cpu_get(policy->cpu); | 1528 | policy = cpufreq_cpu_get(policy->cpu); |
1513 | if (!policy) | 1529 | if (!policy) |
1514 | return -EINVAL; | 1530 | return -EINVAL; |
1515 | 1531 | ||
1516 | if (cpu_online(cpu) && cpufreq_driver->getavg) | 1532 | ret = cpufreq_driver->getavg(policy, cpu); |
1517 | ret = cpufreq_driver->getavg(policy, cpu); | ||
1518 | 1533 | ||
1519 | cpufreq_cpu_put(policy); | 1534 | cpufreq_cpu_put(policy); |
1520 | return ret; | 1535 | return ret; |