Merge "PM / devfreq: Introduce a sysfs lock" into msm-4.14

This commit is contained in:
Linux Build Service Account 2018-04-12 14:29:10 -07:00 committed by Gerrit - the friendly Code Review server
commit f22faadc28
2 changed files with 14 additions and 1 deletions

View File

@ -522,6 +522,7 @@ static void devfreq_dev_release(struct device *dev)
devfreq->profile->exit(devfreq->dev.parent);
mutex_destroy(&devfreq->lock);
mutex_destroy(&devfreq->sysfs_lock);
kfree(devfreq);
}
@ -564,6 +565,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
}
mutex_init(&devfreq->lock);
mutex_init(&devfreq->sysfs_lock);
mutex_lock(&devfreq->lock);
devfreq->dev.parent = dev;
devfreq->dev.class = devfreq_class;
@ -962,12 +964,13 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
goto out;
}
mutex_lock(&df->sysfs_lock);
if (df->governor) {
ret = df->governor->event_handler(df, DEVFREQ_GOV_STOP, NULL);
if (ret) {
dev_warn(dev, "%s: Governor %s not stopped(%d)\n",
__func__, df->governor->name, ret);
goto out;
goto gov_stop_out;
}
}
prev_gov = df->governor;
@ -985,6 +988,9 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
NULL);
}
}
gov_stop_out:
mutex_unlock(&df->sysfs_lock);
out:
mutex_unlock(&devfreq_list_lock);
@ -1079,8 +1085,10 @@ static ssize_t polling_interval_store(struct device *dev,
if (ret != 1)
return -EINVAL;
mutex_lock(&df->sysfs_lock);
df->governor->event_handler(df, DEVFREQ_GOV_INTERVAL, &value);
ret = count;
mutex_unlock(&df->sysfs_lock);
return ret;
}
@ -1098,6 +1106,7 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
if (ret != 1)
return -EINVAL;
mutex_lock(&df->sysfs_lock);
mutex_lock(&df->lock);
max = df->max_freq;
if (value && max && value > max) {
@ -1110,6 +1119,7 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr,
ret = count;
unlock:
mutex_unlock(&df->lock);
mutex_unlock(&df->sysfs_lock);
return ret;
}
@ -1125,6 +1135,7 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
if (ret != 1)
return -EINVAL;
mutex_lock(&df->sysfs_lock);
mutex_lock(&df->lock);
min = df->min_freq;
if (value && min && value < min) {
@ -1137,6 +1148,7 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr,
ret = count;
unlock:
mutex_unlock(&df->lock);
mutex_unlock(&df->sysfs_lock);
return ret;
}

View File

@ -139,6 +139,7 @@ struct devfreq {
struct list_head node;
struct mutex lock;
struct mutex sysfs_lock;
struct device dev;
struct devfreq_dev_profile *profile;
const struct devfreq_governor *governor;