cregit-Linux how code gets into the kernel

Release 4.11 drivers/cpufreq/cpufreq_userspace.c

Directory: drivers/cpufreq
/*
 *  linux/drivers/cpufreq/cpufreq_userspace.c
 *
 *  Copyright (C)  2001 Russell King
 *            (C)  2002 - 2004 Dominik Brodowski <linux@brodo.de>
 *
 * 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/init.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/slab.h>

static DEFINE_PER_CPU(unsigned int, cpu_is_managed);
static DEFINE_MUTEX(userspace_mutex);

/**
 * cpufreq_set - set the CPU frequency
 * @policy: pointer to policy struct where freq is being set
 * @freq: target frequency in kHz
 *
 * Sets the CPU frequency to freq.
 */

static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) { int ret = -EINVAL; unsigned int *setspeed = policy->governor_data; pr_debug("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); mutex_lock(&userspace_mutex); if (!per_cpu(cpu_is_managed, policy->cpu)) goto err; *setspeed = freq; ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L); err: mutex_unlock(&userspace_mutex); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Jones4550.56%112.50%
Sai Gurrappadi1415.73%112.50%
Thomas Renninger910.11%112.50%
Dominik Brodowski910.11%225.00%
Andrew Morton44.49%112.50%
Venkatesh Pallipadi44.49%112.50%
Mike Travis44.49%112.50%
Total89100.00%8100.00%


static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) { return sprintf(buf, "%u\n", policy->cur); }

Contributors

PersonTokensPropCommitsCommitProp
Dominik Brodowski2281.48%133.33%
Dave Jones414.81%133.33%
Viresh Kumar13.70%133.33%
Total27100.00%3100.00%


static int cpufreq_userspace_policy_init(struct cpufreq_policy *policy) { unsigned int *setspeed; setspeed = kzalloc(sizeof(*setspeed), GFP_KERNEL); if (!setspeed) return -ENOMEM; policy->governor_data = setspeed; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Sai Gurrappadi47100.00%1100.00%
Total47100.00%1100.00%


static void cpufreq_userspace_policy_exit(struct cpufreq_policy *policy) { mutex_lock(&userspace_mutex); kfree(policy->governor_data); policy->governor_data = NULL; mutex_unlock(&userspace_mutex); }

Contributors

PersonTokensPropCommitsCommitProp
Sai Gurrappadi1850.00%133.33%
Rafael J. Wysocki1027.78%133.33%
Dominik Brodowski822.22%133.33%
Total36100.00%3100.00%


static int cpufreq_userspace_policy_start(struct cpufreq_policy *policy) { unsigned int *setspeed = policy->governor_data; BUG_ON(!policy->cur); pr_debug("started managing cpu %u\n", policy->cpu); mutex_lock(&userspace_mutex); per_cpu(cpu_is_managed, policy->cpu) = 1; *setspeed = policy->cur; mutex_unlock(&userspace_mutex); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Rafael J. Wysocki2738.57%112.50%
Dominik Brodowski1217.14%112.50%
Dave Jones811.43%112.50%
Sai Gurrappadi710.00%112.50%
Viresh Kumar68.57%112.50%
Venkatesh Pallipadi45.71%112.50%
Mike Travis45.71%112.50%
Andrew Morton22.86%112.50%
Total70100.00%8100.00%


static void cpufreq_userspace_policy_stop(struct cpufreq_policy *policy) { unsigned int *setspeed = policy->governor_data; pr_debug("managing cpu %u stopped\n", policy->cpu); mutex_lock(&userspace_mutex); per_cpu(cpu_is_managed, policy->cpu) = 0; *setspeed = 0; mutex_unlock(&userspace_mutex); }

Contributors

PersonTokensPropCommitsCommitProp
Rafael J. Wysocki2442.11%114.29%
Mike Travis915.79%114.29%
Dominik Brodowski712.28%114.29%
Viresh Kumar610.53%114.29%
Sai Gurrappadi58.77%114.29%
Dave Jones47.02%114.29%
Andrew Morton23.51%114.29%
Total57100.00%7100.00%


static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy) { unsigned int *setspeed = policy->governor_data; mutex_lock(&userspace_mutex); pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n", policy->cpu, policy->min, policy->max, policy->cur, *setspeed); if (policy->max < *setspeed) __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); else if (policy->min > *setspeed) __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); else __cpufreq_driver_target(policy, *setspeed, CPUFREQ_RELATION_L); mutex_unlock(&userspace_mutex); }

Contributors

PersonTokensPropCommitsCommitProp
Dominik Brodowski4238.89%218.18%
Rafael J. Wysocki2119.44%19.09%
Sai Gurrappadi1917.59%19.09%
Thomas Renninger87.41%19.09%
Dave Jones76.48%327.27%
Viresh Kumar54.63%19.09%
Andrew Morton43.70%19.09%
Mike Travis21.85%19.09%
Total108100.00%11100.00%

static struct cpufreq_governor cpufreq_gov_userspace = { .name = "userspace", .init = cpufreq_userspace_policy_init, .exit = cpufreq_userspace_policy_exit, .start = cpufreq_userspace_policy_start, .stop = cpufreq_userspace_policy_stop, .limits = cpufreq_userspace_policy_limits, .store_setspeed = cpufreq_set, .show_setspeed = show_speed, .owner = THIS_MODULE, };
static int __init cpufreq_gov_userspace_init(void) { return cpufreq_register_governor(&cpufreq_gov_userspace); }

Contributors

PersonTokensPropCommitsCommitProp
Dominik Brodowski1487.50%150.00%
Dave Jones212.50%150.00%
Total16100.00%2100.00%


static void __exit cpufreq_gov_userspace_exit(void) { cpufreq_unregister_governor(&cpufreq_gov_userspace); }

Contributors

PersonTokensPropCommitsCommitProp
Dominik Brodowski15100.00%1100.00%
Total15100.00%1100.00%

MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, " "Russell King <rmk@arm.linux.org.uk>"); MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'"); MODULE_LICENSE("GPL"); #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE
struct cpufreq_governor *cpufreq_default_governor(void) { return &cpufreq_gov_userspace; }

Contributors

PersonTokensPropCommitsCommitProp
Rafael J. Wysocki13100.00%1100.00%
Total13100.00%1100.00%

fs_initcall(cpufreq_gov_userspace_init); #else module_init(cpufreq_gov_userspace_init); #endif module_exit(cpufreq_gov_userspace_exit);

Overall Contributors

PersonTokensPropCommitsCommitProp
Dominik Brodowski17929.54%28.70%
Rafael J. Wysocki11819.47%28.70%
Sai Gurrappadi11318.65%14.35%
Dave Jones8013.20%1043.48%
Viresh Kumar274.46%28.70%
Mike Travis264.29%14.35%
Venkatesh Pallipadi193.14%28.70%
Thomas Renninger172.81%14.35%
Andrew Morton152.48%14.35%
Johannes Weiner121.98%14.35%
Total606100.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.
Created with cregit.