Loading drivers/thermal/cpu_cooling.c +29 −21 Original line number Original line Diff line number Diff line Loading @@ -64,6 +64,11 @@ static struct cpufreq_cooling_device *notify_device; * get_idr - function to get a unique id. * get_idr - function to get a unique id. * @idr: struct idr * handle used to create a id. * @idr: struct idr * handle used to create a id. * @id: int * value generated by this function. * @id: int * value generated by this function. * * This function will populate @id with an unique * id, using the idr API. * * Return: 0 on success, an error code on failure. */ */ static int get_idr(struct idr *idr, int *id) static int get_idr(struct idr *idr, int *id) { { Loading @@ -75,6 +80,7 @@ static int get_idr(struct idr *idr, int *id) if (unlikely(ret < 0)) if (unlikely(ret < 0)) return ret; return ret; *id = ret; *id = ret; return 0; return 0; } } Loading Loading @@ -105,6 +111,7 @@ static void release_idr(struct idr *idr, int id) static int is_cpufreq_valid(int cpu) static int is_cpufreq_valid(int cpu) { { struct cpufreq_policy policy; struct cpufreq_policy policy; return !cpufreq_get_policy(&policy, cpu); return !cpufreq_get_policy(&policy, cpu); } } Loading Loading @@ -134,7 +141,8 @@ enum cpufreq_cooling_property { * Return: 0 on success, -EINVAL when invalid parameters are passed. * Return: 0 on success, -EINVAL when invalid parameters are passed. */ */ static int get_property(unsigned int cpu, unsigned long input, static int get_property(unsigned int cpu, unsigned long input, unsigned int* output, enum cpufreq_cooling_property property) unsigned int *output, enum cpufreq_cooling_property property) { { int i, j; int i, j; unsigned long max_level = 0, level = 0; unsigned long max_level = 0, level = 0; Loading @@ -149,7 +157,6 @@ static int get_property(unsigned int cpu, unsigned long input, if (!table) if (!table) return -EINVAL; return -EINVAL; for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { /* ignore invalid entries */ /* ignore invalid entries */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) if (table[i].frequency == CPUFREQ_ENTRY_INVALID) Loading @@ -176,7 +183,6 @@ static int get_property(unsigned int cpu, unsigned long input, if (property == GET_FREQ) if (property == GET_FREQ) level = descend ? input : (max_level - input - 1); level = descend ? input : (max_level - input - 1); for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { /* ignore invalid entry */ /* ignore invalid entry */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) if (table[i].frequency == CPUFREQ_ENTRY_INVALID) Loading @@ -201,6 +207,7 @@ static int get_property(unsigned int cpu, unsigned long input, } } j++; j++; } } return -EINVAL; return -EINVAL; } } Loading @@ -221,6 +228,7 @@ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) return THERMAL_CSTATE_INVALID; return THERMAL_CSTATE_INVALID; return (unsigned long)val; return (unsigned long)val; } } EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); Loading @@ -245,6 +253,7 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) ret = get_property(cpu, level, &freq, GET_FREQ); ret = get_property(cpu, level, &freq, GET_FREQ); if (ret) if (ret) return 0; return 0; return freq; return freq; } } Loading Loading @@ -324,9 +333,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, return 0; return 0; } } /* /* cpufreq cooling device callback functions are defined below */ * cpufreq cooling device callback functions are defined below */ /** /** * cpufreq_get_max_state - callback function to get the max cooling state. * cpufreq_get_max_state - callback function to get the max cooling state. Loading Loading @@ -373,6 +380,7 @@ static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; *state = cpufreq_device->cpufreq_state; *state = cpufreq_device->cpufreq_state; return 0; return 0; } } Loading Loading @@ -417,8 +425,8 @@ static struct notifier_block thermal_cpufreq_notifier_block = { * Return: a valid struct thermal_cooling_device pointer on success, * Return: a valid struct thermal_cooling_device pointer on success, * on failure, it returns a corresponding ERR_PTR(). * on failure, it returns a corresponding ERR_PTR(). */ */ struct thermal_cooling_device *cpufreq_cooling_register( struct thermal_cooling_device * const struct cpumask *clip_cpus) cpufreq_cooling_register(const struct cpumask *clip_cpus) { { struct thermal_cooling_device *cool_dev; struct thermal_cooling_device *cool_dev; struct cpufreq_cooling_device *cpufreq_dev = NULL; struct cpufreq_cooling_device *cpufreq_dev = NULL; Loading Loading @@ -475,6 +483,7 @@ struct thermal_cooling_device *cpufreq_cooling_register( cpufreq_dev_count++; cpufreq_dev_count++; mutex_unlock(&cooling_cpufreq_lock); mutex_unlock(&cooling_cpufreq_lock); return cool_dev; return cool_dev; } } EXPORT_SYMBOL_GPL(cpufreq_cooling_register); EXPORT_SYMBOL_GPL(cpufreq_cooling_register); Loading @@ -496,7 +505,6 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) if (cpufreq_dev_count == 0) if (cpufreq_dev_count == 0) cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); CPUFREQ_POLICY_NOTIFIER); mutex_unlock(&cooling_cpufreq_lock); mutex_unlock(&cooling_cpufreq_lock); thermal_cooling_device_unregister(cpufreq_dev->cool_dev); thermal_cooling_device_unregister(cpufreq_dev->cool_dev); Loading include/linux/cpu_cooling.h +8 −8 Original line number Original line Diff line number Diff line Loading @@ -32,8 +32,8 @@ * cpufreq_cooling_register - function to create cpufreq cooling device. * cpufreq_cooling_register - function to create cpufreq cooling device. * @clip_cpus: cpumask of cpus where the frequency constraints will happen * @clip_cpus: cpumask of cpus where the frequency constraints will happen */ */ struct thermal_cooling_device *cpufreq_cooling_register( struct thermal_cooling_device * const struct cpumask *clip_cpus); cpufreq_cooling_register(const struct cpumask *clip_cpus); /** /** * cpufreq_cooling_unregister - function to remove cpufreq cooling device. * cpufreq_cooling_unregister - function to remove cpufreq cooling device. Loading @@ -43,18 +43,18 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int); unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int); #else /* !CONFIG_CPU_THERMAL */ #else /* !CONFIG_CPU_THERMAL */ static inline struct thermal_cooling_device *cpufreq_cooling_register( static inline struct thermal_cooling_device * const struct cpumask *clip_cpus) cpufreq_cooling_register(const struct cpumask *clip_cpus) { { return NULL; return NULL; } } static inline void cpufreq_cooling_unregister( static inline struct thermal_cooling_device *cdev) void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) { { return; return; } } static inline unsigned long cpufreq_cooling_get_level(unsigned int, static inline unsigned int) unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int) { { return THERMAL_CSTATE_INVALID; return THERMAL_CSTATE_INVALID; } } Loading Loading
drivers/thermal/cpu_cooling.c +29 −21 Original line number Original line Diff line number Diff line Loading @@ -64,6 +64,11 @@ static struct cpufreq_cooling_device *notify_device; * get_idr - function to get a unique id. * get_idr - function to get a unique id. * @idr: struct idr * handle used to create a id. * @idr: struct idr * handle used to create a id. * @id: int * value generated by this function. * @id: int * value generated by this function. * * This function will populate @id with an unique * id, using the idr API. * * Return: 0 on success, an error code on failure. */ */ static int get_idr(struct idr *idr, int *id) static int get_idr(struct idr *idr, int *id) { { Loading @@ -75,6 +80,7 @@ static int get_idr(struct idr *idr, int *id) if (unlikely(ret < 0)) if (unlikely(ret < 0)) return ret; return ret; *id = ret; *id = ret; return 0; return 0; } } Loading Loading @@ -105,6 +111,7 @@ static void release_idr(struct idr *idr, int id) static int is_cpufreq_valid(int cpu) static int is_cpufreq_valid(int cpu) { { struct cpufreq_policy policy; struct cpufreq_policy policy; return !cpufreq_get_policy(&policy, cpu); return !cpufreq_get_policy(&policy, cpu); } } Loading Loading @@ -134,7 +141,8 @@ enum cpufreq_cooling_property { * Return: 0 on success, -EINVAL when invalid parameters are passed. * Return: 0 on success, -EINVAL when invalid parameters are passed. */ */ static int get_property(unsigned int cpu, unsigned long input, static int get_property(unsigned int cpu, unsigned long input, unsigned int* output, enum cpufreq_cooling_property property) unsigned int *output, enum cpufreq_cooling_property property) { { int i, j; int i, j; unsigned long max_level = 0, level = 0; unsigned long max_level = 0, level = 0; Loading @@ -149,7 +157,6 @@ static int get_property(unsigned int cpu, unsigned long input, if (!table) if (!table) return -EINVAL; return -EINVAL; for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { /* ignore invalid entries */ /* ignore invalid entries */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) if (table[i].frequency == CPUFREQ_ENTRY_INVALID) Loading @@ -176,7 +183,6 @@ static int get_property(unsigned int cpu, unsigned long input, if (property == GET_FREQ) if (property == GET_FREQ) level = descend ? input : (max_level - input - 1); level = descend ? input : (max_level - input - 1); for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { /* ignore invalid entry */ /* ignore invalid entry */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) if (table[i].frequency == CPUFREQ_ENTRY_INVALID) Loading @@ -201,6 +207,7 @@ static int get_property(unsigned int cpu, unsigned long input, } } j++; j++; } } return -EINVAL; return -EINVAL; } } Loading @@ -221,6 +228,7 @@ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) return THERMAL_CSTATE_INVALID; return THERMAL_CSTATE_INVALID; return (unsigned long)val; return (unsigned long)val; } } EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); Loading @@ -245,6 +253,7 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) ret = get_property(cpu, level, &freq, GET_FREQ); ret = get_property(cpu, level, &freq, GET_FREQ); if (ret) if (ret) return 0; return 0; return freq; return freq; } } Loading Loading @@ -324,9 +333,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, return 0; return 0; } } /* /* cpufreq cooling device callback functions are defined below */ * cpufreq cooling device callback functions are defined below */ /** /** * cpufreq_get_max_state - callback function to get the max cooling state. * cpufreq_get_max_state - callback function to get the max cooling state. Loading Loading @@ -373,6 +380,7 @@ static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; *state = cpufreq_device->cpufreq_state; *state = cpufreq_device->cpufreq_state; return 0; return 0; } } Loading Loading @@ -417,8 +425,8 @@ static struct notifier_block thermal_cpufreq_notifier_block = { * Return: a valid struct thermal_cooling_device pointer on success, * Return: a valid struct thermal_cooling_device pointer on success, * on failure, it returns a corresponding ERR_PTR(). * on failure, it returns a corresponding ERR_PTR(). */ */ struct thermal_cooling_device *cpufreq_cooling_register( struct thermal_cooling_device * const struct cpumask *clip_cpus) cpufreq_cooling_register(const struct cpumask *clip_cpus) { { struct thermal_cooling_device *cool_dev; struct thermal_cooling_device *cool_dev; struct cpufreq_cooling_device *cpufreq_dev = NULL; struct cpufreq_cooling_device *cpufreq_dev = NULL; Loading Loading @@ -475,6 +483,7 @@ struct thermal_cooling_device *cpufreq_cooling_register( cpufreq_dev_count++; cpufreq_dev_count++; mutex_unlock(&cooling_cpufreq_lock); mutex_unlock(&cooling_cpufreq_lock); return cool_dev; return cool_dev; } } EXPORT_SYMBOL_GPL(cpufreq_cooling_register); EXPORT_SYMBOL_GPL(cpufreq_cooling_register); Loading @@ -496,7 +505,6 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) if (cpufreq_dev_count == 0) if (cpufreq_dev_count == 0) cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); CPUFREQ_POLICY_NOTIFIER); mutex_unlock(&cooling_cpufreq_lock); mutex_unlock(&cooling_cpufreq_lock); thermal_cooling_device_unregister(cpufreq_dev->cool_dev); thermal_cooling_device_unregister(cpufreq_dev->cool_dev); Loading
include/linux/cpu_cooling.h +8 −8 Original line number Original line Diff line number Diff line Loading @@ -32,8 +32,8 @@ * cpufreq_cooling_register - function to create cpufreq cooling device. * cpufreq_cooling_register - function to create cpufreq cooling device. * @clip_cpus: cpumask of cpus where the frequency constraints will happen * @clip_cpus: cpumask of cpus where the frequency constraints will happen */ */ struct thermal_cooling_device *cpufreq_cooling_register( struct thermal_cooling_device * const struct cpumask *clip_cpus); cpufreq_cooling_register(const struct cpumask *clip_cpus); /** /** * cpufreq_cooling_unregister - function to remove cpufreq cooling device. * cpufreq_cooling_unregister - function to remove cpufreq cooling device. Loading @@ -43,18 +43,18 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int); unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int); #else /* !CONFIG_CPU_THERMAL */ #else /* !CONFIG_CPU_THERMAL */ static inline struct thermal_cooling_device *cpufreq_cooling_register( static inline struct thermal_cooling_device * const struct cpumask *clip_cpus) cpufreq_cooling_register(const struct cpumask *clip_cpus) { { return NULL; return NULL; } } static inline void cpufreq_cooling_unregister( static inline struct thermal_cooling_device *cdev) void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) { { return; return; } } static inline unsigned long cpufreq_cooling_get_level(unsigned int, static inline unsigned int) unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int) { { return THERMAL_CSTATE_INVALID; return THERMAL_CSTATE_INVALID; } } Loading