Commit 63c3b9d7 authored by Akinobu Mita's avatar Akinobu Mita Committed by Benjamin Herrenschmidt

powerpc/spufs: Use simple_write_to_buffer

Simplify several write fileoperations for spufs by using
simple_write_to_buffer().
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 06ca2188
......@@ -219,24 +219,17 @@ spufs_mem_write(struct file *file, const char __user *buffer,
loff_t pos = *ppos;
int ret;
if (pos < 0)
return -EINVAL;
if (pos > LS_SIZE)
return -EFBIG;
if (size > LS_SIZE - pos)
size = LS_SIZE - pos;
ret = spu_acquire(ctx);
if (ret)
return ret;
local_store = ctx->ops->get_ls(ctx);
ret = copy_from_user(local_store + pos, buffer, size);
size = simple_write_to_buffer(local_store, LS_SIZE, ppos, buffer, size);
spu_release(ctx);
if (ret)
return -EFAULT;
*ppos = pos + size;
return size;
}
......@@ -574,18 +567,15 @@ spufs_regs_write(struct file *file, const char __user *buffer,
if (*pos >= sizeof(lscsa->gprs))
return -EFBIG;
size = min_t(ssize_t, sizeof(lscsa->gprs) - *pos, size);
*pos += size;
ret = spu_acquire_saved(ctx);
if (ret)
return ret;
ret = copy_from_user((char *)lscsa->gprs + *pos - size,
buffer, size) ? -EFAULT : size;
size = simple_write_to_buffer(lscsa->gprs, sizeof(lscsa->gprs), pos,
buffer, size);
spu_release_saved(ctx);
return ret;
return size;
}
static const struct file_operations spufs_regs_fops = {
......@@ -630,18 +620,15 @@ spufs_fpcr_write(struct file *file, const char __user * buffer,
if (*pos >= sizeof(lscsa->fpcr))
return -EFBIG;
size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
ret = spu_acquire_saved(ctx);
if (ret)
return ret;
*pos += size;
ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
buffer, size) ? -EFAULT : size;
size = simple_write_to_buffer(&lscsa->fpcr, sizeof(lscsa->fpcr), pos,
buffer, size);
spu_release_saved(ctx);
return ret;
return size;
}
static const struct file_operations spufs_fpcr_fops = {
......
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