summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/lib/checksum_wrappers_64.c
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2010-08-02 20:11:36 +0000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-09-02 14:07:30 +1000
commit8c77391475bc3284a380fc46aaf0bcf26bde3ae6 (patch)
tree0948ebdf02ce03948faf8dc41af8414f84652239 /arch/powerpc/lib/checksum_wrappers_64.c
parentfdd374b62ca4df144c0138359dcffa83df7a0ea8 (diff)
downloadblackbird-op-linux-8c77391475bc3284a380fc46aaf0bcf26bde3ae6.tar.gz
blackbird-op-linux-8c77391475bc3284a380fc46aaf0bcf26bde3ae6.zip
powerpc: Add 64bit csum_and_copy_to_user
This adds the equivalent of csum_and_copy_from_user for the receive side so we can copy and checksum in one pass. It is modelled on the generic checksum routine. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/lib/checksum_wrappers_64.c')
-rw-r--r--arch/powerpc/lib/checksum_wrappers_64.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/arch/powerpc/lib/checksum_wrappers_64.c b/arch/powerpc/lib/checksum_wrappers_64.c
index 614cff1a8e0e..769b817fbb32 100644
--- a/arch/powerpc/lib/checksum_wrappers_64.c
+++ b/arch/powerpc/lib/checksum_wrappers_64.c
@@ -63,3 +63,40 @@ out:
return (__force __wsum)csum;
}
EXPORT_SYMBOL(csum_and_copy_from_user);
+
+__wsum csum_and_copy_to_user(const void *src, void __user *dst, int len,
+ __wsum sum, int *err_ptr)
+{
+ unsigned int csum;
+
+ might_sleep();
+
+ *err_ptr = 0;
+
+ if (!len) {
+ csum = 0;
+ goto out;
+ }
+
+ if (unlikely((len < 0) || !access_ok(VERIFY_WRITE, dst, len))) {
+ *err_ptr = -EFAULT;
+ csum = -1; /* invalid checksum */
+ goto out;
+ }
+
+ csum = csum_partial_copy_generic(src, (void __force *)dst,
+ len, sum, NULL, err_ptr);
+
+ if (unlikely(*err_ptr)) {
+ csum = csum_partial(src, len, sum);
+
+ if (copy_to_user(dst, src, len)) {
+ *err_ptr = -EFAULT;
+ csum = -1; /* invalid checksum */
+ }
+ }
+
+out:
+ return (__force __wsum)csum;
+}
+EXPORT_SYMBOL(csum_and_copy_to_user);
OpenPOWER on IntegriCloud