Commit 5adf5dc5 authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman

staging: most: rearrange function aim_write

This patch straightens and rearranges the code of function aim_write()
of module aim-cdev.
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f45b0fba
...@@ -183,10 +183,9 @@ static int aim_close(struct inode *inode, struct file *filp) ...@@ -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, static ssize_t aim_write(struct file *filp, const char __user *buf,
size_t count, loff_t *offset) size_t count, loff_t *offset)
{ {
int ret, err; int ret;
size_t actual_len; size_t actual_len;
size_t max_len; size_t max_len;
ssize_t retval;
struct mbo *mbo = NULL; struct mbo *mbo = NULL;
struct aim_channel *c = filp->private_data; struct aim_channel *c = filp->private_data;
...@@ -202,33 +201,30 @@ static ssize_t aim_write(struct file *filp, const char __user *buf, ...@@ -202,33 +201,30 @@ static ssize_t aim_write(struct file *filp, const char __user *buf,
} }
if (unlikely(!c->dev)) { if (unlikely(!c->dev)) {
err = -EPIPE; ret = -EPIPE;
goto error; goto unlock;
} }
max_len = c->cfg->buffer_size; max_len = c->cfg->buffer_size;
actual_len = min(count, max_len); actual_len = min(count, max_len);
mbo->buffer_length = actual_len; mbo->buffer_length = actual_len;
retval = copy_from_user(mbo->virt_address, buf, mbo->buffer_length); if (copy_from_user(mbo->virt_address, buf, mbo->buffer_length)) {
if (retval) { ret = -EFAULT;
err = -EIO; goto put_mbo;
goto error;
} }
ret = most_submit_mbo(mbo); ret = most_submit_mbo(mbo);
if (ret) { if (ret)
pr_info("submitting MBO to core failed\n"); goto put_mbo;
err = ret;
goto error;
}
mutex_unlock(&c->io_mutex); mutex_unlock(&c->io_mutex);
return actual_len - retval; return actual_len;
error: put_mbo:
if (mbo) most_put_mbo(mbo);
most_put_mbo(mbo); unlock:
mutex_unlock(&c->io_mutex); mutex_unlock(&c->io_mutex);
return err; return ret;
} }
/** /**
......
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