diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2012-12-19 23:40:34 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-07 23:25:48 +0100 |
commit | 2714b019fd570309e9a4cab2b988cbb7a36bbecd (patch) | |
tree | 4f932aae850fedb20cee23086b3a514102abac18 | |
parent | staging: comedi: comedi_fops: remove the goto's in comedi_read() (diff) | |
download | linux-2714b019fd570309e9a4cab2b988cbb7a36bbecd.tar.xz linux-2714b019fd570309e9a4cab2b988cbb7a36bbecd.zip |
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: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index cf1410dfc52c..0e9b5220ce22 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1870,39 +1870,27 @@ 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; + struct comedi_device *dev = comedi_dev_from_minor(minor); - if (info == NULL) - return -ENODEV; - dev = info->device; - if (dev == NULL) + if (!dev) return -ENODEV; if (!dev->attached) { DPRINTK("no driver configured on comedi%i\n", dev->minor); - retval = -ENODEV; - goto done; + return -ENODEV; } s = comedi_write_subdevice(info); - if (s == NULL) { - retval = -EIO; - goto done; - } + if (!s) + return -EIO; + async = s->async; - if (!nbytes) { - retval = 0; - goto done; - } - if (!s->busy) { - retval = 0; - goto done; - } - if (s->busy != file) { - retval = -EACCES; - goto done; - } + if (!s->busy || !nbytes) + return 0; + if (s->busy != file) + return -EACCES; + add_wait_queue(&async->wait_head, &wait); while (nbytes > 0 && !retval) { set_current_state(TASK_INTERRUPTIBLE); @@ -1967,7 +1955,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, set_current_state(TASK_RUNNING); remove_wait_queue(&async->wait_head, &wait); -done: return count ? count : retval; } |