aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug27
-rw-r--r--lib/bitmap.c166
-rw-r--r--lib/extable.c3
-rw-r--r--lib/idr.c50
-rw-r--r--lib/kobject.c3
-rw-r--r--lib/kobject_uevent.c6
-rw-r--r--lib/smp_processor_id.c1
-rw-r--r--lib/sort.c1
-rw-r--r--lib/string.c125
-rw-r--r--lib/swiotlb.c2
-rw-r--r--lib/textsearch.c2
-rw-r--r--lib/vsprintf.c1
-rw-r--r--lib/zlib_inflate/inflate.c1
13 files changed, 291 insertions, 97 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 016e89a44ac8..156822e3cc79 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -128,7 +128,7 @@ config DEBUG_HIGHMEM
128config DEBUG_BUGVERBOSE 128config DEBUG_BUGVERBOSE
129 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED 129 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
130 depends on BUG 130 depends on BUG
131 depends on ARM || ARM26 || M32R || M68K || SPARC32 || SPARC64 || (X86 && !X86_64) || FRV 131 depends on ARM || ARM26 || M32R || M68K || SPARC32 || SPARC64 || X86_32 || FRV
132 default !EMBEDDED 132 default !EMBEDDED
133 help 133 help
134 Say Y here to make BUG() panics output the file name and line number 134 Say Y here to make BUG() panics output the file name and line number
@@ -168,13 +168,34 @@ config DEBUG_FS
168 168
169 If unsure, say N. 169 If unsure, say N.
170 170
171config DEBUG_VM
172 bool "Debug VM"
173 depends on DEBUG_KERNEL
174 help
175 Enable this to debug the virtual-memory system.
176
177 If unsure, say N.
178
171config FRAME_POINTER 179config FRAME_POINTER
172 bool "Compile the kernel with frame pointers" 180 bool "Compile the kernel with frame pointers"
173 depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML) 181 depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML)
174 default y if DEBUG_INFO && UML 182 default y if DEBUG_INFO && UML
175 help 183 help
176 If you say Y here the resulting kernel image will be slightly larger 184 If you say Y here the resulting kernel image will be slightly larger
177 and slower, but it might give very useful debugging information 185 and slower, but it might give very useful debugging information on
178 on some architectures or you use external debuggers. 186 some architectures or if you use external debuggers.
179 If you don't debug the kernel, you can say N. 187 If you don't debug the kernel, you can say N.
180 188
189config RCU_TORTURE_TEST
190 tristate "torture tests for RCU"
191 depends on DEBUG_KERNEL
192 default n
193 help
194 This option provides a kernel module that runs torture tests
195 on the RCU infrastructure. The kernel module may be built
196 after the fact on the running kernel to be tested, if desired.
197
198 Say Y here if you want RCU torture tests to start automatically
199 at boot time (you probably don't).
200 Say M if you want the RCU torture tests to build as a module.
201 Say N if you are unsure.
diff --git a/lib/bitmap.c b/lib/bitmap.c
index fb9371fdd44a..23d3b1147fe9 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -511,6 +511,172 @@ int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
511} 511}
512EXPORT_SYMBOL(bitmap_parselist); 512EXPORT_SYMBOL(bitmap_parselist);
513 513
514/*
515 * bitmap_pos_to_ord(buf, pos, bits)
516 * @buf: pointer to a bitmap
517 * @pos: a bit position in @buf (0 <= @pos < @bits)
518 * @bits: number of valid bit positions in @buf
519 *
520 * Map the bit at position @pos in @buf (of length @bits) to the
521 * ordinal of which set bit it is. If it is not set or if @pos
522 * is not a valid bit position, map to zero (0).
523 *
524 * If for example, just bits 4 through 7 are set in @buf, then @pos
525 * values 4 through 7 will get mapped to 0 through 3, respectively,
526 * and other @pos values will get mapped to 0. When @pos value 7
527 * gets mapped to (returns) @ord value 3 in this example, that means
528 * that bit 7 is the 3rd (starting with 0th) set bit in @buf.
529 *
530 * The bit positions 0 through @bits are valid positions in @buf.
531 */
532static int bitmap_pos_to_ord(const unsigned long *buf, int pos, int bits)
533{
534 int ord = 0;
535
536 if (pos >= 0 && pos < bits) {
537 int i;
538
539 for (i = find_first_bit(buf, bits);
540 i < pos;
541 i = find_next_bit(buf, bits, i + 1))
542 ord++;
543 if (i > pos)
544 ord = 0;
545 }
546 return ord;
547}
548
549/**
550 * bitmap_ord_to_pos(buf, ord, bits)
551 * @buf: pointer to bitmap
552 * @ord: ordinal bit position (n-th set bit, n >= 0)
553 * @bits: number of valid bit positions in @buf
554 *
555 * Map the ordinal offset of bit @ord in @buf to its position in @buf.
556 * If @ord is not the ordinal offset of a set bit in @buf, map to zero (0).
557 *
558 * If for example, just bits 4 through 7 are set in @buf, then @ord
559 * values 0 through 3 will get mapped to 4 through 7, respectively,
560 * and all other @ord valuds will get mapped to 0. When @ord value 3
561 * gets mapped to (returns) @pos value 7 in this example, that means
562 * that the 3rd set bit (starting with 0th) is at position 7 in @buf.
563 *
564 * The bit positions 0 through @bits are valid positions in @buf.
565 */
566static int bitmap_ord_to_pos(const unsigned long *buf, int ord, int bits)
567{
568 int pos = 0;
569
570 if (ord >= 0 && ord < bits) {
571 int i;
572
573 for (i = find_first_bit(buf, bits);
574 i < bits && ord > 0;
575 i = find_next_bit(buf, bits, i + 1))
576 ord--;
577 if (i < bits && ord == 0)
578 pos = i;
579 }
580
581 return pos;
582}
583
584/**
585 * bitmap_remap - Apply map defined by a pair of bitmaps to another bitmap
586 * @src: subset to be remapped
587 * @dst: remapped result
588 * @old: defines domain of map
589 * @new: defines range of map
590 * @bits: number of bits in each of these bitmaps
591 *
592 * Let @old and @new define a mapping of bit positions, such that
593 * whatever position is held by the n-th set bit in @old is mapped
594 * to the n-th set bit in @new. In the more general case, allowing
595 * for the possibility that the weight 'w' of @new is less than the
596 * weight of @old, map the position of the n-th set bit in @old to
597 * the position of the m-th set bit in @new, where m == n % w.
598 *
599 * If either of the @old and @new bitmaps are empty, or if@src and @dst
600 * point to the same location, then this routine does nothing.
601 *
602 * The positions of unset bits in @old are mapped to the position of
603 * the first set bit in @new.
604 *
605 * Apply the above specified mapping to @src, placing the result in
606 * @dst, clearing any bits previously set in @dst.
607 *
608 * The resulting value of @dst will have either the same weight as
609 * @src, or less weight in the general case that the mapping wasn't
610 * injective due to the weight of @new being less than that of @old.
611 * The resulting value of @dst will never have greater weight than
612 * that of @src, except perhaps in the case that one of the above
613 * conditions was not met and this routine just returned.
614 *
615 * For example, lets say that @old has bits 4 through 7 set, and
616 * @new has bits 12 through 15 set. This defines the mapping of bit
617 * position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other
618 * bit positions to 12 (the first set bit in @new. So if say @src
619 * comes into this routine with bits 1, 5 and 7 set, then @dst should
620 * leave with bits 12, 13 and 15 set.
621 */
622void bitmap_remap(unsigned long *dst, const unsigned long *src,
623 const unsigned long *old, const unsigned long *new,
624 int bits)
625{
626 int s;
627
628 if (bitmap_weight(old, bits) == 0)
629 return;
630 if (bitmap_weight(new, bits) == 0)
631 return;
632 if (dst == src) /* following doesn't handle inplace remaps */
633 return;
634
635 bitmap_zero(dst, bits);
636 for (s = find_first_bit(src, bits);
637 s < bits;
638 s = find_next_bit(src, bits, s + 1)) {
639 int x = bitmap_pos_to_ord(old, s, bits);
640 int y = bitmap_ord_to_pos(new, x, bits);
641 set_bit(y, dst);
642 }
643}
644EXPORT_SYMBOL(bitmap_remap);
645
646/**
647 * bitmap_bitremap - Apply map defined by a pair of bitmaps to a single bit
648 * @oldbit - bit position to be mapped
649 * @old: defines domain of map
650 * @new: defines range of map
651 * @bits: number of bits in each of these bitmaps
652 *
653 * Let @old and @new define a mapping of bit positions, such that
654 * whatever position is held by the n-th set bit in @old is mapped
655 * to the n-th set bit in @new. In the more general case, allowing
656 * for the possibility that the weight 'w' of @new is less than the
657 * weight of @old, map the position of the n-th set bit in @old to
658 * the position of the m-th set bit in @new, where m == n % w.
659 *
660 * The positions of unset bits in @old are mapped to the position of
661 * the first set bit in @new.
662 *
663 * Apply the above specified mapping to bit position @oldbit, returning
664 * the new bit position.
665 *
666 * For example, lets say that @old has bits 4 through 7 set, and
667 * @new has bits 12 through 15 set. This defines the mapping of bit
668 * position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other
669 * bit positions to 12 (the first set bit in @new. So if say @oldbit
670 * is 5, then this routine returns 13.
671 */
672int bitmap_bitremap(int oldbit, const unsigned long *old,
673 const unsigned long *new, int bits)
674{
675 int x = bitmap_pos_to_ord(old, oldbit, bits);
676 return bitmap_ord_to_pos(new, x, bits);
677}
678EXPORT_SYMBOL(bitmap_bitremap);
679
514/** 680/**
515 * bitmap_find_free_region - find a contiguous aligned mem region 681 * bitmap_find_free_region - find a contiguous aligned mem region
516 * @bitmap: an array of unsigned longs corresponding to the bitmap 682 * @bitmap: an array of unsigned longs corresponding to the bitmap
diff --git a/lib/extable.c b/lib/extable.c
index 3f677a8f0c3c..18df57c029df 100644
--- a/lib/extable.c
+++ b/lib/extable.c
@@ -16,9 +16,6 @@
16#include <linux/sort.h> 16#include <linux/sort.h>
17#include <asm/uaccess.h> 17#include <asm/uaccess.h>
18 18
19extern struct exception_table_entry __start___ex_table[];
20extern struct exception_table_entry __stop___ex_table[];
21
22#ifndef ARCH_HAS_SORT_EXTABLE 19#ifndef ARCH_HAS_SORT_EXTABLE
23/* 20/*
24 * The exception table needs to be sorted so that the binary 21 * The exception table needs to be sorted so that the binary
diff --git a/lib/idr.c b/lib/idr.c
index 6415d053e2bf..d226259c3c28 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -6,20 +6,20 @@
6 * Modified by George Anzinger to reuse immediately and to use 6 * Modified by George Anzinger to reuse immediately and to use
7 * find bit instructions. Also removed _irq on spinlocks. 7 * find bit instructions. Also removed _irq on spinlocks.
8 * 8 *
9 * Small id to pointer translation service. 9 * Small id to pointer translation service.
10 * 10 *
11 * It uses a radix tree like structure as a sparse array indexed 11 * It uses a radix tree like structure as a sparse array indexed
12 * by the id to obtain the pointer. The bitmap makes allocating 12 * by the id to obtain the pointer. The bitmap makes allocating
13 * a new id quick. 13 * a new id quick.
14 * 14 *
15 * You call it to allocate an id (an int) an associate with that id a 15 * You call it to allocate an id (an int) an associate with that id a
16 * pointer or what ever, we treat it as a (void *). You can pass this 16 * pointer or what ever, we treat it as a (void *). You can pass this
17 * id to a user for him to pass back at a later time. You then pass 17 * id to a user for him to pass back at a later time. You then pass
18 * that id to this code and it returns your pointer. 18 * that id to this code and it returns your pointer.
19 19
20 * You can release ids at any time. When all ids are released, most of 20 * You can release ids at any time. When all ids are released, most of
21 * the memory is returned (we keep IDR_FREE_MAX) in a local pool so we 21 * the memory is returned (we keep IDR_FREE_MAX) in a local pool so we
22 * don't need to go to the memory "store" during an id allocate, just 22 * don't need to go to the memory "store" during an id allocate, just
23 * so you don't need to be too concerned about locking and conflicts 23 * so you don't need to be too concerned about locking and conflicts
24 * with the slab allocator. 24 * with the slab allocator.
25 */ 25 */
@@ -72,12 +72,12 @@ static void free_layer(struct idr *idp, struct idr_layer *p)
72 * If the system is REALLY out of memory this function returns 0, 72 * If the system is REALLY out of memory this function returns 0,
73 * otherwise 1. 73 * otherwise 1.
74 */ 74 */
75int idr_pre_get(struct idr *idp, unsigned gfp_mask) 75int idr_pre_get(struct idr *idp, gfp_t gfp_mask)
76{ 76{
77 while (idp->id_free_cnt < IDR_FREE_MAX) { 77 while (idp->id_free_cnt < IDR_FREE_MAX) {
78 struct idr_layer *new; 78 struct idr_layer *new;
79 new = kmem_cache_alloc(idr_layer_cache, gfp_mask); 79 new = kmem_cache_alloc(idr_layer_cache, gfp_mask);
80 if(new == NULL) 80 if (new == NULL)
81 return (0); 81 return (0);
82 free_layer(idp, new); 82 free_layer(idp, new);
83 } 83 }
@@ -107,7 +107,7 @@ static int sub_alloc(struct idr *idp, void *ptr, int *starting_id)
107 if (m == IDR_SIZE) { 107 if (m == IDR_SIZE) {
108 /* no space available go back to previous layer. */ 108 /* no space available go back to previous layer. */
109 l++; 109 l++;
110 id = (id | ((1 << (IDR_BITS*l))-1)) + 1; 110 id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1;
111 if (!(p = pa[l])) { 111 if (!(p = pa[l])) {
112 *starting_id = id; 112 *starting_id = id;
113 return -2; 113 return -2;
@@ -161,7 +161,7 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id)
161{ 161{
162 struct idr_layer *p, *new; 162 struct idr_layer *p, *new;
163 int layers, v, id; 163 int layers, v, id;
164 164
165 id = starting_id; 165 id = starting_id;
166build_up: 166build_up:
167 p = idp->top; 167 p = idp->top;
@@ -225,6 +225,7 @@ build_up:
225int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) 225int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
226{ 226{
227 int rv; 227 int rv;
228
228 rv = idr_get_new_above_int(idp, ptr, starting_id); 229 rv = idr_get_new_above_int(idp, ptr, starting_id);
229 /* 230 /*
230 * This is a cheap hack until the IDR code can be fixed to 231 * This is a cheap hack until the IDR code can be fixed to
@@ -259,6 +260,7 @@ EXPORT_SYMBOL(idr_get_new_above);
259int idr_get_new(struct idr *idp, void *ptr, int *id) 260int idr_get_new(struct idr *idp, void *ptr, int *id)
260{ 261{
261 int rv; 262 int rv;
263
262 rv = idr_get_new_above_int(idp, ptr, 0); 264 rv = idr_get_new_above_int(idp, ptr, 0);
263 /* 265 /*
264 * This is a cheap hack until the IDR code can be fixed to 266 * This is a cheap hack until the IDR code can be fixed to
@@ -306,11 +308,10 @@ static void sub_remove(struct idr *idp, int shift, int id)
306 free_layer(idp, **paa); 308 free_layer(idp, **paa);
307 **paa-- = NULL; 309 **paa-- = NULL;
308 } 310 }
309 if ( ! *paa ) 311 if (!*paa)
310 idp->layers = 0; 312 idp->layers = 0;
311 } else { 313 } else
312 idr_remove_warning(id); 314 idr_remove_warning(id);
313 }
314} 315}
315 316
316/** 317/**
@@ -326,9 +327,8 @@ void idr_remove(struct idr *idp, int id)
326 id &= MAX_ID_MASK; 327 id &= MAX_ID_MASK;
327 328
328 sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); 329 sub_remove(idp, (idp->layers - 1) * IDR_BITS, id);
329 if ( idp->top && idp->top->count == 1 && 330 if (idp->top && idp->top->count == 1 && (idp->layers > 1) &&
330 (idp->layers > 1) && 331 idp->top->ary[0]) { // We can drop a layer
331 idp->top->ary[0]){ // We can drop a layer
332 332
333 p = idp->top->ary[0]; 333 p = idp->top->ary[0];
334 idp->top->bitmap = idp->top->count = 0; 334 idp->top->bitmap = idp->top->count = 0;
@@ -337,7 +337,6 @@ void idr_remove(struct idr *idp, int id)
337 --idp->layers; 337 --idp->layers;
338 } 338 }
339 while (idp->id_free_cnt >= IDR_FREE_MAX) { 339 while (idp->id_free_cnt >= IDR_FREE_MAX) {
340
341 p = alloc_layer(idp); 340 p = alloc_layer(idp);
342 kmem_cache_free(idr_layer_cache, p); 341 kmem_cache_free(idr_layer_cache, p);
343 return; 342 return;
@@ -346,6 +345,19 @@ void idr_remove(struct idr *idp, int id)
346EXPORT_SYMBOL(idr_remove); 345EXPORT_SYMBOL(idr_remove);
347 346
348/** 347/**
348 * idr_destroy - release all cached layers within an idr tree
349 * idp: idr handle
350 */
351void idr_destroy(struct idr *idp)
352{
353 while (idp->id_free_cnt) {
354 struct idr_layer *p = alloc_layer(idp);
355 kmem_cache_free(idr_layer_cache, p);
356 }
357}
358EXPORT_SYMBOL(idr_destroy);
359
360/**
349 * idr_find - return pointer for given id 361 * idr_find - return pointer for given id
350 * @idp: idr handle 362 * @idp: idr handle
351 * @id: lookup key 363 * @id: lookup key
@@ -378,8 +390,8 @@ void *idr_find(struct idr *idp, int id)
378} 390}
379EXPORT_SYMBOL(idr_find); 391EXPORT_SYMBOL(idr_find);
380 392
381static void idr_cache_ctor(void * idr_layer, 393static void idr_cache_ctor(void * idr_layer, kmem_cache_t *idr_layer_cache,
382 kmem_cache_t *idr_layer_cache, unsigned long flags) 394 unsigned long flags)
383{ 395{
384 memset(idr_layer, 0, sizeof(struct idr_layer)); 396 memset(idr_layer, 0, sizeof(struct idr_layer));
385} 397}
@@ -387,7 +399,7 @@ static void idr_cache_ctor(void * idr_layer,
387static int init_id_cache(void) 399static int init_id_cache(void)
388{ 400{
389 if (!idr_layer_cache) 401 if (!idr_layer_cache)
390 idr_layer_cache = kmem_cache_create("idr_layer_cache", 402 idr_layer_cache = kmem_cache_create("idr_layer_cache",
391 sizeof(struct idr_layer), 0, 0, idr_cache_ctor, NULL); 403 sizeof(struct idr_layer), 0, 0, idr_cache_ctor, NULL);
392 return 0; 404 return 0;
393} 405}
diff --git a/lib/kobject.c b/lib/kobject.c
index dd0917dd9fa9..a181abed89f6 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -14,6 +14,7 @@
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/stat.h> 16#include <linux/stat.h>
17#include <linux/slab.h>
17 18
18/** 19/**
19 * populate_dir - populate directory with attributes. 20 * populate_dir - populate directory with attributes.
@@ -100,7 +101,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)
100 * @kobj: kobject in question, with which to build the path 101 * @kobj: kobject in question, with which to build the path
101 * @gfp_mask: the allocation type used to allocate the path 102 * @gfp_mask: the allocation type used to allocate the path
102 */ 103 */
103char *kobject_get_path(struct kobject *kobj, int gfp_mask) 104char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
104{ 105{
105 char *path; 106 char *path;
106 int len; 107 int len;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 04ca4429ddfa..3ab375411e38 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -54,7 +54,7 @@ static char *action_to_string(enum kobject_action action)
54static struct sock *uevent_sock; 54static struct sock *uevent_sock;
55 55
56/** 56/**
57 * send_uevent - notify userspace by sending event trough netlink socket 57 * send_uevent - notify userspace by sending event through netlink socket
58 * 58 *
59 * @signal: signal name 59 * @signal: signal name
60 * @obj: object path (kobject) 60 * @obj: object path (kobject)
@@ -62,7 +62,7 @@ static struct sock *uevent_sock;
62 * @gfp_mask: 62 * @gfp_mask:
63 */ 63 */
64static int send_uevent(const char *signal, const char *obj, 64static int send_uevent(const char *signal, const char *obj,
65 char **envp, int gfp_mask) 65 char **envp, gfp_t gfp_mask)
66{ 66{
67 struct sk_buff *skb; 67 struct sk_buff *skb;
68 char *pos; 68 char *pos;
@@ -98,7 +98,7 @@ static int send_uevent(const char *signal, const char *obj,
98} 98}
99 99
100static int do_kobject_uevent(struct kobject *kobj, enum kobject_action action, 100static int do_kobject_uevent(struct kobject *kobj, enum kobject_action action,
101 struct attribute *attr, int gfp_mask) 101 struct attribute *attr, gfp_t gfp_mask)
102{ 102{
103 char *path; 103 char *path;
104 char *attrpath; 104 char *attrpath;
diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c
index 42c08ef828c5..eddc9b3d3876 100644
--- a/lib/smp_processor_id.c
+++ b/lib/smp_processor_id.c
@@ -5,6 +5,7 @@
5 */ 5 */
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/kallsyms.h> 7#include <linux/kallsyms.h>
8#include <linux/sched.h>
8 9
9unsigned int debug_smp_processor_id(void) 10unsigned int debug_smp_processor_id(void)
10{ 11{
diff --git a/lib/sort.c b/lib/sort.c
index ddc4d35df289..5f3b51ffa1dc 100644
--- a/lib/sort.c
+++ b/lib/sort.c
@@ -7,6 +7,7 @@
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/sort.h> 9#include <linux/sort.h>
10#include <linux/slab.h>
10 11
11static void u32_swap(void *a, void *b, int size) 12static void u32_swap(void *a, void *b, int size)
12{ 13{
diff --git a/lib/string.c b/lib/string.c
index d886ef157c12..037a48acedbb 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -36,11 +36,13 @@ int strnicmp(const char *s1, const char *s2, size_t len)
36 /* Yes, Virginia, it had better be unsigned */ 36 /* Yes, Virginia, it had better be unsigned */
37 unsigned char c1, c2; 37 unsigned char c1, c2;
38 38
39 c1 = 0; c2 = 0; 39 c1 = c2 = 0;
40 if (len) { 40 if (len) {
41 do { 41 do {
42 c1 = *s1; c2 = *s2; 42 c1 = *s1;
43 s1++; s2++; 43 c2 = *s2;
44 s1++;
45 s2++;
44 if (!c1) 46 if (!c1)
45 break; 47 break;
46 if (!c2) 48 if (!c2)
@@ -55,7 +57,6 @@ int strnicmp(const char *s1, const char *s2, size_t len)
55 } 57 }
56 return (int)c1 - (int)c2; 58 return (int)c1 - (int)c2;
57} 59}
58
59EXPORT_SYMBOL(strnicmp); 60EXPORT_SYMBOL(strnicmp);
60#endif 61#endif
61 62
@@ -66,7 +67,7 @@ EXPORT_SYMBOL(strnicmp);
66 * @src: Where to copy the string from 67 * @src: Where to copy the string from
67 */ 68 */
68#undef strcpy 69#undef strcpy
69char * strcpy(char * dest,const char *src) 70char *strcpy(char *dest, const char *src)
70{ 71{
71 char *tmp = dest; 72 char *tmp = dest;
72 73
@@ -91,12 +92,13 @@ EXPORT_SYMBOL(strcpy);
91 * count, the remainder of @dest will be padded with %NUL. 92 * count, the remainder of @dest will be padded with %NUL.
92 * 93 *
93 */ 94 */
94char * strncpy(char * dest,const char *src,size_t count) 95char *strncpy(char *dest, const char *src, size_t count)
95{ 96{
96 char *tmp = dest; 97 char *tmp = dest;
97 98
98 while (count) { 99 while (count) {
99 if ((*tmp = *src) != 0) src++; 100 if ((*tmp = *src) != 0)
101 src++;
100 tmp++; 102 tmp++;
101 count--; 103 count--;
102 } 104 }
@@ -122,7 +124,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
122 size_t ret = strlen(src); 124 size_t ret = strlen(src);
123 125
124 if (size) { 126 if (size) {
125 size_t len = (ret >= size) ? size-1 : ret; 127 size_t len = (ret >= size) ? size - 1 : ret;
126 memcpy(dest, src, len); 128 memcpy(dest, src, len);
127 dest[len] = '\0'; 129 dest[len] = '\0';
128 } 130 }
@@ -138,7 +140,7 @@ EXPORT_SYMBOL(strlcpy);
138 * @src: The string to append to it 140 * @src: The string to append to it
139 */ 141 */
140#undef strcat 142#undef strcat
141char * strcat(char * dest, const char * src) 143char *strcat(char *dest, const char *src)
142{ 144{
143 char *tmp = dest; 145 char *tmp = dest;
144 146
@@ -146,7 +148,6 @@ char * strcat(char * dest, const char * src)
146 dest++; 148 dest++;
147 while ((*dest++ = *src++) != '\0') 149 while ((*dest++ = *src++) != '\0')
148 ; 150 ;
149
150 return tmp; 151 return tmp;
151} 152}
152EXPORT_SYMBOL(strcat); 153EXPORT_SYMBOL(strcat);
@@ -162,7 +163,7 @@ EXPORT_SYMBOL(strcat);
162 * Note that in contrast to strncpy, strncat ensures the result is 163 * Note that in contrast to strncpy, strncat ensures the result is
163 * terminated. 164 * terminated.
164 */ 165 */
165char * strncat(char *dest, const char *src, size_t count) 166char *strncat(char *dest, const char *src, size_t count)
166{ 167{
167 char *tmp = dest; 168 char *tmp = dest;
168 169
@@ -176,7 +177,6 @@ char * strncat(char *dest, const char *src, size_t count)
176 } 177 }
177 } 178 }
178 } 179 }
179
180 return tmp; 180 return tmp;
181} 181}
182EXPORT_SYMBOL(strncat); 182EXPORT_SYMBOL(strncat);
@@ -216,15 +216,14 @@ EXPORT_SYMBOL(strlcat);
216 * @ct: Another string 216 * @ct: Another string
217 */ 217 */
218#undef strcmp 218#undef strcmp
219int strcmp(const char * cs,const char * ct) 219int strcmp(const char *cs, const char *ct)
220{ 220{
221 register signed char __res; 221 signed char __res;
222 222
223 while (1) { 223 while (1) {
224 if ((__res = *cs - *ct++) != 0 || !*cs++) 224 if ((__res = *cs - *ct++) != 0 || !*cs++)
225 break; 225 break;
226 } 226 }
227
228 return __res; 227 return __res;
229} 228}
230EXPORT_SYMBOL(strcmp); 229EXPORT_SYMBOL(strcmp);
@@ -237,16 +236,15 @@ EXPORT_SYMBOL(strcmp);
237 * @ct: Another string 236 * @ct: Another string
238 * @count: The maximum number of bytes to compare 237 * @count: The maximum number of bytes to compare
239 */ 238 */
240int strncmp(const char * cs,const char * ct,size_t count) 239int strncmp(const char *cs, const char *ct, size_t count)
241{ 240{
242 register signed char __res = 0; 241 signed char __res = 0;
243 242
244 while (count) { 243 while (count) {
245 if ((__res = *cs - *ct++) != 0 || !*cs++) 244 if ((__res = *cs - *ct++) != 0 || !*cs++)
246 break; 245 break;
247 count--; 246 count--;
248 } 247 }
249
250 return __res; 248 return __res;
251} 249}
252EXPORT_SYMBOL(strncmp); 250EXPORT_SYMBOL(strncmp);
@@ -258,12 +256,12 @@ EXPORT_SYMBOL(strncmp);
258 * @s: The string to be searched 256 * @s: The string to be searched
259 * @c: The character to search for 257 * @c: The character to search for
260 */ 258 */
261char * strchr(const char * s, int c) 259char *strchr(const char *s, int c)
262{ 260{
263 for(; *s != (char) c; ++s) 261 for (; *s != (char)c; ++s)
264 if (*s == '\0') 262 if (*s == '\0')
265 return NULL; 263 return NULL;
266 return (char *) s; 264 return (char *)s;
267} 265}
268EXPORT_SYMBOL(strchr); 266EXPORT_SYMBOL(strchr);
269#endif 267#endif
@@ -274,7 +272,7 @@ EXPORT_SYMBOL(strchr);
274 * @s: The string to be searched 272 * @s: The string to be searched
275 * @c: The character to search for 273 * @c: The character to search for
276 */ 274 */
277char * strrchr(const char * s, int c) 275char *strrchr(const char *s, int c)
278{ 276{
279 const char *p = s + strlen(s); 277 const char *p = s + strlen(s);
280 do { 278 do {
@@ -296,8 +294,8 @@ EXPORT_SYMBOL(strrchr);
296char *strnchr(const char *s, size_t count, int c) 294char *strnchr(const char *s, size_t count, int c)
297{ 295{
298 for (; count-- && *s != '\0'; ++s) 296 for (; count-- && *s != '\0'; ++s)
299 if (*s == (char) c) 297 if (*s == (char)c)
300 return (char *) s; 298 return (char *)s;
301 return NULL; 299 return NULL;
302} 300}
303EXPORT_SYMBOL(strnchr); 301EXPORT_SYMBOL(strnchr);
@@ -308,7 +306,7 @@ EXPORT_SYMBOL(strnchr);
308 * strlen - Find the length of a string 306 * strlen - Find the length of a string
309 * @s: The string to be sized 307 * @s: The string to be sized
310 */ 308 */
311size_t strlen(const char * s) 309size_t strlen(const char *s)
312{ 310{
313 const char *sc; 311 const char *sc;
314 312
@@ -325,7 +323,7 @@ EXPORT_SYMBOL(strlen);
325 * @s: The string to be sized 323 * @s: The string to be sized
326 * @count: The maximum number of bytes to search 324 * @count: The maximum number of bytes to search
327 */ 325 */
328size_t strnlen(const char * s, size_t count) 326size_t strnlen(const char *s, size_t count)
329{ 327{
330 const char *sc; 328 const char *sc;
331 329
@@ -358,7 +356,6 @@ size_t strspn(const char *s, const char *accept)
358 return count; 356 return count;
359 ++count; 357 ++count;
360 } 358 }
361
362 return count; 359 return count;
363} 360}
364 361
@@ -384,9 +381,8 @@ size_t strcspn(const char *s, const char *reject)
384 } 381 }
385 ++count; 382 ++count;
386 } 383 }
387
388 return count; 384 return count;
389} 385}
390EXPORT_SYMBOL(strcspn); 386EXPORT_SYMBOL(strcspn);
391 387
392#ifndef __HAVE_ARCH_STRPBRK 388#ifndef __HAVE_ARCH_STRPBRK
@@ -395,14 +391,14 @@ EXPORT_SYMBOL(strcspn);
395 * @cs: The string to be searched 391 * @cs: The string to be searched
396 * @ct: The characters to search for 392 * @ct: The characters to search for
397 */ 393 */
398char * strpbrk(const char * cs,const char * ct) 394char *strpbrk(const char *cs, const char *ct)
399{ 395{
400 const char *sc1,*sc2; 396 const char *sc1, *sc2;
401 397
402 for( sc1 = cs; *sc1 != '\0'; ++sc1) { 398 for (sc1 = cs; *sc1 != '\0'; ++sc1) {
403 for( sc2 = ct; *sc2 != '\0'; ++sc2) { 399 for (sc2 = ct; *sc2 != '\0'; ++sc2) {
404 if (*sc1 == *sc2) 400 if (*sc1 == *sc2)
405 return (char *) sc1; 401 return (char *)sc1;
406 } 402 }
407 } 403 }
408 return NULL; 404 return NULL;
@@ -422,9 +418,10 @@ EXPORT_SYMBOL(strpbrk);
422 * of that name. In fact, it was stolen from glibc2 and de-fancy-fied. 418 * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
423 * Same semantics, slimmer shape. ;) 419 * Same semantics, slimmer shape. ;)
424 */ 420 */
425char * strsep(char **s, const char *ct) 421char *strsep(char **s, const char *ct)
426{ 422{
427 char *sbegin = *s, *end; 423 char *sbegin = *s;
424 char *end;
428 425
429 if (sbegin == NULL) 426 if (sbegin == NULL)
430 return NULL; 427 return NULL;
@@ -433,10 +430,8 @@ char * strsep(char **s, const char *ct)
433 if (end) 430 if (end)
434 *end++ = '\0'; 431 *end++ = '\0';
435 *s = end; 432 *s = end;
436
437 return sbegin; 433 return sbegin;
438} 434}
439
440EXPORT_SYMBOL(strsep); 435EXPORT_SYMBOL(strsep);
441#endif 436#endif
442 437
@@ -449,13 +444,12 @@ EXPORT_SYMBOL(strsep);
449 * 444 *
450 * Do not use memset() to access IO space, use memset_io() instead. 445 * Do not use memset() to access IO space, use memset_io() instead.
451 */ 446 */
452void * memset(void * s,int c,size_t count) 447void *memset(void *s, int c, size_t count)
453{ 448{
454 char *xs = (char *) s; 449 char *xs = s;
455 450
456 while (count--) 451 while (count--)
457 *xs++ = c; 452 *xs++ = c;
458
459 return s; 453 return s;
460} 454}
461EXPORT_SYMBOL(memset); 455EXPORT_SYMBOL(memset);
@@ -471,13 +465,13 @@ EXPORT_SYMBOL(memset);
471 * You should not use this function to access IO space, use memcpy_toio() 465 * You should not use this function to access IO space, use memcpy_toio()
472 * or memcpy_fromio() instead. 466 * or memcpy_fromio() instead.
473 */ 467 */
474void * memcpy(void * dest,const void *src,size_t count) 468void *memcpy(void *dest, const void *src, size_t count)
475{ 469{
476 char *tmp = (char *) dest, *s = (char *) src; 470 char *tmp = dest;
471 char *s = src;
477 472
478 while (count--) 473 while (count--)
479 *tmp++ = *s++; 474 *tmp++ = *s++;
480
481 return dest; 475 return dest;
482} 476}
483EXPORT_SYMBOL(memcpy); 477EXPORT_SYMBOL(memcpy);
@@ -492,23 +486,24 @@ EXPORT_SYMBOL(memcpy);
492 * 486 *
493 * Unlike memcpy(), memmove() copes with overlapping areas. 487 * Unlike memcpy(), memmove() copes with overlapping areas.
494 */ 488 */
495void * memmove(void * dest,const void *src,size_t count) 489void *memmove(void *dest, const void *src, size_t count)
496{ 490{
497 char *tmp, *s; 491 char *tmp;
492 const char *s;
498 493
499 if (dest <= src) { 494 if (dest <= src) {
500 tmp = (char *) dest; 495 tmp = dest;
501 s = (char *) src; 496 s = src;
502 while (count--) 497 while (count--)
503 *tmp++ = *s++; 498 *tmp++ = *s++;
504 } 499 } else {
505 else { 500 tmp = dest;
506 tmp = (char *) dest + count; 501 tmp += count;
507 s = (char *) src + count; 502 s = src;
503 s += count;
508 while (count--) 504 while (count--)
509 *--tmp = *--s; 505 *--tmp = *--s;
510 } 506 }
511
512 return dest; 507 return dest;
513} 508}
514EXPORT_SYMBOL(memmove); 509EXPORT_SYMBOL(memmove);
@@ -522,12 +517,12 @@ EXPORT_SYMBOL(memmove);
522 * @count: The size of the area. 517 * @count: The size of the area.
523 */ 518 */
524#undef memcmp 519#undef memcmp
525int memcmp(const void * cs,const void * ct,size_t count) 520int memcmp(const void *cs, const void *ct, size_t count)
526{ 521{
527 const unsigned char *su1, *su2; 522 const unsigned char *su1, *su2;
528 int res = 0; 523 int res = 0;
529 524
530 for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--) 525 for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
531 if ((res = *su1 - *su2) != 0) 526 if ((res = *su1 - *su2) != 0)
532 break; 527 break;
533 return res; 528 return res;
@@ -545,17 +540,17 @@ EXPORT_SYMBOL(memcmp);
545 * returns the address of the first occurrence of @c, or 1 byte past 540 * returns the address of the first occurrence of @c, or 1 byte past
546 * the area if @c is not found 541 * the area if @c is not found
547 */ 542 */
548void * memscan(void * addr, int c, size_t size) 543void *memscan(void *addr, int c, size_t size)
549{ 544{
550 unsigned char * p = (unsigned char *) addr; 545 unsigned char *p = addr;
551 546
552 while (size) { 547 while (size) {
553 if (*p == c) 548 if (*p == c)
554 return (void *) p; 549 return (void *)p;
555 p++; 550 p++;
556 size--; 551 size--;
557 } 552 }
558 return (void *) p; 553 return (void *)p;
559} 554}
560EXPORT_SYMBOL(memscan); 555EXPORT_SYMBOL(memscan);
561#endif 556#endif
@@ -566,18 +561,18 @@ EXPORT_SYMBOL(memscan);
566 * @s1: The string to be searched 561 * @s1: The string to be searched
567 * @s2: The string to search for 562 * @s2: The string to search for
568 */ 563 */
569char * strstr(const char * s1,const char * s2) 564char *strstr(const char *s1, const char *s2)
570{ 565{
571 int l1, l2; 566 int l1, l2;
572 567
573 l2 = strlen(s2); 568 l2 = strlen(s2);
574 if (!l2) 569 if (!l2)
575 return (char *) s1; 570 return (char *)s1;
576 l1 = strlen(s1); 571 l1 = strlen(s1);
577 while (l1 >= l2) { 572 while (l1 >= l2) {
578 l1--; 573 l1--;
579 if (!memcmp(s1,s2,l2)) 574 if (!memcmp(s1, s2, l2))
580 return (char *) s1; 575 return (char *)s1;
581 s1++; 576 s1++;
582 } 577 }
583 return NULL; 578 return NULL;
@@ -600,7 +595,7 @@ void *memchr(const void *s, int c, size_t n)
600 const unsigned char *p = s; 595 const unsigned char *p = s;
601 while (n-- != 0) { 596 while (n-- != 0) {
602 if ((unsigned char)c == *p++) { 597 if ((unsigned char)c == *p++) {
603 return (void *)(p-1); 598 return (void *)(p - 1);
604 } 599 }
605 } 600 }
606 return NULL; 601 return NULL;
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 5bdeaaea57fd..57216f3544ca 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -433,7 +433,7 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size,
433 433
434void * 434void *
435swiotlb_alloc_coherent(struct device *hwdev, size_t size, 435swiotlb_alloc_coherent(struct device *hwdev, size_t size,
436 dma_addr_t *dma_handle, int flags) 436 dma_addr_t *dma_handle, gfp_t flags)
437{ 437{
438 unsigned long dev_addr; 438 unsigned long dev_addr;
439 void *ret; 439 void *ret;
diff --git a/lib/textsearch.c b/lib/textsearch.c
index 1e934c196f0f..6f3093efbd7b 100644
--- a/lib/textsearch.c
+++ b/lib/textsearch.c
@@ -254,7 +254,7 @@ unsigned int textsearch_find_continuous(struct ts_config *conf,
254 * parameters or a ERR_PTR(). 254 * parameters or a ERR_PTR().
255 */ 255 */
256struct ts_config *textsearch_prepare(const char *algo, const void *pattern, 256struct ts_config *textsearch_prepare(const char *algo, const void *pattern,
257 unsigned int len, int gfp_mask, int flags) 257 unsigned int len, gfp_t gfp_mask, int flags)
258{ 258{
259 int err = -ENOENT; 259 int err = -ENOENT;
260 struct ts_config *conf; 260 struct ts_config *conf;
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index e4e9031dd9c3..b07db5ca3f66 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -23,6 +23,7 @@
23#include <linux/ctype.h> 23#include <linux/ctype.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25 25
26#include <asm/page.h> /* for PAGE_SIZE */
26#include <asm/div64.h> 27#include <asm/div64.h>
27 28
28/** 29/**
diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c
index 3d94cb90c1d3..31b9e9054bf7 100644
--- a/lib/zlib_inflate/inflate.c
+++ b/lib/zlib_inflate/inflate.c
@@ -3,7 +3,6 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6#include <linux/module.h>
7#include <linux/zutil.h> 6#include <linux/zutil.h>
8#include "infblock.h" 7#include "infblock.h"
9#include "infutil.h" 8#include "infutil.h"