staging: most: rearrange function aim_write
authorChristian Gromm <christian.gromm@microchip.com>
Tue, 22 Dec 2015 09:53:07 +0000 (10:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Feb 2016 01:34:58 +0000 (17:34 -0800)
This patch straightens and rearranges the code of function aim_write()
of module aim-cdev.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/aim-cdev/cdev.c

index 0ee2f08..c3f3271 100644 (file)
@@ -183,10 +183,9 @@ static int aim_close(struct inode *inode, struct file *filp)
 static ssize_t aim_write(struct file *filp, const char __user *buf,
                         size_t count, loff_t *offset)
 {
-       int ret, err;
+       int ret;
        size_t actual_len;
        size_t max_len;
-       ssize_t retval;
        struct mbo *mbo = NULL;
        struct aim_channel *c = filp->private_data;
 
@@ -202,33 +201,30 @@ static ssize_t aim_write(struct file *filp, const char __user *buf,
        }
 
        if (unlikely(!c->dev)) {
-               err = -EPIPE;
-               goto error;
+               ret = -EPIPE;
+               goto unlock;
        }
 
        max_len = c->cfg->buffer_size;
        actual_len = min(count, max_len);
        mbo->buffer_length = actual_len;
 
-       retval = copy_from_user(mbo->virt_address, buf, mbo->buffer_length);
-       if (retval) {
-               err = -EIO;
-               goto error;
+       if (copy_from_user(mbo->virt_address, buf, mbo->buffer_length)) {
+               ret = -EFAULT;
+               goto put_mbo;
        }
 
        ret = most_submit_mbo(mbo);
-       if (ret) {
-               pr_info("submitting MBO to core failed\n");
-               err = ret;
-               goto error;
-       }
+       if (ret)
+               goto put_mbo;
+
        mutex_unlock(&c->io_mutex);
-       return actual_len - retval;
-error:
-       if (mbo)
-               most_put_mbo(mbo);
+       return actual_len;
+put_mbo:
+       most_put_mbo(mbo);
+unlock:
        mutex_unlock(&c->io_mutex);
-       return err;
+       return ret;
 }
 
 /**