On 25-06-19, 13:32, Daniel Lezcano wrote: > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index aee024e42618..f07454249fbc 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1379,8 +1379,8 @@ static int cpufreq_online(unsigned int cpu) > cpufreq_driver->ready(policy); > > if (cpufreq_thermal_control_enabled(cpufreq_driver)) > - policy->cdev = of_cpufreq_cooling_register(policy); > - > + of_cpufreq_cooling_register(policy); > + We don't need any error checking here anymore ? > pr_debug("initialization complete\n"); > > return 0; > @@ -1468,10 +1468,8 @@ static int cpufreq_offline(unsigned int cpu) > goto unlock; > } > > - if (cpufreq_thermal_control_enabled(cpufreq_driver)) { > - cpufreq_cooling_unregister(policy->cdev); > - policy->cdev = NULL; > - } > + if (cpufreq_thermal_control_enabled(cpufreq_driver)) > + cpufreq_cooling_unregister(policy); And we unregister unconditionally, even if we failed ? What if this routine prints error messages for such an case ? > > if (cpufreq_driver->stop_cpu) > cpufreq_driver->stop_cpu(policy); > diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c > index 83486775e593..007c7c6bf845 100644 > --- a/drivers/thermal/cpu_cooling.c > +++ b/drivers/thermal/cpu_cooling.c > @@ -78,6 +78,7 @@ struct cpufreq_cooling_device { > struct cpufreq_policy *policy; > struct list_head node; > struct time_in_idle *idle_time; > + struct thermal_cooling_device *cdev; > }; > > static DEFINE_IDA(cpufreq_ida); > @@ -606,6 +607,7 @@ __cpufreq_cooling_register(struct device_node *np, > goto remove_ida; > > cpufreq_cdev->clipped_freq = get_state_freq(cpufreq_cdev, 0); > + cpufreq_cdev->cdev = cdev; > > mutex_lock(&cooling_list_lock); > /* Register the notifier for first cpufreq cooling device */ > @@ -699,18 +701,18 @@ EXPORT_SYMBOL_GPL(of_cpufreq_cooling_register); > * > * This interface function unregisters the "thermal-cpufreq-%x" cooling device. > */ > -void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) > +void cpufreq_cooling_unregister(struct cpufreq_policy *policy) > { > struct cpufreq_cooling_device *cpufreq_cdev; > bool last; > > - if (!cdev) > - return; > - > - cpufreq_cdev = cdev->devdata; > - > mutex_lock(&cooling_list_lock); > - list_del(&cpufreq_cdev->node); > + list_for_each_entry(cpufreq_cdev, &cpufreq_cdev_list, node) { > + if (cpufreq_cdev->policy == policy) { > + list_del(&cpufreq_cdev->node); > + break; > + } > + } What if we reach here without a match for the policy ? We shouldn't continue and error out, right ? Print an error message as well ? -- viresh