aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile2
-rw-r--r--lib/iovec.c53
-rw-r--r--lib/klist.c2
-rw-r--r--lib/mpi/longlong.h5
4 files changed, 58 insertions, 4 deletions
diff --git a/lib/Makefile b/lib/Makefile
index e9c52e1b853a..c55a037a354e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -23,7 +23,7 @@ lib-y += kobject.o klist.o
23 23
24obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ 24obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
25 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ 25 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
26 gcd.o lcm.o list_sort.o uuid.o flex_array.o \ 26 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o \
27 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o 27 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o
28obj-y += string_helpers.o 28obj-y += string_helpers.o
29obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o 29obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
diff --git a/lib/iovec.c b/lib/iovec.c
new file mode 100644
index 000000000000..454baa88bf27
--- /dev/null
+++ b/lib/iovec.c
@@ -0,0 +1,53 @@
1#include <linux/uaccess.h>
2#include <linux/export.h>
3#include <linux/uio.h>
4
5/*
6 * Copy iovec to kernel. Returns -EFAULT on error.
7 *
8 * Note: this modifies the original iovec.
9 */
10
11int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len)
12{
13 while (len > 0) {
14 if (iov->iov_len) {
15 int copy = min_t(unsigned int, len, iov->iov_len);
16 if (copy_from_user(kdata, iov->iov_base, copy))
17 return -EFAULT;
18 len -= copy;
19 kdata += copy;
20 iov->iov_base += copy;
21 iov->iov_len -= copy;
22 }
23 iov++;
24 }
25
26 return 0;
27}
28EXPORT_SYMBOL(memcpy_fromiovec);
29
30/*
31 * Copy kernel to iovec. Returns -EFAULT on error.
32 *
33 * Note: this modifies the original iovec.
34 */
35
36int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
37{
38 while (len > 0) {
39 if (iov->iov_len) {
40 int copy = min_t(unsigned int, iov->iov_len, len);
41 if (copy_to_user(iov->iov_base, kdata, copy))
42 return -EFAULT;
43 kdata += copy;
44 len -= copy;
45 iov->iov_len -= copy;
46 iov->iov_base += copy;
47 }
48 iov++;
49 }
50
51 return 0;
52}
53EXPORT_SYMBOL(memcpy_toiovec);
diff --git a/lib/klist.c b/lib/klist.c
index 0874e41609a6..358a368a2947 100644
--- a/lib/klist.c
+++ b/lib/klist.c
@@ -193,10 +193,10 @@ static void klist_release(struct kref *kref)
193 if (waiter->node != n) 193 if (waiter->node != n)
194 continue; 194 continue;
195 195
196 list_del(&waiter->list);
196 waiter->woken = 1; 197 waiter->woken = 1;
197 mb(); 198 mb();
198 wake_up_process(waiter->process); 199 wake_up_process(waiter->process);
199 list_del(&waiter->list);
200 } 200 }
201 spin_unlock(&klist_remove_lock); 201 spin_unlock(&klist_remove_lock);
202 knode_set_klist(n, NULL); 202 knode_set_klist(n, NULL);
diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h
index 095ab157a521..d411355f238e 100644
--- a/lib/mpi/longlong.h
+++ b/lib/mpi/longlong.h
@@ -318,7 +318,8 @@ extern UDItype __udiv_qrnnd();
318 "rM" ((USItype)(bh)), \ 318 "rM" ((USItype)(bh)), \
319 "rM" ((USItype)(al)), \ 319 "rM" ((USItype)(al)), \
320 "rM" ((USItype)(bl))) 320 "rM" ((USItype)(bl)))
321#if defined(_PA_RISC1_1) 321#if 0 && defined(_PA_RISC1_1)
322/* xmpyu uses floating point register which is not allowed in Linux kernel. */
322#define umul_ppmm(wh, wl, u, v) \ 323#define umul_ppmm(wh, wl, u, v) \
323do { \ 324do { \
324 union {UDItype __ll; \ 325 union {UDItype __ll; \
@@ -337,7 +338,7 @@ do { \
337#define UMUL_TIME 40 338#define UMUL_TIME 40
338#define UDIV_TIME 80 339#define UDIV_TIME 80
339#endif 340#endif
340#ifndef LONGLONG_STANDALONE 341#if 0 /* #ifndef LONGLONG_STANDALONE */
341#define udiv_qrnnd(q, r, n1, n0, d) \ 342#define udiv_qrnnd(q, r, n1, n0, d) \
342do { USItype __r; \ 343do { USItype __r; \
343 (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \ 344 (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \