aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig5
-rw-r--r--lib/Kconfig.debug34
-rw-r--r--lib/cpumask.c3
-rw-r--r--lib/devres.c26
-rw-r--r--lib/fault-inject.c3
-rw-r--r--lib/inflate.c129
-rw-r--r--lib/iomap.c27
-rw-r--r--lib/kobject.c69
-rw-r--r--lib/parser.c10
-rw-r--r--lib/radix-tree.c2
-rw-r--r--lib/swiotlb.c1
-rw-r--r--lib/vsprintf.c37
-rw-r--r--lib/zlib_inflate/inflate.c8
13 files changed, 207 insertions, 147 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index 384249915047..96d6e8ca8b70 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -111,4 +111,9 @@ config HAS_IOPORT
111 depends on HAS_IOMEM && !NO_IOPORT 111 depends on HAS_IOMEM && !NO_IOPORT
112 default y 112 default y
113 113
114config HAS_DMA
115 boolean
116 depends on !NO_DMA
117 default y
118
114endmenu 119endmenu
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 79afd00bbe5f..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
@@ -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/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/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 cecf2fbede3e..fc5f3f6e7329 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -582,22 +582,10 @@ void kset_init(struct kset * k)
582/** 582/**
583 * kset_add - add a kset object to the hierarchy. 583 * kset_add - add a kset object to the hierarchy.
584 * @k: kset. 584 * @k: kset.
585 *
586 * Simply, this adds the kset's embedded kobject to the
587 * hierarchy.
588 * We also try to make sure that the kset's embedded kobject
589 * has a parent before it is added. We only care if the embedded
590 * kobject is not part of a kset itself, since kobject_add()
591 * assigns a parent in that case.
592 * If that is the case, and the kset has a controlling subsystem,
593 * then we set the kset's parent to be said subsystem.
594 */ 585 */
595 586
596int kset_add(struct kset * k) 587int kset_add(struct kset * k)
597{ 588{
598 if (!k->kobj.parent && !k->kobj.kset && k->subsys)
599 k->kobj.parent = &k->subsys->kset.kobj;
600
601 return kobject_add(&k->kobj); 589 return kobject_add(&k->kobj);
602} 590}
603 591
@@ -656,53 +644,28 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name)
656 return ret; 644 return ret;
657} 645}
658 646
659 647void subsystem_init(struct kset *s)
660void subsystem_init(struct subsystem * s)
661{ 648{
662 kset_init(&s->kset); 649 kset_init(s);
663} 650}
664 651
665/** 652int subsystem_register(struct kset *s)
666 * subsystem_register - register a subsystem.
667 * @s: the subsystem we're registering.
668 *
669 * Once we register the subsystem, we want to make sure that
670 * the kset points back to this subsystem.
671 */
672
673int subsystem_register(struct subsystem * s)
674{ 653{
675 int error; 654 return kset_register(s);
676
677 if (!s)
678 return -EINVAL;
679
680 subsystem_init(s);
681 pr_debug("subsystem %s: registering\n",s->kset.kobj.name);
682
683 if (!(error = kset_add(&s->kset))) {
684 if (!s->kset.subsys)
685 s->kset.subsys = s;
686 }
687 return error;
688} 655}
689 656
690void subsystem_unregister(struct subsystem * s) 657void subsystem_unregister(struct kset *s)
691{ 658{
692 if (!s) 659 kset_unregister(s);
693 return;
694 pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name);
695 kset_unregister(&s->kset);
696} 660}
697 661
698
699/** 662/**
700 * subsystem_create_file - export sysfs attribute file. 663 * subsystem_create_file - export sysfs attribute file.
701 * @s: subsystem. 664 * @s: subsystem.
702 * @a: subsystem attribute descriptor. 665 * @a: subsystem attribute descriptor.
703 */ 666 */
704 667
705int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) 668int subsys_create_file(struct kset *s, struct subsys_attribute *a)
706{ 669{
707 int error = 0; 670 int error = 0;
708 671
@@ -710,28 +673,12 @@ int subsys_create_file(struct subsystem * s, struct subsys_attribute * a)
710 return -EINVAL; 673 return -EINVAL;
711 674
712 if (subsys_get(s)) { 675 if (subsys_get(s)) {
713 error = sysfs_create_file(&s->kset.kobj,&a->attr); 676 error = sysfs_create_file(&s->kobj, &a->attr);
714 subsys_put(s); 677 subsys_put(s);
715 } 678 }
716 return error; 679 return error;
717} 680}
718 681
719
720/**
721 * subsystem_remove_file - remove sysfs attribute file.
722 * @s: subsystem.
723 * @a: attribute desciptor.
724 */
725#if 0
726void subsys_remove_file(struct subsystem * s, struct subsys_attribute * a)
727{
728 if (subsys_get(s)) {
729 sysfs_remove_file(&s->kset.kobj,&a->attr);
730 subsys_put(s);
731 }
732}
733#endif /* 0 */
734
735EXPORT_SYMBOL(kobject_init); 682EXPORT_SYMBOL(kobject_init);
736EXPORT_SYMBOL(kobject_register); 683EXPORT_SYMBOL(kobject_register);
737EXPORT_SYMBOL(kobject_unregister); 684EXPORT_SYMBOL(kobject_unregister);
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/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