aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2010-12-24 15:03:56 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-01-20 22:08:34 -0500
commit63c3b9d71bb66f4b62059713201f066ad9415bb5 (patch)
treee35ff573627a759b407129903f80c298303f1fa0 /arch/powerpc
parent06ca2188eccbd7932636ac5bde2837297800480e (diff)
powerpc/spufs: Use simple_write_to_buffer
Simplify several write fileoperations for spufs by using simple_write_to_buffer(). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 02f7b113a31b..3c7c3f82d842 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -219,24 +219,17 @@ spufs_mem_write(struct file *file, const char __user *buffer,
219 loff_t pos = *ppos; 219 loff_t pos = *ppos;
220 int ret; 220 int ret;
221 221
222 if (pos < 0)
223 return -EINVAL;
224 if (pos > LS_SIZE) 222 if (pos > LS_SIZE)
225 return -EFBIG; 223 return -EFBIG;
226 if (size > LS_SIZE - pos)
227 size = LS_SIZE - pos;
228 224
229 ret = spu_acquire(ctx); 225 ret = spu_acquire(ctx);
230 if (ret) 226 if (ret)
231 return ret; 227 return ret;
232 228
233 local_store = ctx->ops->get_ls(ctx); 229 local_store = ctx->ops->get_ls(ctx);
234 ret = copy_from_user(local_store + pos, buffer, size); 230 size = simple_write_to_buffer(local_store, LS_SIZE, ppos, buffer, size);
235 spu_release(ctx); 231 spu_release(ctx);
236 232
237 if (ret)
238 return -EFAULT;
239 *ppos = pos + size;
240 return size; 233 return size;
241} 234}
242 235
@@ -574,18 +567,15 @@ spufs_regs_write(struct file *file, const char __user *buffer,
574 if (*pos >= sizeof(lscsa->gprs)) 567 if (*pos >= sizeof(lscsa->gprs))
575 return -EFBIG; 568 return -EFBIG;
576 569
577 size = min_t(ssize_t, sizeof(lscsa->gprs) - *pos, size);
578 *pos += size;
579
580 ret = spu_acquire_saved(ctx); 570 ret = spu_acquire_saved(ctx);
581 if (ret) 571 if (ret)
582 return ret; 572 return ret;
583 573
584 ret = copy_from_user((char *)lscsa->gprs + *pos - size, 574 size = simple_write_to_buffer(lscsa->gprs, sizeof(lscsa->gprs), pos,
585 buffer, size) ? -EFAULT : size; 575 buffer, size);
586 576
587 spu_release_saved(ctx); 577 spu_release_saved(ctx);
588 return ret; 578 return size;
589} 579}
590 580
591static const struct file_operations spufs_regs_fops = { 581static const struct file_operations spufs_regs_fops = {
@@ -630,18 +620,15 @@ spufs_fpcr_write(struct file *file, const char __user * buffer,
630 if (*pos >= sizeof(lscsa->fpcr)) 620 if (*pos >= sizeof(lscsa->fpcr))
631 return -EFBIG; 621 return -EFBIG;
632 622
633 size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
634
635 ret = spu_acquire_saved(ctx); 623 ret = spu_acquire_saved(ctx);
636 if (ret) 624 if (ret)
637 return ret; 625 return ret;
638 626
639 *pos += size; 627 size = simple_write_to_buffer(&lscsa->fpcr, sizeof(lscsa->fpcr), pos,
640 ret = copy_from_user((char *)&lscsa->fpcr + *pos - size, 628 buffer, size);
641 buffer, size) ? -EFAULT : size;
642 629
643 spu_release_saved(ctx); 630 spu_release_saved(ctx);
644 return ret; 631 return size;
645} 632}
646 633
647static const struct file_operations spufs_fpcr_fops = { 634static const struct file_operations spufs_fpcr_fops = {