Ejemplo n.º 1
0
static ssize_t store_request(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t count)
{
	struct devfreq *devfreq = to_devfreq(dev);
	struct userspace_data *data;
	int wanted;
	int req_freq;
	int err = 0;

	req_freq = 0;
	mutex_lock(&devfreq->lock);
	data = devfreq->data;
	sscanf(buf, "%d", &wanted);
	if(data){
		data->req_bw += wanted;
		pr_debug("*** %s, request:%d, total request:%d ***\n",
				__func__, wanted, data->req_bw);
		if(data->req_bw < 0)
			data->req_bw = 0;
		if(data->convert_bw_to_freq)
			req_freq = data->convert_bw_to_freq(wanted);
	}
	user_requests.req_sum += req_freq;
	if(user_requests.req_sum < 0)
		user_requests.req_sum = 0;
	err = update_devfreq(devfreq);
	if (err == 0)
		err = count;
	mutex_unlock(&devfreq->lock);
	return err;

}
Ejemplo n.º 2
0
static ssize_t show_perf(struct device *dev, struct device_attribute *attr,
		char *buf)
{
	struct devfreq *devfreq = to_devfreq(dev);
	struct userspace_data *data;
	int err = 0;

	mutex_lock(&devfreq->lock);
	data = devfreq->data;
	if(data)
		err = sprintf(buf, "%lu KHz \n", data->set_freq);
	mutex_unlock(&devfreq->lock);
	return err;
}
Ejemplo n.º 3
0
static ssize_t store_enable(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t count)
{
	struct devfreq *devfreq = to_devfreq(dev);
	struct userspace_data *data;
	unsigned long wanted;

	mutex_lock(&devfreq->lock);
	data = devfreq->data;
	sscanf(buf, "%lu", &wanted);
	if(data){
		data->enable = wanted;
	}
	mutex_unlock(&devfreq->lock);
	return count;
}
Ejemplo n.º 4
0
static ssize_t show_upthreshold(struct device *dev, struct device_attribute *attr,
			 char *buf)
{
	struct devfreq *devfreq = to_devfreq(dev);
	struct userspace_data *data;
	int err = 0;

	mutex_lock(&devfreq->lock);
	data = devfreq->data;
	if(data){
		err = sprintf(buf, "%lu\n", data->upthreshold);
	}else
		err = sprintf(buf, "%d\n", DFO_UPTHRESHOLD);
	mutex_unlock(&devfreq->lock);
	return err;
}
Ejemplo n.º 5
0
static ssize_t show_downdifferential(struct device *dev, struct device_attribute *attr,
			char *buf)
{
	struct devfreq *devfreq = to_devfreq(dev);
	struct userspace_data *data;
	int err = 0;

	mutex_lock(&devfreq->lock);
	data = devfreq->data;
	if(data){
		err = sprintf(buf, "%lu\n", data->downdifferential);
	}else{
		err = sprintf(buf, "%d\n", DFO_DOWNDIFFERENCTIAL);
	}
	mutex_unlock(&devfreq->lock);
	return err;
}
static ssize_t show_freq(struct device *dev, struct device_attribute *attr,
			 char *buf)
{
	struct devfreq *devfreq = to_devfreq(dev);
	struct userspace_data *data;
	int err = 0;

	mutex_lock(&devfreq->lock);
	data = devfreq->data;

	if (data->valid)
		err = sprintf(buf, "%lu\n", data->user_frequency);
	else
		err = sprintf(buf, "undefined\n");
	mutex_unlock(&devfreq->lock);
	return err;
}
Ejemplo n.º 7
0
static ssize_t store_freq(struct device *dev, struct device_attribute *attr,
			  const char *buf, size_t count)
{
	struct devfreq *devfreq = to_devfreq(dev);
	struct userspace_data *data;
	unsigned long wanted;
	int err = 0;

	mutex_lock(&devfreq->lock);
	data = devfreq->data;

	sscanf(buf, "%lu", &wanted);
	data->user_frequency = wanted;
	data->valid = true;
	err = update_devfreq(devfreq);
	if (err == 0)
		err = count;
	mutex_unlock(&devfreq->lock);
	return err;
}