cregit-Linux how code gets into the kernel

Release 4.7 drivers/cpufreq/freq_table.c

Directory: drivers/cpufreq
/*
 * linux/drivers/cpufreq/freq_table.c
 *
 * Copyright (C) 2002 - 2003 Dominik Brodowski
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 */


#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/cpufreq.h>
#include <linux/module.h>

/*********************************************************************
 *                     FREQUENCY TABLE HELPERS                       *
 *********************************************************************/


bool policy_has_boost_freq(struct cpufreq_policy *policy) { struct cpufreq_frequency_table *pos, *table = policy->freq_table; if (!table) return false; cpufreq_for_each_valid_entry(pos, table) if (pos->flags & CPUFREQ_BOOST_FREQ) return true; return false; }

Contributors

PersonTokensPropCommitsCommitProp
viresh kumarviresh kumar50100.00%1100.00%
Total50100.00%1100.00%

EXPORT_SYMBOL_GPL(policy_has_boost_freq);
int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table) { struct cpufreq_frequency_table *pos; unsigned int min_freq = ~0; unsigned int max_freq = 0; unsigned int freq; cpufreq_for_each_valid_entry(pos, table) { freq = pos->frequency; if (!cpufreq_boost_enabled() && (pos->flags & CPUFREQ_BOOST_FREQ)) continue; pr_debug("table entry %u: %u kHz\n", (int)(pos - table), freq); if (freq < min_freq) min_freq = freq; if (freq > max_freq) max_freq = freq; } policy->min = policy->cpuinfo.min_freq = min_freq; policy->max = policy->cpuinfo.max_freq = max_freq; if (policy->min == ~0) return -EINVAL; else return 0; }

Contributors

PersonTokensPropCommitsCommitProp
dominik brodowskidominik brodowski9566.43%228.57%
stratos karafotisstratos karafotis2416.78%114.29%
dave jonesdave jones106.99%114.29%
lukasz majewskilukasz majewski96.29%114.29%
viresh kumarviresh kumar53.50%228.57%
Total143100.00%7100.00%

EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo);
int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table) { struct cpufreq_frequency_table *pos; unsigned int freq, next_larger = ~0; bool found = false; pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); cpufreq_verify_within_cpu_limits(policy); cpufreq_for_each_valid_entry(pos, table) { freq = pos->frequency; if ((freq >= policy->min) && (freq <= policy->max)) { found = true; break; } if ((next_larger > freq) && (freq > policy->max)) next_larger = freq; } if (!found) { policy->max = next_larger; cpufreq_verify_within_cpu_limits(policy); } pr_debug("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
dominik brodowskidominik brodowski8454.90%233.33%
dave jonesdave jones3220.92%116.67%
viresh kumarviresh kumar2013.07%233.33%
stratos karafotisstratos karafotis1711.11%116.67%
Total153100.00%6100.00%

EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); /* * Generic routine to verify policy & frequency table, requires driver to set * policy->freq_table prior to it. */
int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) { struct cpufreq_frequency_table *table = cpufreq_frequency_get_table(policy->cpu); if (!table) return -ENODEV; return cpufreq_frequency_table_verify(policy, table); }

Contributors

PersonTokensPropCommitsCommitProp
viresh kumarviresh kumar39100.00%1100.00%
Total39100.00%1100.00%

EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify);
int cpufreq_frequency_table_target(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table, unsigned int target_freq, unsigned int relation, unsigned int *index) { struct cpufreq_frequency_table optimal = { .driver_data = ~0, .frequency = 0, }; struct cpufreq_frequency_table suboptimal = { .driver_data = ~0, .frequency = 0, }; struct cpufreq_frequency_table *pos; unsigned int freq, diff, i = 0; pr_debug("request for target %u kHz (relation: %u) for cpu %u\n", target_freq, relation, policy->cpu); switch (relation) { case CPUFREQ_RELATION_H: suboptimal.frequency = ~0; break; case CPUFREQ_RELATION_L: case CPUFREQ_RELATION_C: optimal.frequency = ~0; break; } cpufreq_for_each_valid_entry(pos, table) { freq = pos->frequency; i = pos - table; if ((freq < policy->min) || (freq > policy->max)) continue; if (freq == target_freq) { optimal.driver_data = i; break; } switch (relation) { case CPUFREQ_RELATION_H: if (freq < target_freq) { if (freq >= optimal.frequency) { optimal.frequency = freq; optimal.driver_data = i; } } else { if (freq <= suboptimal.frequency) { suboptimal.frequency = freq; suboptimal.driver_data = i; } } break; case CPUFREQ_RELATION_L: if (freq > target_freq) { if (freq <= optimal.frequency) { optimal.frequency = freq; optimal.driver_data = i; } } else { if (freq >= suboptimal.frequency) { suboptimal.frequency = freq; suboptimal.driver_data = i; } } break; case CPUFREQ_RELATION_C: diff = abs(freq - target_freq); if (diff < optimal.frequency || (diff == optimal.frequency && freq > table[optimal.driver_data].frequency)) { optimal.frequency = diff; optimal.driver_data = i; } break; } } if (optimal.driver_data > i) { if (suboptimal.driver_data > i) return -EINVAL; *index = suboptimal.driver_data; } else *index = optimal.driver_data; pr_debug("target index is %u, freq is:%u kHz\n", *index, table[*index].frequency); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
dominik brodowskidominik brodowski26063.57%222.22%
stratos karafotisstratos karafotis10024.45%333.33%
dave jonesdave jones389.29%222.22%
viresh kumarviresh kumar112.69%222.22%
Total409100.00%9100.00%

EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);
int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, unsigned int freq) { struct cpufreq_frequency_table *pos, *table; table = cpufreq_frequency_get_table(policy->cpu); if (unlikely(!table)) { pr_debug("%s: Unable to find frequency table\n", __func__); return -ENOENT; } cpufreq_for_each_valid_entry(pos, table) if (pos->frequency == freq) return pos - table; return -EINVAL; }

