···6464 * get_idr - function to get a unique id.6565 * @idr: struct idr * handle used to create a id.6666 * @id: int * value generated by this function.6767+ *6868+ * This function will populate @id with an unique6969+ * id, using the idr API.7070+ *7171+ * Return: 0 on success, an error code on failure.6772 */6873static int get_idr(struct idr *idr, int *id)6974{···8075 if (unlikely(ret < 0))8176 return ret;8277 *id = ret;7878+8379 return 0;8480}8581···111105static int is_cpufreq_valid(int cpu)112106{113107 struct cpufreq_policy policy;108108+114109 return !cpufreq_get_policy(&policy, cpu);115110}116111···141134 * Return: 0 on success, -EINVAL when invalid parameters are passed.142135 */143136static int get_property(unsigned int cpu, unsigned long input,144144- unsigned int* output, enum cpufreq_cooling_property property)137137+ unsigned int *output,138138+ enum cpufreq_cooling_property property)145139{146140 int i, j;147141 unsigned long max_level = 0, level = 0;···150142 int descend = -1;151143 struct cpufreq_frequency_table *table =152144 cpufreq_frequency_get_table(cpu);153153-145145+154146 if (!output)155147 return -EINVAL;156148157149 if (!table)158150 return -EINVAL;159151160160-161152 for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {162153 /* ignore invalid entries */163154 if (table[i].frequency == CPUFREQ_ENTRY_INVALID)···181174 }182175183176 if (property == GET_FREQ)184184- level = descend ? input : (max_level - input -1);185185-177177+ level = descend ? input : (max_level - input - 1);186178187179 for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {188180 /* ignore invalid entry */···207201 }208202 j++;209203 }204204+210205 return -EINVAL;211206}212207···228221229222 if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL))230223 return THERMAL_CSTATE_INVALID;224224+231225 return (unsigned long)val;232226}233227EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level);···253245 ret = get_property(cpu, level, &freq, GET_FREQ);254246 if (ret)255247 return 0;248248+256249 return freq;257250}258251···270261 * cooling state).271262 */272263static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device,273273- unsigned long cooling_state)264264+ unsigned long cooling_state)274265{275266 unsigned int cpuid, clip_freq;276267 struct cpumask *mask = &cpufreq_device->allowed_cpus;···312303 * Return: 0 (success)313304 */314305static int cpufreq_thermal_notifier(struct notifier_block *nb,315315- unsigned long event, void *data)306306+ unsigned long event, void *data)316307{317308 struct cpufreq_policy *policy = data;318309 unsigned long max_freq = 0;···323314 if (cpumask_test_cpu(policy->cpu, ¬ify_device->allowed_cpus))324315 max_freq = notify_device->cpufreq_val;325316326326- /* Never exceed user_policy.max*/317317+ /* Never exceed user_policy.max */327318 if (max_freq > policy->user_policy.max)328319 max_freq = policy->user_policy.max;329320···333324 return 0;334325}335326336336-/*337337- * cpufreq cooling device callback functions are defined below338338- */327327+/* cpufreq cooling device callback functions are defined below */339328340329/**341330 * cpufreq_get_max_state - callback function to get the max cooling state.···380373 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;381374382375 *state = cpufreq_device->cpufreq_state;376376+383377 return 0;384378}385379···425417 * Return: a valid struct thermal_cooling_device pointer on success,426418 * on failure, it returns a corresponding ERR_PTR().427419 */428428-struct thermal_cooling_device *cpufreq_cooling_register(429429- const struct cpumask *clip_cpus)420420+struct thermal_cooling_device *421421+cpufreq_cooling_register(const struct cpumask *clip_cpus)430422{431423 struct thermal_cooling_device *cool_dev;432424 struct cpufreq_cooling_device *cpufreq_dev = NULL;···435427 int ret = 0, i;436428 struct cpufreq_policy policy;437429438438- /*Verify that all the clip cpus have same freq_min, freq_max limit*/430430+ /* Verify that all the clip cpus have same freq_min, freq_max limit */439431 for_each_cpu(i, clip_cpus) {440440- /*continue if cpufreq policy not found and not return error*/432432+ /* continue if cpufreq policy not found and not return error */441433 if (!cpufreq_get_policy(&policy, i))442434 continue;443435 if (min == 0 && max == 0) {···445437 max = policy.cpuinfo.max_freq;446438 } else {447439 if (min != policy.cpuinfo.min_freq ||448448- max != policy.cpuinfo.max_freq)440440+ max != policy.cpuinfo.max_freq)449441 return ERR_PTR(-EINVAL);450442 }451443 }452444 cpufreq_dev = kzalloc(sizeof(struct cpufreq_cooling_device),453453- GFP_KERNEL);445445+ GFP_KERNEL);454446 if (!cpufreq_dev)455447 return ERR_PTR(-ENOMEM);456448···466458 cpufreq_dev->id);467459468460 cool_dev = thermal_cooling_device_register(dev_name, cpufreq_dev,469469- &cpufreq_cooling_ops);461461+ &cpufreq_cooling_ops);470462 if (!cool_dev) {471463 release_idr(&cpufreq_idr, cpufreq_dev->id);472464 kfree(cpufreq_dev);···479471 /* Register the notifier for first cpufreq cooling device */480472 if (cpufreq_dev_count == 0)481473 cpufreq_register_notifier(&thermal_cpufreq_notifier_block,482482- CPUFREQ_POLICY_NOTIFIER);474474+ CPUFREQ_POLICY_NOTIFIER);483475 cpufreq_dev_count++;484476485477 mutex_unlock(&cooling_cpufreq_lock);478478+486479 return cool_dev;487480}488481EXPORT_SYMBOL_GPL(cpufreq_cooling_register);···504495 /* Unregister the notifier for the last cpufreq cooling device */505496 if (cpufreq_dev_count == 0)506497 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block,507507- CPUFREQ_POLICY_NOTIFIER);508508-498498+ CPUFREQ_POLICY_NOTIFIER);509499 mutex_unlock(&cooling_cpufreq_lock);510500511501 thermal_cooling_device_unregister(cpufreq_dev->cool_dev);
+8-8
include/linux/cpu_cooling.h
···3232 * cpufreq_cooling_register - function to create cpufreq cooling device.3333 * @clip_cpus: cpumask of cpus where the frequency constraints will happen3434 */3535-struct thermal_cooling_device *cpufreq_cooling_register(3636- const struct cpumask *clip_cpus);3535+struct thermal_cooling_device *3636+cpufreq_cooling_register(const struct cpumask *clip_cpus);37373838/**3939 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.···43434444unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int);4545#else /* !CONFIG_CPU_THERMAL */4646-static inline struct thermal_cooling_device *cpufreq_cooling_register(4747- const struct cpumask *clip_cpus)4646+static inline struct thermal_cooling_device *4747+cpufreq_cooling_register(const struct cpumask *clip_cpus)4848{4949 return NULL;5050}5151-static inline void cpufreq_cooling_unregister(5252- struct thermal_cooling_device *cdev)5151+static inline5252+void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)5353{5454 return;5555}5656-static inline unsigned long cpufreq_cooling_get_level(unsigned int,5757- unsigned int)5656+static inline5757+unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int)5858{5959 return THERMAL_CSTATE_INVALID;6060}