aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/dma-debug.c2
-rw-r--r--lib/idr.c4
-rw-r--r--lib/string.c27
-rw-r--r--lib/zlib_inflate/inffast.c32
4 files changed, 60 insertions, 5 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 7d2f0b33e5a8..ba8b67039d13 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -587,7 +587,7 @@ out_unlock:
587 return count; 587 return count;
588} 588}
589 589
590const struct file_operations filter_fops = { 590static const struct file_operations filter_fops = {
591 .read = filter_read, 591 .read = filter_read,
592 .write = filter_write, 592 .write = filter_write,
593}; 593};
diff --git a/lib/idr.c b/lib/idr.c
index 1cac726c44bc..0dc782216d4b 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -156,10 +156,12 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa)
156 id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1; 156 id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1;
157 157
158 /* if already at the top layer, we need to grow */ 158 /* if already at the top layer, we need to grow */
159 if (!(p = pa[l])) { 159 if (id >= 1 << (idp->layers * IDR_BITS)) {
160 *starting_id = id; 160 *starting_id = id;
161 return IDR_NEED_TO_GROW; 161 return IDR_NEED_TO_GROW;
162 } 162 }
163 p = pa[l];
164 BUG_ON(!p);
163 165
164 /* If we need to go up one layer, continue the 166 /* If we need to go up one layer, continue the
165 * loop; otherwise, restart from the top. 167 * loop; otherwise, restart from the top.
diff --git a/lib/string.c b/lib/string.c
index 9f75b4ec50b8..a1cdcfcc42d0 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -667,7 +667,7 @@ EXPORT_SYMBOL(memscan);
667 */ 667 */
668char *strstr(const char *s1, const char *s2) 668char *strstr(const char *s1, const char *s2)
669{ 669{
670 int l1, l2; 670 size_t l1, l2;
671 671
672 l2 = strlen(s2); 672 l2 = strlen(s2);
673 if (!l2) 673 if (!l2)
@@ -684,6 +684,31 @@ char *strstr(const char *s1, const char *s2)
684EXPORT_SYMBOL(strstr); 684EXPORT_SYMBOL(strstr);
685#endif 685#endif
686 686
687#ifndef __HAVE_ARCH_STRNSTR
688/**
689 * strnstr - Find the first substring in a length-limited string
690 * @s1: The string to be searched
691 * @s2: The string to search for
692 * @len: the maximum number of characters to search
693 */
694char *strnstr(const char *s1, const char *s2, size_t len)
695{
696 size_t l1 = len, l2;
697
698 l2 = strlen(s2);
699 if (!l2)
700 return (char *)s1;
701 while (l1 >= l2) {
702 l1--;
703 if (!memcmp(s1, s2, l2))
704 return (char *)s1;
705 s1++;
706 }
707 return NULL;
708}
709EXPORT_SYMBOL(strnstr);
710#endif
711
687#ifndef __HAVE_ARCH_MEMCHR 712#ifndef __HAVE_ARCH_MEMCHR
688/** 713/**
689 * memchr - Find a character in an area of memory. 714 * memchr - Find a character in an area of memory.
diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c
index 05e1559fa156..215447c55261 100644
--- a/lib/zlib_inflate/inffast.c
+++ b/lib/zlib_inflate/inffast.c
@@ -4,12 +4,25 @@
4 */ 4 */
5 5
6#include <linux/zutil.h> 6#include <linux/zutil.h>
7#include <asm/unaligned.h>
8#include <asm/byteorder.h>
9#include "inftrees.h" 7#include "inftrees.h"
10#include "inflate.h" 8#include "inflate.h"
11#include "inffast.h" 9#include "inffast.h"
12 10
11/* Only do the unaligned "Faster" variant when
12 * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set
13 *
14 * On powerpc, it won't be as we don't include autoconf.h
15 * automatically for the boot wrapper, which is intended as
16 * we run in an environment where we may not be able to deal
17 * with (even rare) alignment faults. In addition, we do not
18 * define __KERNEL__ for arch/powerpc/boot unlike x86
19 */
20
21#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
22#include <asm/unaligned.h>
23#include <asm/byteorder.h>
24#endif
25
13#ifndef ASMINF 26#ifndef ASMINF
14 27
15/* Allow machine dependent optimization for post-increment or pre-increment. 28/* Allow machine dependent optimization for post-increment or pre-increment.
@@ -243,6 +256,7 @@ void inflate_fast(z_streamp strm, unsigned start)
243 } 256 }
244 } 257 }
245 else { 258 else {
259#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
246 unsigned short *sout; 260 unsigned short *sout;
247 unsigned long loops; 261 unsigned long loops;
248 262
@@ -284,6 +298,20 @@ void inflate_fast(z_streamp strm, unsigned start)
284 } 298 }
285 if (len & 1) 299 if (len & 1)
286 PUP(out) = PUP(from); 300 PUP(out) = PUP(from);
301#else /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
302 from = out - dist; /* copy direct from output */
303 do { /* minimum length is three */
304 PUP(out) = PUP(from);
305 PUP(out) = PUP(from);
306 PUP(out) = PUP(from);
307 len -= 3;
308 } while (len > 2);
309 if (len) {
310 PUP(out) = PUP(from);
311 if (len > 1)
312 PUP(out) = PUP(from);
313 }
314#endif /* !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
287 } 315 }
288 } 316 }
289 else if ((op & 64) == 0) { /* 2nd level distance code */ 317 else if ((op & 64) == 0) { /* 2nd level distance code */