@@ -675,43 +675,43 @@ struct devfreq *devfreq_add_device(struct device *dev,
devfreq->max_freq = devfreq->scaling_max_freq;
devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev);
atomic_set(&devfreq->suspend_count, 0);
- dev_set_name(&devfreq->dev, "devfreq%d",
- atomic_inc_return(&devfreq_no));
- err = device_add(&devfreq->dev);
- if (err) {
- mutex_unlock(&devfreq->lock);
- goto err_dev;
- }
-
devfreq->trans_table = devm_kzalloc(&devfreq->dev,
array3_size(sizeof(unsigned int),
devfreq->profile->max_state,
devfreq->profile->max_state),
GFP_KERNEL);
if (!devfreq->trans_table) {
mutex_unlock(&devfreq->lock);
err = -ENOMEM;
- goto err_devfreq;
+ goto err_dev;
}
devfreq->time_in_state = devm_kcalloc(&devfreq->dev,
devfreq->profile->max_state,
sizeof(unsigned long),
GFP_KERNEL);
if (!devfreq->time_in_state) {
mutex_unlock(&devfreq->lock);
err = -ENOMEM;
- goto err_devfreq;
+ goto err_dev;
}
devfreq->last_stat_updated = jiffies;
srcu_init_notifier_head(&devfreq->transition_notifier_list);
+ dev_set_name(&devfreq->dev, "devfreq%d",
+ atomic_inc_return(&devfreq_no));
+ err = device_add(&devfreq->dev);
+ if (err) {
+ mutex_unlock(&devfreq->lock);
+ goto err_dev;
+ }
+
mutex_unlock(&devfreq->lock);
mutex_lock(&devfreq_list_lock);
governor = try_then_request_governor(devfreq->governor_name);
@@ -737,11 +737,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
return devfreq;
err_init:
mutex_unlock(&devfreq_list_lock);
-err_devfreq:
devfreq_remove_device(devfreq);
return ERR_PTR(err);
err_dev:
put_device(&devfreq->dev);
err_out: