Commit 299a2298 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

PM: QoS: Clean up misc device file operations



Reorder the code to avoid using extra function header declarations
for the pm_qos_power_*() family of functions and drop those
declarations.

Also clean up the internals of those functions to consolidate checks,
avoid using redundant local variables and similar.

No intentional functional impact.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Reviewed-by: default avatarAmit Kucheria <amit.kucheria@linaro.org>
Tested-by: default avatarAmit Kucheria <amit.kucheria@linaro.org>
parent 63cffc05
Loading
Loading
Loading
Loading
+26 −36
Original line number Diff line number Diff line
@@ -83,21 +83,6 @@ static struct pm_qos_object *pm_qos_array[] = {
	&cpu_dma_pm_qos,
};

static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
		size_t count, loff_t *f_pos);
static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,
		size_t count, loff_t *f_pos);
static int pm_qos_power_open(struct inode *inode, struct file *filp);
static int pm_qos_power_release(struct inode *inode, struct file *filp);

static const struct file_operations pm_qos_power_fops = {
	.write = pm_qos_power_write,
	.read = pm_qos_power_read,
	.open = pm_qos_power_open,
	.release = pm_qos_power_release,
	.llseek = noop_llseek,
};

/**
 * pm_qos_read_value - Return the current effective constraint value.
 * @c: List of PM QoS constraint requests.
@@ -414,15 +399,6 @@ EXPORT_SYMBOL_GPL(pm_qos_remove_notifier);

/* User space interface to global PM QoS via misc device. */

static int register_pm_qos_misc(struct pm_qos_object *qos)
{
	qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR;
	qos->pm_qos_power_miscdev.name = qos->name;
	qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops;

	return misc_register(&qos->pm_qos_power_miscdev);
}

static int pm_qos_power_open(struct inode *inode, struct file *filp)
{
	struct pm_qos_request *req;
@@ -439,9 +415,10 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)

static int pm_qos_power_release(struct inode *inode, struct file *filp)
{
	struct pm_qos_request *req;
	struct pm_qos_request *req = filp->private_data;

	filp->private_data = NULL;

	req = filp->private_data;
	pm_qos_remove_request(req);
	kfree(req);

@@ -451,13 +428,11 @@ static int pm_qos_power_release(struct inode *inode, struct file *filp)
static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,
				 size_t count, loff_t *f_pos)
{
	s32 value;
	unsigned long flags;
	struct pm_qos_request *req = filp->private_data;
	unsigned long flags;
	s32 value;

	if (!req)
		return -EINVAL;
	if (!pm_qos_request_active(req))
	if (!req || !pm_qos_request_active(req))
		return -EINVAL;

	spin_lock_irqsave(&pm_qos_lock, flags);
@@ -471,7 +446,6 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
				  size_t count, loff_t *f_pos)
{
	s32 value;
	struct pm_qos_request *req;

	if (count == sizeof(s32)) {
		if (copy_from_user(&value, buf, sizeof(s32)))
@@ -484,12 +458,28 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
			return ret;
	}

	req = filp->private_data;
	pm_qos_update_request(req, value);
	pm_qos_update_request(filp->private_data, value);

	return count;
}

static const struct file_operations pm_qos_power_fops = {
	.write = pm_qos_power_write,
	.read = pm_qos_power_read,
	.open = pm_qos_power_open,
	.release = pm_qos_power_release,
	.llseek = noop_llseek,
};

static int register_pm_qos_misc(struct pm_qos_object *qos)
{
	qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR;
	qos->pm_qos_power_miscdev.name = qos->name;
	qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops;

	return misc_register(&qos->pm_qos_power_miscdev);
}

static int __init pm_qos_power_init(void)
{
	int ret;