* [patch 2/2] spufs: use simple_write_to_buffer()
@ 2011-01-18 21:09 akpm
2011-01-18 21:22 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2011-01-18 21:09 UTC (permalink / raw)
To: benh; +Cc: arnd, akinobu.mita, linuxppc-dev, paulus, jk, akpm
From: Akinobu Mita <akinobu.mita@gmail.com>
Simplify several write fileoperations for spufs by using
simple_write_to_buffer().
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Jeremy Kerr <jk@ozlabs.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/powerpc/platforms/cell/spufs/file.c | 27 +++++----------------
1 file changed, 7 insertions(+), 20 deletions(-)
diff -puN arch/powerpc/platforms/cell/spufs/file.c~spufs-use-simple_write_to_buffer arch/powerpc/platforms/cell/spufs/file.c
--- a/arch/powerpc/platforms/cell/spufs/file.c~spufs-use-simple_write_to_buffer
+++ a/arch/powerpc/platforms/cell/spufs/file.c
@@ -219,24 +219,17 @@ spufs_mem_write(struct file *file, const
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, cons
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, cons
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 = {
_
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch 2/2] spufs: use simple_write_to_buffer()
2011-01-18 21:09 [patch 2/2] spufs: use simple_write_to_buffer() akpm
@ 2011-01-18 21:22 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2011-01-18 21:22 UTC (permalink / raw)
To: akpm; +Cc: linuxppc-dev, paulus, akinobu.mita, arnd, jk
On Tue, 2011-01-18 at 13:09 -0800, akpm@linux-foundation.org wrote:
> From: Akinobu Mita <akinobu.mita@gmail.com>
>
> Simplify several write fileoperations for spufs by using
> simple_write_to_buffer().
I'll pick that one up too.
Cheers,
Ben.
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Jeremy Kerr <jk@ozlabs.org>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> arch/powerpc/platforms/cell/spufs/file.c | 27 +++++----------------
> 1 file changed, 7 insertions(+), 20 deletions(-)
>
> diff -puN arch/powerpc/platforms/cell/spufs/file.c~spufs-use-simple_write_to_buffer arch/powerpc/platforms/cell/spufs/file.c
> --- a/arch/powerpc/platforms/cell/spufs/file.c~spufs-use-simple_write_to_buffer
> +++ a/arch/powerpc/platforms/cell/spufs/file.c
> @@ -219,24 +219,17 @@ spufs_mem_write(struct file *file, const
> 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, cons
> 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, cons
> 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 = {
> _
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-18 21:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-18 21:09 [patch 2/2] spufs: use simple_write_to_buffer() akpm
2011-01-18 21:22 ` Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).