Contributors

PersonTokensPropCommitsCommitProp
viresh kumarviresh kumar6181.33%150.00%
stratos karafotisstratos karafotis1418.67%150.00%
Total75100.00%2100.00%

EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_index); /** * show_available_freqs - show available frequencies for the specified CPU */
static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf, bool show_boost) { ssize_t count = 0; struct cpufreq_frequency_table *pos, *table = policy->freq_table; if (!table) return -ENODEV; cpufreq_for_each_valid_entry(pos, table) { /* * show_boost = true and driver_data = BOOST freq * display BOOST freqs * * show_boost = false and driver_data = BOOST freq * show_boost = true and driver_data != BOOST freq * continue - do not display anything * * show_boost = false and driver_data != BOOST freq * display NON BOOST freqs */ if (show_boost ^ (pos->flags & CPUFREQ_BOOST_FREQ)) continue; count += sprintf(&buf[count], "%d ", pos->frequency); } count += sprintf(&buf[count], "\n"); return count; }

Contributors

PersonTokensPropCommitsCommitProp
dave jonesdave jones6666.67%120.00%
stratos karafotisstratos karafotis1313.13%120.00%
lukasz majewskilukasz majewski1313.13%120.00%
viresh kumarviresh kumar77.07%240.00%
Total99100.00%5100.00%

#define cpufreq_attr_available_freq(_name) \ struct freq_attr cpufreq_freq_attr_##_name##_freqs = \ __ATTR_RO(_name##_frequencies) /** * show_scaling_available_frequencies - show available normal frequencies for * the specified CPU */
static ssize_t scaling_available_frequencies_show(struct cpufreq_policy *policy, char *buf) { return show_available_freqs(policy, buf, false); }

Contributors

PersonTokensPropCommitsCommitProp
lukasz majewskilukasz majewski2288.00%150.00%
dave jonesdave jones312.00%150.00%
Total25100.00%2100.00%

cpufreq_attr_available_freq(scaling_available); EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs); /** * show_available_boost_freqs - show available boost frequencies for * the specified CPU */
static ssize_t scaling_boost_frequencies_show(struct cpufreq_policy *policy, char *buf) { return show_available_freqs(policy, buf, true); }

Contributors

PersonTokensPropCommitsCommitProp
lukasz majewskilukasz majewski25100.00%1100.00%
Total25100.00%1100.00%

cpufreq_attr_available_freq(scaling_boost); EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_boost_freqs); struct freq_attr *cpufreq_generic_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, #ifdef CONFIG_CPU_FREQ_BOOST_SW &cpufreq_freq_attr_scaling_boost_freqs, #endif NULL, }; EXPORT_SYMBOL_GPL(cpufreq_generic_attr);
int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table) { int ret = cpufreq_frequency_table_cpuinfo(policy, table); if (!ret) policy->freq_table = table; return ret; }

Contributors

PersonTokensPropCommitsCommitProp
viresh kumarviresh kumar39100.00%2100.00%
Total39100.00%2100.00%

EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); MODULE_DESCRIPTION("CPUfreq frequency table helpers"); MODULE_LICENSE("GPL");

Overall Contributors

PersonTokensPropCommitsCommitProp
dominik brodowskidominik brodowski47640.34%313.04%
viresh kumarviresh kumar27923.64%1252.17%
stratos karafotisstratos karafotis16814.24%313.04%
dave jonesdave jones15413.05%313.04%
lukasz majewskilukasz majewski1028.64%14.35%
fenghua yufenghua yu10.08%14.35%
Total1180100.00%23100.00%
Directory: drivers/cpufreq
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}