Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cda90f7c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "PM / devfreq: Introduce a sysfs lock"

parents a3f86ede 5a2f4ce3
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -520,6 +520,7 @@ static void _remove_devfreq(struct devfreq *devfreq)
		devfreq->profile->exit(devfreq->dev.parent);

	mutex_destroy(&devfreq->lock);
	mutex_destroy(&devfreq->sysfs_lock);
	kfree(devfreq);
}

@@ -576,6 +577,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;
@@ -972,12 +974,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;
@@ -995,6 +998,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);

@@ -1089,8 +1095,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;
}
@@ -1108,6 +1116,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) {
@@ -1120,6 +1129,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;
}

@@ -1135,6 +1145,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) {
@@ -1147,6 +1158,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;
}

+1 −0
Original line number Diff line number Diff line
@@ -167,6 +167,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;