aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig5
-rw-r--r--lib/Kconfig.debug36
-rw-r--r--lib/Makefile5
-rw-r--r--lib/cpumask.c3
-rw-r--r--lib/devres.c26
-rw-r--r--lib/div64.c22
-rw-r--r--lib/fault-inject.c3
-rw-r--r--lib/inflate.c129
-rw-r--r--lib/iomap.c27
-rw-r--r--lib/kobject.c131
-rw-r--r--lib/kobject_uevent.c28
-rw-r--r--lib/kref.c2
-rw-r--r--lib/parser.c10
-rw-r--r--lib/radix-tree.c2
-rw-r--r--lib/reed_solomon/reed_solomon.c84
-rw-r--r--lib/string.c28
-rw-r--r--lib/swiotlb.c1
-rw-r--r--lib/vsprintf.c37
-rw-r--r--lib/zlib_inflate/inflate.c8
19 files changed, 398 insertions, 189 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index 91477b9dc924..2e7ae6b9215b 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -119,4 +119,9 @@ config HAS_IOPORT
119 depends on HAS_IOMEM && !NO_IOPORT 119 depends on HAS_IOMEM && !NO_IOPORT
120 default y 120 default y
121 121
122config HAS_DMA
123 boolean
124 depends on !NO_DMA
125 default y
126
122endmenu 127endmenu
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3f3e7403dcac..ee05b8a061b5 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -86,23 +86,6 @@ config DEBUG_SHIRQ
86 Drivers ought to be able to handle interrupts coming in at those 86 Drivers ought to be able to handle interrupts coming in at those
87 points; some don't and need to be caught. 87 points; some don't and need to be caught.
88 88
89config LOG_BUF_SHIFT
90 int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL
91 range 12 21
92 default 17 if S390 || LOCKDEP
93 default 16 if X86_NUMAQ || IA64
94 default 15 if SMP
95 default 14
96 help
97 Select kernel log buffer size as a power of 2.
98 Defaults and Examples:
99 17 => 128 KB for S/390
100 16 => 64 KB for x86 NUMAQ or IA-64
101 15 => 32 KB for SMP
102 14 => 16 KB for uniprocessor
103 13 => 8 KB
104 12 => 4 KB
105
106config DETECT_SOFTLOCKUP 89config DETECT_SOFTLOCKUP
107 bool "Detect Soft Lockups" 90 bool "Detect Soft Lockups"
108 depends on DEBUG_KERNEL && !S390 91 depends on DEBUG_KERNEL && !S390
@@ -201,6 +184,16 @@ config DEBUG_MUTEXES
201 This feature allows mutex semantics violations to be detected and 184 This feature allows mutex semantics violations to be detected and
202 reported. 185 reported.
203 186
187config DEBUG_SEMAPHORE
188 bool "Semaphore debugging"
189 depends on DEBUG_KERNEL
190 depends on ALPHA || FRV
191 default n
192 help
193 If you say Y here then semaphore processing will issue lots of
194 verbose debugging messages. If you suspect a semaphore problem or a
195 kernel hacker asks for this option then say Y. Otherwise say N.
196
204config DEBUG_LOCK_ALLOC 197config DEBUG_LOCK_ALLOC
205 bool "Lock debugging: detect incorrect freeing of live locks" 198 bool "Lock debugging: detect incorrect freeing of live locks"
206 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 199 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
@@ -261,7 +254,7 @@ config LOCKDEP
261 bool 254 bool
262 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 255 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
263 select STACKTRACE 256 select STACKTRACE
264 select FRAME_POINTER if !X86 257 select FRAME_POINTER if !X86 && !MIPS
265 select KALLSYMS 258 select KALLSYMS
266 select KALLSYMS_ALL 259 select KALLSYMS_ALL
267 260
@@ -320,7 +313,7 @@ config DEBUG_HIGHMEM
320config DEBUG_BUGVERBOSE 313config DEBUG_BUGVERBOSE
321 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED 314 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
322 depends on BUG 315 depends on BUG
323 depends on ARM || ARM26 || AVR32 || M32R || M68K || SPARC32 || SPARC64 || FRV || SUPERH || GENERIC_BUG 316 depends on ARM || ARM26 || AVR32 || M32R || M68K || SPARC32 || SPARC64 || FRV || SUPERH || GENERIC_BUG || BFIN
324 default !EMBEDDED 317 default !EMBEDDED
325 help 318 help
326 Say Y here to make BUG() panics output the file name and line number 319 Say Y here to make BUG() panics output the file name and line number
@@ -333,6 +326,9 @@ config DEBUG_INFO
333 help 326 help
334 If you say Y here the resulting kernel image will include 327 If you say Y here the resulting kernel image will include
335 debugging info resulting in a larger kernel image. 328 debugging info resulting in a larger kernel image.
329 This adds debug symbols to the kernel and modules (gcc -g), and
330 is needed if you intend to use kernel crashdump or binary object
331 tools like crash, kgdb, LKCD, gdb, etc on the kernel.
336 Say Y here only if you plan to debug the kernel. 332 Say Y here only if you plan to debug the kernel.
337 333
338 If unsure, say N. 334 If unsure, say N.
@@ -357,7 +353,7 @@ config DEBUG_LIST
357 353
358config FRAME_POINTER 354config FRAME_POINTER
359 bool "Compile the kernel with frame pointers" 355 bool "Compile the kernel with frame pointers"
360 depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32 || SUPERH) 356 depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32 || SUPERH || BFIN)
361 default y if DEBUG_INFO && UML 357 default y if DEBUG_INFO && UML
362 help 358 help
363 If you say Y here the resulting kernel image will be slightly larger 359 If you say Y here the resulting kernel image will be slightly larger
diff --git a/lib/Makefile b/lib/Makefile
index 2a9e47cc7f22..1f65b4613e09 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -4,7 +4,7 @@
4 4
5lib-y := ctype.o string.o vsprintf.o cmdline.o \ 5lib-y := ctype.o string.o vsprintf.o cmdline.o \
6 rbtree.o radix-tree.o dump_stack.o \ 6 rbtree.o radix-tree.o dump_stack.o \
7 idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \ 7 idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \
8 sha1.o irq_regs.o reciprocal_div.o 8 sha1.o irq_regs.o reciprocal_div.o
9 9
10lib-$(CONFIG_MMU) += ioremap.o 10lib-$(CONFIG_MMU) += ioremap.o
@@ -12,7 +12,8 @@ lib-$(CONFIG_SMP) += cpumask.o
12 12
13lib-y += kobject.o kref.o kobject_uevent.o klist.o 13lib-y += kobject.o kref.o kobject_uevent.o klist.o
14 14
15obj-y += sort.o parser.o halfmd4.o debug_locks.o random32.o bust_spinlocks.o 15obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
16 bust_spinlocks.o
16 17
17ifeq ($(CONFIG_DEBUG_KOBJECT),y) 18ifeq ($(CONFIG_DEBUG_KOBJECT),y)
18CFLAGS_kobject.o += -DDEBUG 19CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 1ea2c184315d..bb4f76d3c3e7 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -15,9 +15,6 @@ int __next_cpu(int n, const cpumask_t *srcp)
15} 15}
16EXPORT_SYMBOL(__next_cpu); 16EXPORT_SYMBOL(__next_cpu);
17 17
18int nr_cpu_ids;
19EXPORT_SYMBOL(nr_cpu_ids);
20
21int __any_online_cpu(const cpumask_t *mask) 18int __any_online_cpu(const cpumask_t *mask)
22{ 19{
23 int cpu; 20 int cpu;
diff --git a/lib/devres.c b/lib/devres.c
index eb38849aa717..b1d336ce7f3d 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -296,5 +296,31 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
296 return rc; 296 return rc;
297} 297}
298EXPORT_SYMBOL(pcim_iomap_regions); 298EXPORT_SYMBOL(pcim_iomap_regions);
299
300/**
301 * pcim_iounmap_regions - Unmap and release PCI BARs
302 * @pdev: PCI device to map IO resources for
303 * @mask: Mask of BARs to unmap and release
304 *
305 * Unamp and release regions specified by @mask.
306 */
307void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask)
308{
309 void __iomem * const *iomap;
310 int i;
311
312 iomap = pcim_iomap_table(pdev);
313 if (!iomap)
314 return;
315
316 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
317 if (!(mask & (1 << i)))
318 continue;
319
320 pcim_iounmap(pdev, iomap[i]);
321 pci_release_region(pdev, i);
322 }
323}
324EXPORT_SYMBOL(pcim_iounmap_regions);
299#endif 325#endif
300#endif 326#endif
diff --git a/lib/div64.c b/lib/div64.c
index 365719f84832..b71cf93c529a 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -23,7 +23,7 @@
23/* Not needed on 64bit architectures */ 23/* Not needed on 64bit architectures */
24#if BITS_PER_LONG == 32 24#if BITS_PER_LONG == 32
25 25
26uint32_t __div64_32(uint64_t *n, uint32_t base) 26uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
27{ 27{
28 uint64_t rem = *n; 28 uint64_t rem = *n;
29 uint64_t b = base; 29 uint64_t b = base;
@@ -58,4 +58,24 @@ uint32_t __div64_32(uint64_t *n, uint32_t base)
58 58
59EXPORT_SYMBOL(__div64_32); 59EXPORT_SYMBOL(__div64_32);
60 60
61/* 64bit divisor, dividend and result. dynamic precision */
62uint64_t div64_64(uint64_t dividend, uint64_t divisor)
63{
64 uint32_t high, d;
65
66 high = divisor >> 32;
67 if (high) {
68 unsigned int shift = fls(high);
69
70 d = divisor >> shift;
71 dividend >>= shift;
72 } else
73 d = divisor;
74
75 do_div(dividend, d);
76
77 return dividend;
78}
79EXPORT_SYMBOL(div64_64);
80
61#endif /* BITS_PER_LONG == 32 */ 81#endif /* BITS_PER_LONG == 32 */
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index 0fabd12c39d7..b18fc2ff9ffe 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -72,9 +72,8 @@ static bool fail_stacktrace(struct fault_attr *attr)
72 trace.entries = entries; 72 trace.entries = entries;
73 trace.max_entries = depth; 73 trace.max_entries = depth;
74 trace.skip = 1; 74 trace.skip = 1;
75 trace.all_contexts = 0;
76 75
77 save_stack_trace(&trace, NULL); 76 save_stack_trace(&trace);
78 for (n = 0; n < trace.nr_entries; n++) { 77 for (n = 0; n < trace.nr_entries; n++) {
79 if (attr->reject_start <= entries[n] && 78 if (attr->reject_start <= entries[n] &&
80 entries[n] < attr->reject_end) 79 entries[n] < attr->reject_end)
diff --git a/lib/inflate.c b/lib/inflate.c
index 6db6e98d1637..845f91d3ac12 100644
--- a/lib/inflate.c
+++ b/lib/inflate.c
@@ -292,7 +292,6 @@ STATIC int INIT huft_build(
292 oversubscribed set of lengths), and three if not enough memory. */ 292 oversubscribed set of lengths), and three if not enough memory. */
293{ 293{
294 unsigned a; /* counter for codes of length k */ 294 unsigned a; /* counter for codes of length k */
295 unsigned c[BMAX+1]; /* bit length count table */
296 unsigned f; /* i repeats in table every f entries */ 295 unsigned f; /* i repeats in table every f entries */
297 int g; /* maximum code length */ 296 int g; /* maximum code length */
298 int h; /* table level */ 297 int h; /* table level */
@@ -303,18 +302,33 @@ STATIC int INIT huft_build(
303 register unsigned *p; /* pointer into c[], b[], or v[] */ 302 register unsigned *p; /* pointer into c[], b[], or v[] */
304 register struct huft *q; /* points to current table */ 303 register struct huft *q; /* points to current table */
305 struct huft r; /* table entry for structure assignment */ 304 struct huft r; /* table entry for structure assignment */
306 struct huft *u[BMAX]; /* table stack */
307 unsigned v[N_MAX]; /* values in order of bit length */
308 register int w; /* bits before this table == (l * h) */ 305 register int w; /* bits before this table == (l * h) */
309 unsigned x[BMAX+1]; /* bit offsets, then code stack */
310 unsigned *xp; /* pointer into x */ 306 unsigned *xp; /* pointer into x */
311 int y; /* number of dummy codes added */ 307 int y; /* number of dummy codes added */
312 unsigned z; /* number of entries in current table */ 308 unsigned z; /* number of entries in current table */
309 struct {
310 unsigned c[BMAX+1]; /* bit length count table */
311 struct huft *u[BMAX]; /* table stack */
312 unsigned v[N_MAX]; /* values in order of bit length */
313 unsigned x[BMAX+1]; /* bit offsets, then code stack */
314 } *stk;
315 unsigned *c, *v, *x;
316 struct huft **u;
317 int ret;
313 318
314DEBG("huft1 "); 319DEBG("huft1 ");
315 320
321 stk = malloc(sizeof(*stk));
322 if (stk == NULL)
323 return 3; /* out of memory */
324
325 c = stk->c;
326 v = stk->v;
327 x = stk->x;
328 u = stk->u;
329
316 /* Generate counts for each bit length */ 330 /* Generate counts for each bit length */
317 memzero(c, sizeof(c)); 331 memzero(stk->c, sizeof(stk->c));
318 p = b; i = n; 332 p = b; i = n;
319 do { 333 do {
320 Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"), 334 Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"),
@@ -326,7 +340,8 @@ DEBG("huft1 ");
326 { 340 {
327 *t = (struct huft *)NULL; 341 *t = (struct huft *)NULL;
328 *m = 0; 342 *m = 0;
329 return 2; 343 ret = 2;
344 goto out;
330 } 345 }
331 346
332DEBG("huft2 "); 347DEBG("huft2 ");
@@ -351,10 +366,14 @@ DEBG("huft3 ");
351 366
352 /* Adjust last length count to fill out codes, if needed */ 367 /* Adjust last length count to fill out codes, if needed */
353 for (y = 1 << j; j < i; j++, y <<= 1) 368 for (y = 1 << j; j < i; j++, y <<= 1)
354 if ((y -= c[j]) < 0) 369 if ((y -= c[j]) < 0) {
355 return 2; /* bad input: more codes than bits */ 370 ret = 2; /* bad input: more codes than bits */
356 if ((y -= c[i]) < 0) 371 goto out;
357 return 2; 372 }
373 if ((y -= c[i]) < 0) {
374 ret = 2;
375 goto out;
376 }
358 c[i] += y; 377 c[i] += y;
359 378
360DEBG("huft4 "); 379DEBG("huft4 ");
@@ -428,7 +447,8 @@ DEBG1("3 ");
428 { 447 {
429 if (h) 448 if (h)
430 huft_free(u[0]); 449 huft_free(u[0]);
431 return 3; /* not enough memory */ 450 ret = 3; /* not enough memory */
451 goto out;
432 } 452 }
433DEBG1("4 "); 453DEBG1("4 ");
434 hufts += z + 1; /* track memory usage */ 454 hufts += z + 1; /* track memory usage */
@@ -492,7 +512,11 @@ DEBG("h6f ");
492DEBG("huft7 "); 512DEBG("huft7 ");
493 513
494 /* Return true (1) if we were given an incomplete table */ 514 /* Return true (1) if we were given an incomplete table */
495 return y != 0 && g != 1; 515 ret = y != 0 && g != 1;
516
517 out:
518 free(stk);
519 return ret;
496} 520}
497 521
498 522
@@ -705,10 +729,14 @@ STATIC int noinline INIT inflate_fixed(void)
705 struct huft *td; /* distance code table */ 729 struct huft *td; /* distance code table */
706 int bl; /* lookup bits for tl */ 730 int bl; /* lookup bits for tl */
707 int bd; /* lookup bits for td */ 731 int bd; /* lookup bits for td */
708 unsigned l[288]; /* length list for huft_build */ 732 unsigned *l; /* length list for huft_build */
709 733
710DEBG("<fix"); 734DEBG("<fix");
711 735
736 l = malloc(sizeof(*l) * 288);
737 if (l == NULL)
738 return 3; /* out of memory */
739
712 /* set up literal table */ 740 /* set up literal table */
713 for (i = 0; i < 144; i++) 741 for (i = 0; i < 144; i++)
714 l[i] = 8; 742 l[i] = 8;
@@ -719,9 +747,10 @@ DEBG("<fix");
719 for (; i < 288; i++) /* make a complete, but wrong code set */ 747 for (; i < 288; i++) /* make a complete, but wrong code set */
720 l[i] = 8; 748 l[i] = 8;
721 bl = 7; 749 bl = 7;
722 if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) 750 if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) {
751 free(l);
723 return i; 752 return i;
724 753 }
725 754
726 /* set up distance table */ 755 /* set up distance table */
727 for (i = 0; i < 30; i++) /* make an incomplete code set */ 756 for (i = 0; i < 30; i++) /* make an incomplete code set */
@@ -730,6 +759,7 @@ DEBG("<fix");
730 if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1) 759 if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1)
731 { 760 {
732 huft_free(tl); 761 huft_free(tl);
762 free(l);
733 763
734 DEBG(">"); 764 DEBG(">");
735 return i; 765 return i;
@@ -737,11 +767,13 @@ DEBG("<fix");
737 767
738 768
739 /* decompress until an end-of-block code */ 769 /* decompress until an end-of-block code */
740 if (inflate_codes(tl, td, bl, bd)) 770 if (inflate_codes(tl, td, bl, bd)) {
771 free(l);
741 return 1; 772 return 1;
742 773 }
743 774
744 /* free the decoding tables, return */ 775 /* free the decoding tables, return */
776 free(l);
745 huft_free(tl); 777 huft_free(tl);
746 huft_free(td); 778 huft_free(td);
747 return 0; 779 return 0;
@@ -766,16 +798,19 @@ STATIC int noinline INIT inflate_dynamic(void)
766 unsigned nb; /* number of bit length codes */ 798 unsigned nb; /* number of bit length codes */
767 unsigned nl; /* number of literal/length codes */ 799 unsigned nl; /* number of literal/length codes */
768 unsigned nd; /* number of distance codes */ 800 unsigned nd; /* number of distance codes */
769#ifdef PKZIP_BUG_WORKAROUND 801 unsigned *ll; /* literal/length and distance code lengths */
770 unsigned ll[288+32]; /* literal/length and distance code lengths */
771#else
772 unsigned ll[286+30]; /* literal/length and distance code lengths */
773#endif
774 register ulg b; /* bit buffer */ 802 register ulg b; /* bit buffer */
775 register unsigned k; /* number of bits in bit buffer */ 803 register unsigned k; /* number of bits in bit buffer */
804 int ret;
776 805
777DEBG("<dyn"); 806DEBG("<dyn");
778 807
808#ifdef PKZIP_BUG_WORKAROUND
809 ll = malloc(sizeof(*ll) * (288+32)); /* literal/length and distance code lengths */
810#else
811 ll = malloc(sizeof(*ll) * (286+30)); /* literal/length and distance code lengths */
812#endif
813
779 /* make local bit buffer */ 814 /* make local bit buffer */
780 b = bb; 815 b = bb;
781 k = bk; 816 k = bk;
@@ -796,7 +831,10 @@ DEBG("<dyn");
796#else 831#else
797 if (nl > 286 || nd > 30) 832 if (nl > 286 || nd > 30)
798#endif 833#endif
799 return 1; /* bad lengths */ 834 {
835 ret = 1; /* bad lengths */
836 goto out;
837 }
800 838
801DEBG("dyn1 "); 839DEBG("dyn1 ");
802 840
@@ -818,7 +856,8 @@ DEBG("dyn2 ");
818 { 856 {
819 if (i == 1) 857 if (i == 1)
820 huft_free(tl); 858 huft_free(tl);
821 return i; /* incomplete code set */ 859 ret = i; /* incomplete code set */
860 goto out;
822 } 861 }
823 862
824DEBG("dyn3 "); 863DEBG("dyn3 ");
@@ -840,8 +879,10 @@ DEBG("dyn3 ");
840 NEEDBITS(2) 879 NEEDBITS(2)
841 j = 3 + ((unsigned)b & 3); 880 j = 3 + ((unsigned)b & 3);
842 DUMPBITS(2) 881 DUMPBITS(2)
843 if ((unsigned)i + j > n) 882 if ((unsigned)i + j > n) {
844 return 1; 883 ret = 1;
884 goto out;
885 }
845 while (j--) 886 while (j--)
846 ll[i++] = l; 887 ll[i++] = l;
847 } 888 }
@@ -850,8 +891,10 @@ DEBG("dyn3 ");
850 NEEDBITS(3) 891 NEEDBITS(3)
851 j = 3 + ((unsigned)b & 7); 892 j = 3 + ((unsigned)b & 7);
852 DUMPBITS(3) 893 DUMPBITS(3)
853 if ((unsigned)i + j > n) 894 if ((unsigned)i + j > n) {
854 return 1; 895 ret = 1;
896 goto out;
897 }
855 while (j--) 898 while (j--)
856 ll[i++] = 0; 899 ll[i++] = 0;
857 l = 0; 900 l = 0;
@@ -861,8 +904,10 @@ DEBG("dyn3 ");
861 NEEDBITS(7) 904 NEEDBITS(7)
862 j = 11 + ((unsigned)b & 0x7f); 905 j = 11 + ((unsigned)b & 0x7f);
863 DUMPBITS(7) 906 DUMPBITS(7)
864 if ((unsigned)i + j > n) 907 if ((unsigned)i + j > n) {
865 return 1; 908 ret = 1;
909 goto out;
910 }
866 while (j--) 911 while (j--)
867 ll[i++] = 0; 912 ll[i++] = 0;
868 l = 0; 913 l = 0;
@@ -891,7 +936,8 @@ DEBG("dyn5b ");
891 error("incomplete literal tree"); 936 error("incomplete literal tree");
892 huft_free(tl); 937 huft_free(tl);
893 } 938 }
894 return i; /* incomplete code set */ 939 ret = i; /* incomplete code set */
940 goto out;
895 } 941 }
896DEBG("dyn5c "); 942DEBG("dyn5c ");
897 bd = dbits; 943 bd = dbits;
@@ -907,15 +953,18 @@ DEBG("dyn5d ");
907 huft_free(td); 953 huft_free(td);
908 } 954 }
909 huft_free(tl); 955 huft_free(tl);
910 return i; /* incomplete code set */ 956 ret = i; /* incomplete code set */
957 goto out;
911#endif 958#endif
912 } 959 }
913 960
914DEBG("dyn6 "); 961DEBG("dyn6 ");
915 962
916 /* decompress until an end-of-block code */ 963 /* decompress until an end-of-block code */
917 if (inflate_codes(tl, td, bl, bd)) 964 if (inflate_codes(tl, td, bl, bd)) {
918 return 1; 965 ret = 1;
966 goto out;
967 }
919 968
920DEBG("dyn7 "); 969DEBG("dyn7 ");
921 970
@@ -924,10 +973,14 @@ DEBG("dyn7 ");
924 huft_free(td); 973 huft_free(td);
925 974
926 DEBG(">"); 975 DEBG(">");
927 return 0; 976 ret = 0;
928 977out:
929 underrun: 978 free(ll);
930 return 4; /* Input underrun */ 979 return ret;
980
981underrun:
982 ret = 4; /* Input underrun */
983 goto out;
931} 984}
932 985
933 986
diff --git a/lib/iomap.c b/lib/iomap.c
index 4d43f37c0154..a57d262a5ed9 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -35,20 +35,28 @@
35#define PIO_RESERVED 0x40000UL 35#define PIO_RESERVED 0x40000UL
36#endif 36#endif
37 37
38static void bad_io_access(unsigned long port, const char *access)
39{
40 static int count = 10;
41 if (count) {
42 count--;
43 printk(KERN_ERR "Bad IO access at port %lx (%s)\n", port, access);
44 WARN_ON(1);
45 }
46}
47
38/* 48/*
39 * Ugly macros are a way of life. 49 * Ugly macros are a way of life.
40 */ 50 */
41#define VERIFY_PIO(port) BUG_ON((port & ~PIO_MASK) != PIO_OFFSET)
42
43#define IO_COND(addr, is_pio, is_mmio) do { \ 51#define IO_COND(addr, is_pio, is_mmio) do { \
44 unsigned long port = (unsigned long __force)addr; \ 52 unsigned long port = (unsigned long __force)addr; \
45 if (port < PIO_RESERVED) { \ 53 if (port >= PIO_RESERVED) { \
46 VERIFY_PIO(port); \ 54 is_mmio; \
55 } else if (port > PIO_OFFSET) { \
47 port &= PIO_MASK; \ 56 port &= PIO_MASK; \
48 is_pio; \ 57 is_pio; \
49 } else { \ 58 } else \
50 is_mmio; \ 59 bad_io_access(port, #is_pio ); \
51 } \
52} while (0) 60} while (0)
53 61
54#ifndef pio_read16be 62#ifndef pio_read16be
@@ -64,22 +72,27 @@
64unsigned int fastcall ioread8(void __iomem *addr) 72unsigned int fastcall ioread8(void __iomem *addr)
65{ 73{
66 IO_COND(addr, return inb(port), return readb(addr)); 74 IO_COND(addr, return inb(port), return readb(addr));
75 return 0xff;
67} 76}
68unsigned int fastcall ioread16(void __iomem *addr) 77unsigned int fastcall ioread16(void __iomem *addr)
69{ 78{
70 IO_COND(addr, return inw(port), return readw(addr)); 79 IO_COND(addr, return inw(port), return readw(addr));
80 return 0xffff;
71} 81}
72unsigned int fastcall ioread16be(void __iomem *addr) 82unsigned int fastcall ioread16be(void __iomem *addr)
73{ 83{
74 IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr)); 84 IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr));
85 return 0xffff;
75} 86}
76unsigned int fastcall ioread32(void __iomem *addr) 87unsigned int fastcall ioread32(void __iomem *addr)
77{ 88{
78 IO_COND(addr, return inl(port), return readl(addr)); 89 IO_COND(addr, return inl(port), return readl(addr));
90 return 0xffffffff;
79} 91}
80unsigned int fastcall ioread32be(void __iomem *addr) 92unsigned int fastcall ioread32be(void __iomem *addr)
81{ 93{
82 IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr)); 94 IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr));
95 return 0xffffffff;
83} 96}
84EXPORT_SYMBOL(ioread8); 97EXPORT_SYMBOL(ioread8);
85EXPORT_SYMBOL(ioread16); 98EXPORT_SYMBOL(ioread16);
diff --git a/lib/kobject.c b/lib/kobject.c
index f4f6176dcd12..fc5f3f6e7329 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -157,7 +157,7 @@ static void unlink(struct kobject * kobj)
157} 157}
158 158
159/** 159/**
160 * kobject_add - add an object to the hierarchy. 160 * kobject_shadow_add - add an object to the hierarchy.
161 * @kobj: object. 161 * @kobj: object.
162 * @shadow_parent: sysfs directory to add to. 162 * @shadow_parent: sysfs directory to add to.
163 */ 163 */
@@ -174,6 +174,7 @@ int kobject_shadow_add(struct kobject * kobj, struct dentry *shadow_parent)
174 if (!*kobj->k_name) { 174 if (!*kobj->k_name) {
175 pr_debug("kobject attempted to be registered with no name!\n"); 175 pr_debug("kobject attempted to be registered with no name!\n");
176 WARN_ON(1); 176 WARN_ON(1);
177 kobject_put(kobj);
177 return -EINVAL; 178 return -EINVAL;
178 } 179 }
179 parent = kobject_get(kobj->parent); 180 parent = kobject_get(kobj->parent);
@@ -190,8 +191,8 @@ int kobject_shadow_add(struct kobject * kobj, struct dentry *shadow_parent)
190 191
191 list_add_tail(&kobj->entry,&kobj->kset->list); 192 list_add_tail(&kobj->entry,&kobj->kset->list);
192 spin_unlock(&kobj->kset->list_lock); 193 spin_unlock(&kobj->kset->list_lock);
194 kobj->parent = parent;
193 } 195 }
194 kobj->parent = parent;
195 196
196 error = create_dir(kobj, shadow_parent); 197 error = create_dir(kobj, shadow_parent);
197 if (error) { 198 if (error) {
@@ -311,13 +312,43 @@ EXPORT_SYMBOL(kobject_set_name);
311int kobject_rename(struct kobject * kobj, const char *new_name) 312int kobject_rename(struct kobject * kobj, const char *new_name)
312{ 313{
313 int error = 0; 314 int error = 0;
315 const char *devpath = NULL;
316 char *devpath_string = NULL;
317 char *envp[2];
314 318
315 kobj = kobject_get(kobj); 319 kobj = kobject_get(kobj);
316 if (!kobj) 320 if (!kobj)
317 return -EINVAL; 321 return -EINVAL;
318 if (!kobj->parent) 322 if (!kobj->parent)
319 return -EINVAL; 323 return -EINVAL;
324
325 devpath = kobject_get_path(kobj, GFP_KERNEL);
326 if (!devpath) {
327 error = -ENOMEM;
328 goto out;
329 }
330 devpath_string = kmalloc(strlen(devpath) + 15, GFP_KERNEL);
331 if (!devpath_string) {
332 error = -ENOMEM;
333 goto out;
334 }
335 sprintf(devpath_string, "DEVPATH_OLD=%s", devpath);
336 envp[0] = devpath_string;
337 envp[1] = NULL;
338 /* Note : if we want to send the new name alone, not the full path,
339 * we could probably use kobject_name(kobj); */
340
320 error = sysfs_rename_dir(kobj, kobj->parent->dentry, new_name); 341 error = sysfs_rename_dir(kobj, kobj->parent->dentry, new_name);
342
343 /* This function is mostly/only used for network interface.
344 * Some hotplug package track interfaces by their name and
345 * therefore want to know when the name is changed by the user. */
346 if (!error)
347 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
348
349out:
350 kfree(devpath_string);
351 kfree(devpath);
321 kobject_put(kobj); 352 kobject_put(kobj);
322 353
323 return error; 354 return error;
@@ -385,9 +416,11 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
385 goto out; 416 goto out;
386 old_parent = kobj->parent; 417 old_parent = kobj->parent;
387 kobj->parent = new_parent; 418 kobj->parent = new_parent;
419 new_parent = NULL;
388 kobject_put(old_parent); 420 kobject_put(old_parent);
389 kobject_uevent_env(kobj, KOBJ_MOVE, envp); 421 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
390out: 422out:
423 kobject_put(new_parent);
391 kobject_put(kobj); 424 kobject_put(kobj);
392 kfree(devpath_string); 425 kfree(devpath_string);
393 kfree(devpath); 426 kfree(devpath);
@@ -486,13 +519,15 @@ static struct kobj_type dir_ktype = {
486}; 519};
487 520
488/** 521/**
489 * kobject_add_dir - add sub directory of object. 522 * kobject_kset_add_dir - add sub directory of object.
523 * @kset: kset the directory is belongs to.
490 * @parent: object in which a directory is created. 524 * @parent: object in which a directory is created.
491 * @name: directory name. 525 * @name: directory name.
492 * 526 *
493 * Add a plain directory object as child of given object. 527 * Add a plain directory object as child of given object.
494 */ 528 */
495struct kobject *kobject_add_dir(struct kobject *parent, const char *name) 529struct kobject *kobject_kset_add_dir(struct kset *kset,
530 struct kobject *parent, const char *name)
496{ 531{
497 struct kobject *k; 532 struct kobject *k;
498 int ret; 533 int ret;
@@ -504,13 +539,14 @@ struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
504 if (!k) 539 if (!k)
505 return NULL; 540 return NULL;
506 541
542 k->kset = kset;
507 k->parent = parent; 543 k->parent = parent;
508 k->ktype = &dir_ktype; 544 k->ktype = &dir_ktype;
509 kobject_set_name(k, name); 545 kobject_set_name(k, name);
510 ret = kobject_register(k); 546 ret = kobject_register(k);
511 if (ret < 0) { 547 if (ret < 0) {
512 printk(KERN_WARNING "kobject_add_dir: " 548 printk(KERN_WARNING "%s: kobject_register error: %d\n",
513 "kobject_register error: %d\n", ret); 549 __func__, ret);
514 kobject_del(k); 550 kobject_del(k);
515 return NULL; 551 return NULL;
516 } 552 }
@@ -519,6 +555,18 @@ struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
519} 555}
520 556
521/** 557/**
558 * kobject_add_dir - add sub directory of object.
559 * @parent: object in which a directory is created.
560 * @name: directory name.
561 *
562 * Add a plain directory object as child of given object.
563 */
564struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
565{
566 return kobject_kset_add_dir(NULL, parent, name);
567}
568
569/**
522 * kset_init - initialize a kset for use 570 * kset_init - initialize a kset for use
523 * @k: kset 571 * @k: kset
524 */ 572 */
@@ -534,22 +582,10 @@ void kset_init(struct kset * k)
534/** 582/**
535 * kset_add - add a kset object to the hierarchy. 583 * kset_add - add a kset object to the hierarchy.
536 * @k: kset. 584 * @k: kset.
537 *
538 * Simply, this adds the kset's embedded kobject to the
539 * hierarchy.
540 * We also try to make sure that the kset's embedded kobject
541 * has a parent before it is added. We only care if the embedded
542 * kobject is not part of a kset itself, since kobject_add()
543 * assigns a parent in that case.
544 * If that is the case, and the kset has a controlling subsystem,
545 * then we set the kset's parent to be said subsystem.
546 */ 585 */
547 586
548int kset_add(struct kset * k) 587int kset_add(struct kset * k)
549{ 588{
550 if (!k->kobj.parent && !k->kobj.kset && k->subsys)
551 k->kobj.parent = &k->subsys->kset.kobj;
552
553 return kobject_add(&k->kobj); 589 return kobject_add(&k->kobj);
554} 590}
555 591
@@ -608,55 +644,28 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name)
608 return ret; 644 return ret;
609} 645}
610 646
611 647void subsystem_init(struct kset *s)
612void subsystem_init(struct subsystem * s)
613{ 648{
614 init_rwsem(&s->rwsem); 649 kset_init(s);
615 kset_init(&s->kset);
616} 650}
617 651
618/** 652int subsystem_register(struct kset *s)
619 * subsystem_register - register a subsystem.
620 * @s: the subsystem we're registering.
621 *
622 * Once we register the subsystem, we want to make sure that
623 * the kset points back to this subsystem for correct usage of
624 * the rwsem.
625 */
626
627int subsystem_register(struct subsystem * s)
628{ 653{
629 int error; 654 return kset_register(s);
630
631 if (!s)
632 return -EINVAL;
633
634 subsystem_init(s);
635 pr_debug("subsystem %s: registering\n",s->kset.kobj.name);
636
637 if (!(error = kset_add(&s->kset))) {
638 if (!s->kset.subsys)
639 s->kset.subsys = s;
640 }
641 return error;
642} 655}
643 656
644void subsystem_unregister(struct subsystem * s) 657void subsystem_unregister(struct kset *s)
645{ 658{
646 if (!s) 659 kset_unregister(s);
647 return;
648 pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name);
649 kset_unregister(&s->kset);
650} 660}
651 661
652
653/** 662/**
654 * subsystem_create_file - export sysfs attribute file. 663 * subsystem_create_file - export sysfs attribute file.
655 * @s: subsystem. 664 * @s: subsystem.
656 * @a: subsystem attribute descriptor. 665 * @a: subsystem attribute descriptor.
657 */ 666 */
658 667
659int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) 668int subsys_create_file(struct kset *s, struct subsys_attribute *a)
660{ 669{
661 int error = 0; 670 int error = 0;
662 671
@@ -664,28 +673,12 @@ int subsys_create_file(struct subsystem * s, struct subsys_attribute * a)
664 return -EINVAL; 673 return -EINVAL;
665 674
666 if (subsys_get(s)) { 675 if (subsys_get(s)) {
667 error = sysfs_create_file(&s->kset.kobj,&a->attr); 676 error = sysfs_create_file(&s->kobj, &a->attr);
668 subsys_put(s); 677 subsys_put(s);
669 } 678 }
670 return error; 679 return error;
671} 680}
672 681
673
674/**
675 * subsystem_remove_file - remove sysfs attribute file.
676 * @s: subsystem.
677 * @a: attribute desciptor.
678 */
679#if 0
680void subsys_remove_file(struct subsystem * s, struct subsys_attribute * a)
681{
682 if (subsys_get(s)) {
683 sysfs_remove_file(&s->kset.kobj,&a->attr);
684 subsys_put(s);
685 }
686}
687#endif /* 0 */
688
689EXPORT_SYMBOL(kobject_init); 682EXPORT_SYMBOL(kobject_init);
690EXPORT_SYMBOL(kobject_register); 683EXPORT_SYMBOL(kobject_register);
691EXPORT_SYMBOL(kobject_unregister); 684EXPORT_SYMBOL(kobject_unregister);
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 84272ed77f03..12e311dc664c 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -42,10 +42,6 @@ static char *action_to_string(enum kobject_action action)
42 return "remove"; 42 return "remove";
43 case KOBJ_CHANGE: 43 case KOBJ_CHANGE:
44 return "change"; 44 return "change";
45 case KOBJ_MOUNT:
46 return "mount";
47 case KOBJ_UMOUNT:
48 return "umount";
49 case KOBJ_OFFLINE: 45 case KOBJ_OFFLINE:
50 return "offline"; 46 return "offline";
51 case KOBJ_ONLINE: 47 case KOBJ_ONLINE:
@@ -95,10 +91,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
95 91
96 /* search the kset we belong to */ 92 /* search the kset we belong to */
97 top_kobj = kobj; 93 top_kobj = kobj;
98 if (!top_kobj->kset && top_kobj->parent) { 94 while (!top_kobj->kset && top_kobj->parent) {
99 do { 95 top_kobj = top_kobj->parent;
100 top_kobj = top_kobj->parent;
101 } while (!top_kobj->kset && top_kobj->parent);
102 } 96 }
103 if (!top_kobj->kset) { 97 if (!top_kobj->kset) {
104 pr_debug("kobject attempted to send uevent without kset!\n"); 98 pr_debug("kobject attempted to send uevent without kset!\n");
@@ -115,6 +109,16 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
115 return 0; 109 return 0;
116 } 110 }
117 111
112 /* originating subsystem */
113 if (uevent_ops && uevent_ops->name)
114 subsystem = uevent_ops->name(kset, kobj);
115 else
116 subsystem = kobject_name(&kset->kobj);
117 if (!subsystem) {
118 pr_debug("unset subsytem caused the event to drop!\n");
119 return 0;
120 }
121
118 /* environment index */ 122 /* environment index */
119 envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); 123 envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL);
120 if (!envp) 124 if (!envp)
@@ -134,12 +138,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
134 goto exit; 138 goto exit;
135 } 139 }
136 140
137 /* originating subsystem */
138 if (uevent_ops && uevent_ops->name)
139 subsystem = uevent_ops->name(kset, kobj);
140 else
141 subsystem = kobject_name(&kset->kobj);
142
143 /* event environemnt for helper process only */ 141 /* event environemnt for helper process only */
144 envp[i++] = "HOME=/"; 142 envp[i++] = "HOME=/";
145 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 143 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
@@ -293,7 +291,7 @@ EXPORT_SYMBOL_GPL(add_uevent_var);
293static int __init kobject_uevent_init(void) 291static int __init kobject_uevent_init(void)
294{ 292{
295 uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL, 293 uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL,
296 THIS_MODULE); 294 NULL, THIS_MODULE);
297 295
298 if (!uevent_sock) { 296 if (!uevent_sock) {
299 printk(KERN_ERR 297 printk(KERN_ERR
diff --git a/lib/kref.c b/lib/kref.c
index 0d07cc31c818..a6dc3ec328e0 100644
--- a/lib/kref.c
+++ b/lib/kref.c
@@ -21,6 +21,7 @@
21void kref_init(struct kref *kref) 21void kref_init(struct kref *kref)
22{ 22{
23 atomic_set(&kref->refcount,1); 23 atomic_set(&kref->refcount,1);
24 smp_mb();
24} 25}
25 26
26/** 27/**
@@ -31,6 +32,7 @@ void kref_get(struct kref *kref)
31{ 32{
32 WARN_ON(!atomic_read(&kref->refcount)); 33 WARN_ON(!atomic_read(&kref->refcount));
33 atomic_inc(&kref->refcount); 34 atomic_inc(&kref->refcount);
35 smp_mb__after_atomic_inc();
34} 36}
35 37
36/** 38/**
diff --git a/lib/parser.c b/lib/parser.c
index 7ad2a48abc5e..703c8c13b346 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -22,7 +22,7 @@
22 * match extremely simple token=arg style patterns. If the pattern is found, 22 * match extremely simple token=arg style patterns. If the pattern is found,
23 * the location(s) of the arguments will be returned in the @args array. 23 * the location(s) of the arguments will be returned in the @args array.
24 */ 24 */
25static int match_one(char *s, char *p, substring_t args[]) 25static int match_one(char *s, const char *p, substring_t args[])
26{ 26{
27 char *meta; 27 char *meta;
28 int argc = 0; 28 int argc = 0;
@@ -43,7 +43,7 @@ static int match_one(char *s, char *p, substring_t args[])
43 p = meta + 1; 43 p = meta + 1;
44 44
45 if (isdigit(*p)) 45 if (isdigit(*p))
46 len = simple_strtoul(p, &p, 10); 46 len = simple_strtoul(p, (char **) &p, 10);
47 else if (*p == '%') { 47 else if (*p == '%') {
48 if (*s++ != '%') 48 if (*s++ != '%')
49 return 0; 49 return 0;
@@ -102,7 +102,7 @@ static int match_one(char *s, char *p, substring_t args[])
102 */ 102 */
103int match_token(char *s, match_table_t table, substring_t args[]) 103int match_token(char *s, match_table_t table, substring_t args[])
104{ 104{
105 struct match_token *p; 105 const struct match_token *p;
106 106
107 for (p = table; !match_one(s, p->pattern, args) ; p++) 107 for (p = table; !match_one(s, p->pattern, args) ; p++)
108 ; 108 ;
@@ -190,7 +190,7 @@ int match_hex(substring_t *s, int *result)
190 * &substring_t @s to the c-style string @to. Caller guarantees that @to is 190 * &substring_t @s to the c-style string @to. Caller guarantees that @to is
191 * large enough to hold the characters of @s. 191 * large enough to hold the characters of @s.
192 */ 192 */
193void match_strcpy(char *to, substring_t *s) 193void match_strcpy(char *to, const substring_t *s)
194{ 194{
195 memcpy(to, s->from, s->to - s->from); 195 memcpy(to, s->from, s->to - s->from);
196 to[s->to - s->from] = '\0'; 196 to[s->to - s->from] = '\0';
@@ -204,7 +204,7 @@ void match_strcpy(char *to, substring_t *s)
204 * the &substring_t @s. The caller is responsible for freeing the returned 204 * the &substring_t @s. The caller is responsible for freeing the returned
205 * string with kfree(). 205 * string with kfree().
206 */ 206 */
207char *match_strdup(substring_t *s) 207char *match_strdup(const substring_t *s)
208{ 208{
209 char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL); 209 char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL);
210 if (p) 210 if (p)
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index d69ddbe43865..402eb4eb6b23 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1004,7 +1004,7 @@ static int radix_tree_callback(struct notifier_block *nfb,
1004 struct radix_tree_preload *rtp; 1004 struct radix_tree_preload *rtp;
1005 1005
1006 /* Free per-cpu pool of perloaded nodes */ 1006 /* Free per-cpu pool of perloaded nodes */
1007 if (action == CPU_DEAD) { 1007 if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
1008 rtp = &per_cpu(radix_tree_preloads, cpu); 1008 rtp = &per_cpu(radix_tree_preloads, cpu);
1009 while (rtp->nr) { 1009 while (rtp->nr) {
1010 kmem_cache_free(radix_tree_node_cachep, 1010 kmem_cache_free(radix_tree_node_cachep,
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
index a4b730a2180c..5b0d8522b7ca 100644
--- a/lib/reed_solomon/reed_solomon.c
+++ b/lib/reed_solomon/reed_solomon.c
@@ -56,6 +56,7 @@ static DEFINE_MUTEX(rslistlock);
56 * rs_init - Initialize a Reed-Solomon codec 56 * rs_init - Initialize a Reed-Solomon codec
57 * @symsize: symbol size, bits (1-8) 57 * @symsize: symbol size, bits (1-8)
58 * @gfpoly: Field generator polynomial coefficients 58 * @gfpoly: Field generator polynomial coefficients
59 * @gffunc: Field generator function
59 * @fcr: first root of RS code generator polynomial, index form 60 * @fcr: first root of RS code generator polynomial, index form
60 * @prim: primitive element to generate polynomial roots 61 * @prim: primitive element to generate polynomial roots
61 * @nroots: RS code generator polynomial degree (number of roots) 62 * @nroots: RS code generator polynomial degree (number of roots)
@@ -63,8 +64,8 @@ static DEFINE_MUTEX(rslistlock);
63 * Allocate a control structure and the polynom arrays for faster 64 * Allocate a control structure and the polynom arrays for faster
64 * en/decoding. Fill the arrays according to the given parameters. 65 * en/decoding. Fill the arrays according to the given parameters.
65 */ 66 */
66static struct rs_control *rs_init(int symsize, int gfpoly, int fcr, 67static struct rs_control *rs_init(int symsize, int gfpoly, int (*gffunc)(int),
67 int prim, int nroots) 68 int fcr, int prim, int nroots)
68{ 69{
69 struct rs_control *rs; 70 struct rs_control *rs;
70 int i, j, sr, root, iprim; 71 int i, j, sr, root, iprim;
@@ -82,6 +83,7 @@ static struct rs_control *rs_init(int symsize, int gfpoly, int fcr,
82 rs->prim = prim; 83 rs->prim = prim;
83 rs->nroots = nroots; 84 rs->nroots = nroots;
84 rs->gfpoly = gfpoly; 85 rs->gfpoly = gfpoly;
86 rs->gffunc = gffunc;
85 87
86 /* Allocate the arrays */ 88 /* Allocate the arrays */
87 rs->alpha_to = kmalloc(sizeof(uint16_t) * (rs->nn + 1), GFP_KERNEL); 89 rs->alpha_to = kmalloc(sizeof(uint16_t) * (rs->nn + 1), GFP_KERNEL);
@@ -99,17 +101,26 @@ static struct rs_control *rs_init(int symsize, int gfpoly, int fcr,
99 /* Generate Galois field lookup tables */ 101 /* Generate Galois field lookup tables */
100 rs->index_of[0] = rs->nn; /* log(zero) = -inf */ 102 rs->index_of[0] = rs->nn; /* log(zero) = -inf */
101 rs->alpha_to[rs->nn] = 0; /* alpha**-inf = 0 */ 103 rs->alpha_to[rs->nn] = 0; /* alpha**-inf = 0 */
102 sr = 1; 104 if (gfpoly) {
103 for (i = 0; i < rs->nn; i++) { 105 sr = 1;
104 rs->index_of[sr] = i; 106 for (i = 0; i < rs->nn; i++) {
105 rs->alpha_to[i] = sr; 107 rs->index_of[sr] = i;
106 sr <<= 1; 108 rs->alpha_to[i] = sr;
107 if (sr & (1 << symsize)) 109 sr <<= 1;
108 sr ^= gfpoly; 110 if (sr & (1 << symsize))
109 sr &= rs->nn; 111 sr ^= gfpoly;
112 sr &= rs->nn;
113 }
114 } else {
115 sr = gffunc(0);
116 for (i = 0; i < rs->nn; i++) {
117 rs->index_of[sr] = i;
118 rs->alpha_to[i] = sr;
119 sr = gffunc(sr);
120 }
110 } 121 }
111 /* If it's not primitive, exit */ 122 /* If it's not primitive, exit */
112 if(sr != 1) 123 if(sr != rs->alpha_to[0])
113 goto errpol; 124 goto errpol;
114 125
115 /* Find prim-th root of 1, used in decoding */ 126 /* Find prim-th root of 1, used in decoding */
@@ -173,18 +184,22 @@ void free_rs(struct rs_control *rs)
173} 184}
174 185
175/** 186/**
176 * init_rs - Find a matching or allocate a new rs control structure 187 * init_rs_internal - Find a matching or allocate a new rs control structure
177 * @symsize: the symbol size (number of bits) 188 * @symsize: the symbol size (number of bits)
178 * @gfpoly: the extended Galois field generator polynomial coefficients, 189 * @gfpoly: the extended Galois field generator polynomial coefficients,
179 * with the 0th coefficient in the low order bit. The polynomial 190 * with the 0th coefficient in the low order bit. The polynomial
180 * must be primitive; 191 * must be primitive;
192 * @gffunc: pointer to function to generate the next field element,
193 * or the multiplicative identity element if given 0. Used
194 * instead of gfpoly if gfpoly is 0
181 * @fcr: the first consecutive root of the rs code generator polynomial 195 * @fcr: the first consecutive root of the rs code generator polynomial
182 * in index form 196 * in index form
183 * @prim: primitive element to generate polynomial roots 197 * @prim: primitive element to generate polynomial roots
184 * @nroots: RS code generator polynomial degree (number of roots) 198 * @nroots: RS code generator polynomial degree (number of roots)
185 */ 199 */
186struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, 200static struct rs_control *init_rs_internal(int symsize, int gfpoly,
187 int nroots) 201 int (*gffunc)(int), int fcr,
202 int prim, int nroots)
188{ 203{
189 struct list_head *tmp; 204 struct list_head *tmp;
190 struct rs_control *rs; 205 struct rs_control *rs;
@@ -208,6 +223,8 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
208 continue; 223 continue;
209 if (gfpoly != rs->gfpoly) 224 if (gfpoly != rs->gfpoly)
210 continue; 225 continue;
226 if (gffunc != rs->gffunc)
227 continue;
211 if (fcr != rs->fcr) 228 if (fcr != rs->fcr)
212 continue; 229 continue;
213 if (prim != rs->prim) 230 if (prim != rs->prim)
@@ -220,7 +237,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
220 } 237 }
221 238
222 /* Create a new one */ 239 /* Create a new one */
223 rs = rs_init(symsize, gfpoly, fcr, prim, nroots); 240 rs = rs_init(symsize, gfpoly, gffunc, fcr, prim, nroots);
224 if (rs) { 241 if (rs) {
225 rs->users = 1; 242 rs->users = 1;
226 list_add(&rs->list, &rslist); 243 list_add(&rs->list, &rslist);
@@ -230,6 +247,42 @@ out:
230 return rs; 247 return rs;
231} 248}
232 249
250/**
251 * init_rs - Find a matching or allocate a new rs control structure
252 * @symsize: the symbol size (number of bits)
253 * @gfpoly: the extended Galois field generator polynomial coefficients,
254 * with the 0th coefficient in the low order bit. The polynomial
255 * must be primitive;
256 * @fcr: the first consecutive root of the rs code generator polynomial
257 * in index form
258 * @prim: primitive element to generate polynomial roots
259 * @nroots: RS code generator polynomial degree (number of roots)
260 */
261struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
262 int nroots)
263{
264 return init_rs_internal(symsize, gfpoly, NULL, fcr, prim, nroots);
265}
266
267/**
268 * init_rs_non_canonical - Find a matching or allocate a new rs control
269 * structure, for fields with non-canonical
270 * representation
271 * @symsize: the symbol size (number of bits)
272 * @gffunc: pointer to function to generate the next field element,
273 * or the multiplicative identity element if given 0. Used
274 * instead of gfpoly if gfpoly is 0
275 * @fcr: the first consecutive root of the rs code generator polynomial
276 * in index form
277 * @prim: primitive element to generate polynomial roots
278 * @nroots: RS code generator polynomial degree (number of roots)
279 */
280struct rs_control *init_rs_non_canonical(int symsize, int (*gffunc)(int),
281 int fcr, int prim, int nroots)
282{
283 return init_rs_internal(symsize, 0, gffunc, fcr, prim, nroots);
284}
285
233#ifdef CONFIG_REED_SOLOMON_ENC8 286#ifdef CONFIG_REED_SOLOMON_ENC8
234/** 287/**
235 * encode_rs8 - Calculate the parity for data values (8bit data width) 288 * encode_rs8 - Calculate the parity for data values (8bit data width)
@@ -321,6 +374,7 @@ EXPORT_SYMBOL_GPL(decode_rs16);
321#endif 374#endif
322 375
323EXPORT_SYMBOL_GPL(init_rs); 376EXPORT_SYMBOL_GPL(init_rs);
377EXPORT_SYMBOL_GPL(init_rs_non_canonical);
324EXPORT_SYMBOL_GPL(free_rs); 378EXPORT_SYMBOL_GPL(free_rs);
325 379
326MODULE_LICENSE("GPL"); 380MODULE_LICENSE("GPL");
diff --git a/lib/string.c b/lib/string.c
index bab440fb0dfc..5efafed3d6b6 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -60,6 +60,34 @@ int strnicmp(const char *s1, const char *s2, size_t len)
60EXPORT_SYMBOL(strnicmp); 60EXPORT_SYMBOL(strnicmp);
61#endif 61#endif
62 62
63#ifndef __HAVE_ARCH_STRCASECMP
64int strcasecmp(const char *s1, const char *s2)
65{
66 int c1, c2;
67
68 do {
69 c1 = tolower(*s1++);
70 c2 = tolower(*s2++);
71 } while (c1 == c2 && c1 != 0);
72 return c1 - c2;
73}
74EXPORT_SYMBOL(strcasecmp);
75#endif
76
77#ifndef __HAVE_ARCH_STRNCASECMP
78int strncasecmp(const char *s1, const char *s2, size_t n)
79{
80 int c1, c2;
81
82 do {
83 c1 = tolower(*s1++);
84 c2 = tolower(*s2++);
85 } while ((--n > 0) && c1 == c2 && c1 != 0);
86 return c1 - c2;
87}
88EXPORT_SYMBOL(strncasecmp);
89#endif
90
63#ifndef __HAVE_ARCH_STRCPY 91#ifndef __HAVE_ARCH_STRCPY
64/** 92/**
65 * strcpy - Copy a %NUL terminated string 93 * strcpy - Copy a %NUL terminated string
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 9970e55c90bd..10c13ad0d82d 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -778,7 +778,6 @@ swiotlb_dma_supported(struct device *hwdev, u64 mask)
778 return virt_to_bus(io_tlb_end - 1) <= mask; 778 return virt_to_bus(io_tlb_end - 1) <= mask;
779} 779}
780 780
781EXPORT_SYMBOL(swiotlb_init);
782EXPORT_SYMBOL(swiotlb_map_single); 781EXPORT_SYMBOL(swiotlb_map_single);
783EXPORT_SYMBOL(swiotlb_unmap_single); 782EXPORT_SYMBOL(swiotlb_unmap_single);
784EXPORT_SYMBOL(swiotlb_map_sg); 783EXPORT_SYMBOL(swiotlb_map_sg);
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index b025864d2e43..017290241261 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -825,6 +825,17 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
825 break; 825 break;
826 str = next; 826 str = next;
827 } 827 }
828
829 /*
830 * Now we've come all the way through so either the input string or the
831 * format ended. In the former case, there can be a %n at the current
832 * position in the format that needs to be filled.
833 */
834 if (*fmt == '%' && *(fmt + 1) == 'n') {
835 int *p = (int *)va_arg(args, int *);
836 *p = str - buf;
837 }
838
828 return num; 839 return num;
829} 840}
830 841
@@ -851,23 +862,35 @@ EXPORT_SYMBOL(sscanf);
851 862
852 863
853/* Simplified asprintf. */ 864/* Simplified asprintf. */
854char *kasprintf(gfp_t gfp, const char *fmt, ...) 865char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
855{ 866{
856 va_list ap;
857 unsigned int len; 867 unsigned int len;
858 char *p; 868 char *p;
869 va_list aq;
859 870
860 va_start(ap, fmt); 871 va_copy(aq, ap);
861 len = vsnprintf(NULL, 0, fmt, ap); 872 len = vsnprintf(NULL, 0, fmt, aq);
862 va_end(ap); 873 va_end(aq);
863 874
864 p = kmalloc(len+1, gfp); 875 p = kmalloc(len+1, gfp);
865 if (!p) 876 if (!p)
866 return NULL; 877 return NULL;
867 va_start(ap, fmt); 878
868 vsnprintf(p, len+1, fmt, ap); 879 vsnprintf(p, len+1, fmt, ap);
869 va_end(ap); 880
870 return p; 881 return p;
871} 882}
883EXPORT_SYMBOL(kvasprintf);
872 884
885char *kasprintf(gfp_t gfp, const char *fmt, ...)
886{
887 va_list ap;
888 char *p;
889
890 va_start(ap, fmt);
891 p = kvasprintf(gfp, fmt, ap);
892 va_end(ap);
893
894 return p;
895}
873EXPORT_SYMBOL(kasprintf); 896EXPORT_SYMBOL(kasprintf);
diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c
index fceb97c3aff7..7e1e3114a73e 100644
--- a/lib/zlib_inflate/inflate.c
+++ b/lib/zlib_inflate/inflate.c
@@ -743,12 +743,14 @@ int zlib_inflate(z_streamp strm, int flush)
743 743
744 strm->data_type = state->bits + (state->last ? 64 : 0) + 744 strm->data_type = state->bits + (state->last ? 64 : 0) +
745 (state->mode == TYPE ? 128 : 0); 745 (state->mode == TYPE ? 128 : 0);
746 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
747 ret = Z_BUF_ERROR;
748 746
749 if (flush == Z_PACKET_FLUSH && ret == Z_OK && 747 if (flush == Z_PACKET_FLUSH && ret == Z_OK &&
750 (strm->avail_out != 0 || strm->avail_in == 0)) 748 strm->avail_out != 0 && strm->avail_in == 0)
751 return zlib_inflateSyncPacket(strm); 749 return zlib_inflateSyncPacket(strm);
750
751 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
752 ret = Z_BUF_ERROR;
753
752 return ret; 754 return ret;
753} 755}
754 756