summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorIan Abbott2013-01-08 14:27:48 +0100
committerGreg Kroah-Hartman2013-01-18 01:49:25 +0100
commitba1bcf6f23e192e88b7c07d20d6221a0bcb7929e (patch)
tree21a48a02d281a96c93ceadcff895dc620701c10a /drivers/staging/comedi/comedi_fops.c
parentstaging: tidspbridge: remove unused code to handle iva_img (diff)
downloadkernel-qcow2-linux-ba1bcf6f23e192e88b7c07d20d6221a0bcb7929e.tar.gz
kernel-qcow2-linux-ba1bcf6f23e192e88b7c07d20d6221a0bcb7929e.tar.xz
kernel-qcow2-linux-ba1bcf6f23e192e88b7c07d20d6221a0bcb7929e.zip
staging: comedi: (core): add comedi_dev_from_file_info()
Setting `info = comedi_file_info_from_minor(minor)` and `dev = comedi_dev_from_minor(minor)` in the same function is a bit of a waste. The latter function is just a call of the former followed by a conditional return of an embedded pointer (`info->device`) or NULL. The former function uses a spin-lock which is where the wastfulness comes in. Move the "followed by a conditional return of an embedded pointer" part into a new function `comedi_dev_from_file_info` and call this instead of `comedi_dev_from_minor()` in the places where `comedi_file_info_from_minor()` is also called. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedi_fops.c')
-rw-r--r--drivers/staging/comedi/comedi_fops.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index cd2c7d40d4db..7d1e1d5db607 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -103,14 +103,16 @@ static struct comedi_file_info *comedi_file_info_from_minor(unsigned minor)
return info;
}
-struct comedi_device *comedi_dev_from_minor(unsigned minor)
+static struct comedi_device *
+comedi_dev_from_file_info(struct comedi_file_info *info)
{
- struct comedi_file_info *info;
-
- info = comedi_file_info_from_minor(minor);
-
return info ? info->device : NULL;
}
+
+struct comedi_device *comedi_dev_from_minor(unsigned minor)
+{
+ return comedi_dev_from_file_info(comedi_file_info_from_minor(minor));
+}
EXPORT_SYMBOL_GPL(comedi_dev_from_minor);
static struct comedi_subdevice *
@@ -1647,8 +1649,8 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
const unsigned minor = iminor(file->f_dentry->d_inode);
- struct comedi_device *dev = comedi_dev_from_minor(minor);
struct comedi_file_info *info = comedi_file_info_from_minor(minor);
+ struct comedi_device *dev = comedi_dev_from_file_info(info);
int rc;
if (!dev)
@@ -1771,7 +1773,7 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
{
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_file_info *info = comedi_file_info_from_minor(minor);
- struct comedi_device *dev = comedi_dev_from_minor(minor);
+ struct comedi_device *dev = comedi_dev_from_file_info(info);
struct comedi_subdevice *s;
struct comedi_async *async;
unsigned long start = vma->vm_start;
@@ -1851,7 +1853,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
unsigned int mask = 0;
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_file_info *info = comedi_file_info_from_minor(minor);
- struct comedi_device *dev = comedi_dev_from_minor(minor);
+ struct comedi_device *dev = comedi_dev_from_file_info(info);
struct comedi_subdevice *s;
if (!dev)
@@ -1897,7 +1899,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
DECLARE_WAITQUEUE(wait, current);
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_file_info *info = comedi_file_info_from_minor(minor);
- struct comedi_device *dev = comedi_dev_from_minor(minor);
+ struct comedi_device *dev = comedi_dev_from_file_info(info);
if (!dev)
return -ENODEV;
@@ -1992,7 +1994,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
DECLARE_WAITQUEUE(wait, current);
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_file_info *info = comedi_file_info_from_minor(minor);
- struct comedi_device *dev = comedi_dev_from_minor(minor);
+ struct comedi_device *dev = comedi_dev_from_file_info(info);
if (!dev)
return -ENODEV;