Commit 2714b019 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: comedi_fops: remove the goto's in comedi_write()

Use comedi_dev_from_minor() to simplify the return -ENODEV tests.

Cleanup the sanity checking a bit and remove the need for the goto's
when returning an initial error condition.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5c87fef5
...@@ -1870,39 +1870,27 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, ...@@ -1870,39 +1870,27 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_file_info *info = comedi_file_info_from_minor(minor); struct comedi_file_info *info = comedi_file_info_from_minor(minor);
struct comedi_device *dev; struct comedi_device *dev = comedi_dev_from_minor(minor);
if (info == NULL) if (!dev)
return -ENODEV;
dev = info->device;
if (dev == NULL)
return -ENODEV; return -ENODEV;
if (!dev->attached) { if (!dev->attached) {
DPRINTK("no driver configured on comedi%i\n", dev->minor); DPRINTK("no driver configured on comedi%i\n", dev->minor);
retval = -ENODEV; return -ENODEV;
goto done;
} }
s = comedi_write_subdevice(info); s = comedi_write_subdevice(info);
if (s == NULL) { if (!s)
retval = -EIO; return -EIO;
goto done;
}
async = s->async; async = s->async;
if (!nbytes) { if (!s->busy || !nbytes)
retval = 0; return 0;
goto done; if (s->busy != file)
} return -EACCES;
if (!s->busy) {
retval = 0;
goto done;
}
if (s->busy != file) {
retval = -EACCES;
goto done;
}
add_wait_queue(&async->wait_head, &wait); add_wait_queue(&async->wait_head, &wait);
while (nbytes > 0 && !retval) { while (nbytes > 0 && !retval) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
...@@ -1967,7 +1955,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, ...@@ -1967,7 +1955,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&async->wait_head, &wait); remove_wait_queue(&async->wait_head, &wait);
done:
return count ? count : retval; return count ? count : retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment