diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2009-09-12 07:04:37 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-09-12 07:04:37 -0400 |
commit | 87d721ad7a37b7650dd710c88dd5c6a5bf9fe996 (patch) | |
tree | 869d633803eb7c429624d3bd16a6117816849763 /lib | |
parent | ddd559b13f6d2fe3ad68c4b3f5235fd3c2eae4e3 (diff) | |
parent | b7cfda9fc3d7aa60cffab5367f2a72a4a70060cd (diff) |
Merge branch 'master' into devel
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bitmap.c | 12 | ||||
-rw-r--r-- | lib/decompress_bunzip2.c | 24 | ||||
-rw-r--r-- | lib/decompress_inflate.c | 10 | ||||
-rw-r--r-- | lib/decompress_unlzma.c | 23 | ||||
-rw-r--r-- | lib/dma-debug.c | 28 | ||||
-rw-r--r-- | lib/flex_array.c | 43 | ||||
-rw-r--r-- | lib/lmb.c | 2 |
7 files changed, 85 insertions, 57 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 35a1f7ff4149..702565821c99 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -179,14 +179,16 @@ void __bitmap_shift_left(unsigned long *dst, | |||
179 | } | 179 | } |
180 | EXPORT_SYMBOL(__bitmap_shift_left); | 180 | EXPORT_SYMBOL(__bitmap_shift_left); |
181 | 181 | ||
182 | void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, | 182 | int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, |
183 | const unsigned long *bitmap2, int bits) | 183 | const unsigned long *bitmap2, int bits) |
184 | { | 184 | { |
185 | int k; | 185 | int k; |
186 | int nr = BITS_TO_LONGS(bits); | 186 | int nr = BITS_TO_LONGS(bits); |
187 | unsigned long result = 0; | ||
187 | 188 | ||
188 | for (k = 0; k < nr; k++) | 189 | for (k = 0; k < nr; k++) |
189 | dst[k] = bitmap1[k] & bitmap2[k]; | 190 | result |= (dst[k] = bitmap1[k] & bitmap2[k]); |
191 | return result != 0; | ||
190 | } | 192 | } |
191 | EXPORT_SYMBOL(__bitmap_and); | 193 | EXPORT_SYMBOL(__bitmap_and); |
192 | 194 | ||
@@ -212,14 +214,16 @@ void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, | |||
212 | } | 214 | } |
213 | EXPORT_SYMBOL(__bitmap_xor); | 215 | EXPORT_SYMBOL(__bitmap_xor); |
214 | 216 | ||
215 | void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, | 217 | int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, |
216 | const unsigned long *bitmap2, int bits) | 218 | const unsigned long *bitmap2, int bits) |
217 | { | 219 | { |
218 | int k; | 220 | int k; |
219 | int nr = BITS_TO_LONGS(bits); | 221 | int nr = BITS_TO_LONGS(bits); |
222 | unsigned long result = 0; | ||
220 | 223 | ||
221 | for (k = 0; k < nr; k++) | 224 | for (k = 0; k < nr; k++) |
222 | dst[k] = bitmap1[k] & ~bitmap2[k]; | 225 | result |= (dst[k] = bitmap1[k] & ~bitmap2[k]); |
226 | return result != 0; | ||
223 | } | 227 | } |
224 | EXPORT_SYMBOL(__bitmap_andnot); | 228 | EXPORT_SYMBOL(__bitmap_andnot); |
225 | 229 | ||
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c index 708e2a86d87b..600f473a5610 100644 --- a/lib/decompress_bunzip2.c +++ b/lib/decompress_bunzip2.c | |||
@@ -45,12 +45,14 @@ | |||
45 | */ | 45 | */ |
46 | 46 | ||
47 | 47 | ||
48 | #ifndef STATIC | 48 | #ifdef STATIC |
49 | #define PREBOOT | ||
50 | #else | ||
49 | #include <linux/decompress/bunzip2.h> | 51 | #include <linux/decompress/bunzip2.h> |
50 | #endif /* !STATIC */ | 52 | #include <linux/slab.h> |
53 | #endif /* STATIC */ | ||
51 | 54 | ||
52 | #include <linux/decompress/mm.h> | 55 | #include <linux/decompress/mm.h> |
53 | #include <linux/slab.h> | ||
54 | 56 | ||
55 | #ifndef INT_MAX | 57 | #ifndef INT_MAX |
56 | #define INT_MAX 0x7fffffff | 58 | #define INT_MAX 0x7fffffff |
@@ -681,9 +683,7 @@ STATIC int INIT bunzip2(unsigned char *buf, int len, | |||
681 | set_error_fn(error_fn); | 683 | set_error_fn(error_fn); |
682 | if (flush) | 684 | if (flush) |
683 | outbuf = malloc(BZIP2_IOBUF_SIZE); | 685 | outbuf = malloc(BZIP2_IOBUF_SIZE); |
684 | else | 686 | |
685 | len -= 4; /* Uncompressed size hack active in pre-boot | ||
686 | environment */ | ||
687 | if (!outbuf) { | 687 | if (!outbuf) { |
688 | error("Could not allocate output bufer"); | 688 | error("Could not allocate output bufer"); |
689 | return -1; | 689 | return -1; |
@@ -733,4 +733,14 @@ exit_0: | |||
733 | return i; | 733 | return i; |
734 | } | 734 | } |
735 | 735 | ||
736 | #define decompress bunzip2 | 736 | #ifdef PREBOOT |
737 | STATIC int INIT decompress(unsigned char *buf, int len, | ||
738 | int(*fill)(void*, unsigned int), | ||
739 | int(*flush)(void*, unsigned int), | ||
740 | unsigned char *outbuf, | ||
741 | int *pos, | ||
742 | void(*error_fn)(char *x)) | ||
743 | { | ||
744 | return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn); | ||
745 | } | ||
746 | #endif | ||
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c index e36b296fc9f8..68dfce59c1b8 100644 --- a/lib/decompress_inflate.c +++ b/lib/decompress_inflate.c | |||
@@ -19,13 +19,13 @@ | |||
19 | #include "zlib_inflate/inflate.h" | 19 | #include "zlib_inflate/inflate.h" |
20 | 20 | ||
21 | #include "zlib_inflate/infutil.h" | 21 | #include "zlib_inflate/infutil.h" |
22 | #include <linux/slab.h> | ||
22 | 23 | ||
23 | #endif /* STATIC */ | 24 | #endif /* STATIC */ |
24 | 25 | ||
25 | #include <linux/decompress/mm.h> | 26 | #include <linux/decompress/mm.h> |
26 | #include <linux/slab.h> | ||
27 | 27 | ||
28 | #define INBUF_LEN (16*1024) | 28 | #define GZIP_IOBUF_SIZE (16*1024) |
29 | 29 | ||
30 | /* Included from initramfs et al code */ | 30 | /* Included from initramfs et al code */ |
31 | STATIC int INIT gunzip(unsigned char *buf, int len, | 31 | STATIC int INIT gunzip(unsigned char *buf, int len, |
@@ -55,7 +55,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len, | |||
55 | if (buf) | 55 | if (buf) |
56 | zbuf = buf; | 56 | zbuf = buf; |
57 | else { | 57 | else { |
58 | zbuf = malloc(INBUF_LEN); | 58 | zbuf = malloc(GZIP_IOBUF_SIZE); |
59 | len = 0; | 59 | len = 0; |
60 | } | 60 | } |
61 | if (!zbuf) { | 61 | if (!zbuf) { |
@@ -77,7 +77,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len, | |||
77 | } | 77 | } |
78 | 78 | ||
79 | if (len == 0) | 79 | if (len == 0) |
80 | len = fill(zbuf, INBUF_LEN); | 80 | len = fill(zbuf, GZIP_IOBUF_SIZE); |
81 | 81 | ||
82 | /* verify the gzip header */ | 82 | /* verify the gzip header */ |
83 | if (len < 10 || | 83 | if (len < 10 || |
@@ -113,7 +113,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len, | |||
113 | while (rc == Z_OK) { | 113 | while (rc == Z_OK) { |
114 | if (strm->avail_in == 0) { | 114 | if (strm->avail_in == 0) { |
115 | /* TODO: handle case where both pos and fill are set */ | 115 | /* TODO: handle case where both pos and fill are set */ |
116 | len = fill(zbuf, INBUF_LEN); | 116 | len = fill(zbuf, GZIP_IOBUF_SIZE); |
117 | if (len < 0) { | 117 | if (len < 0) { |
118 | rc = -1; | 118 | rc = -1; |
119 | error("read error"); | 119 | error("read error"); |
diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c index 32123a1340e6..0b954e04bd30 100644 --- a/lib/decompress_unlzma.c +++ b/lib/decompress_unlzma.c | |||
@@ -29,12 +29,14 @@ | |||
29 | *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 29 | *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef STATIC | 32 | #ifdef STATIC |
33 | #define PREBOOT | ||
34 | #else | ||
33 | #include <linux/decompress/unlzma.h> | 35 | #include <linux/decompress/unlzma.h> |
36 | #include <linux/slab.h> | ||
34 | #endif /* STATIC */ | 37 | #endif /* STATIC */ |
35 | 38 | ||
36 | #include <linux/decompress/mm.h> | 39 | #include <linux/decompress/mm.h> |
37 | #include <linux/slab.h> | ||
38 | 40 | ||
39 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) | 41 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
40 | 42 | ||
@@ -543,9 +545,7 @@ STATIC inline int INIT unlzma(unsigned char *buf, int in_len, | |||
543 | int ret = -1; | 545 | int ret = -1; |
544 | 546 | ||
545 | set_error_fn(error_fn); | 547 | set_error_fn(error_fn); |
546 | if (!flush) | 548 | |
547 | in_len -= 4; /* Uncompressed size hack active in pre-boot | ||
548 | environment */ | ||
549 | if (buf) | 549 | if (buf) |
550 | inbuf = buf; | 550 | inbuf = buf; |
551 | else | 551 | else |
@@ -645,4 +645,15 @@ exit_0: | |||
645 | return ret; | 645 | return ret; |
646 | } | 646 | } |
647 | 647 | ||
648 | #define decompress unlzma | 648 | #ifdef PREBOOT |
649 | STATIC int INIT decompress(unsigned char *buf, int in_len, | ||
650 | int(*fill)(void*, unsigned int), | ||
651 | int(*flush)(void*, unsigned int), | ||
652 | unsigned char *output, | ||
653 | int *posp, | ||
654 | void(*error_fn)(char *x) | ||
655 | ) | ||
656 | { | ||
657 | return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn); | ||
658 | } | ||
659 | #endif | ||
diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 65b0d99b6d0a..58a9f9fc609a 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c | |||
@@ -156,9 +156,13 @@ static bool driver_filter(struct device *dev) | |||
156 | return true; | 156 | return true; |
157 | 157 | ||
158 | /* driver filter on and initialized */ | 158 | /* driver filter on and initialized */ |
159 | if (current_driver && dev->driver == current_driver) | 159 | if (current_driver && dev && dev->driver == current_driver) |
160 | return true; | 160 | return true; |
161 | 161 | ||
162 | /* driver filter on, but we can't filter on a NULL device... */ | ||
163 | if (!dev) | ||
164 | return false; | ||
165 | |||
162 | if (current_driver || !current_driver_name[0]) | 166 | if (current_driver || !current_driver_name[0]) |
163 | return false; | 167 | return false; |
164 | 168 | ||
@@ -183,17 +187,17 @@ static bool driver_filter(struct device *dev) | |||
183 | return ret; | 187 | return ret; |
184 | } | 188 | } |
185 | 189 | ||
186 | #define err_printk(dev, entry, format, arg...) do { \ | 190 | #define err_printk(dev, entry, format, arg...) do { \ |
187 | error_count += 1; \ | 191 | error_count += 1; \ |
188 | if (driver_filter(dev) && \ | 192 | if (driver_filter(dev) && \ |
189 | (show_all_errors || show_num_errors > 0)) { \ | 193 | (show_all_errors || show_num_errors > 0)) { \ |
190 | WARN(1, "%s %s: " format, \ | 194 | WARN(1, "%s %s: " format, \ |
191 | dev_driver_string(dev), \ | 195 | dev ? dev_driver_string(dev) : "NULL", \ |
192 | dev_name(dev) , ## arg); \ | 196 | dev ? dev_name(dev) : "NULL", ## arg); \ |
193 | dump_entry_trace(entry); \ | 197 | dump_entry_trace(entry); \ |
194 | } \ | 198 | } \ |
195 | if (!show_all_errors && show_num_errors > 0) \ | 199 | if (!show_all_errors && show_num_errors > 0) \ |
196 | show_num_errors -= 1; \ | 200 | show_num_errors -= 1; \ |
197 | } while (0); | 201 | } while (0); |
198 | 202 | ||
199 | /* | 203 | /* |
diff --git a/lib/flex_array.c b/lib/flex_array.c index 0e7894ce8882..7baed2fc3bc8 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c | |||
@@ -99,7 +99,8 @@ static inline int elements_fit_in_base(struct flex_array *fa) | |||
99 | * capacity in the base structure. Also note that no effort is made | 99 | * capacity in the base structure. Also note that no effort is made |
100 | * to efficiently pack objects across page boundaries. | 100 | * to efficiently pack objects across page boundaries. |
101 | */ | 101 | */ |
102 | struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags) | 102 | struct flex_array *flex_array_alloc(int element_size, unsigned int total, |
103 | gfp_t flags) | ||
103 | { | 104 | { |
104 | struct flex_array *ret; | 105 | struct flex_array *ret; |
105 | int max_size = nr_base_part_ptrs() * __elements_per_part(element_size); | 106 | int max_size = nr_base_part_ptrs() * __elements_per_part(element_size); |
@@ -115,16 +116,14 @@ struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags) | |||
115 | return ret; | 116 | return ret; |
116 | } | 117 | } |
117 | 118 | ||
118 | static int fa_element_to_part_nr(struct flex_array *fa, int element_nr) | 119 | static int fa_element_to_part_nr(struct flex_array *fa, |
120 | unsigned int element_nr) | ||
119 | { | 121 | { |
120 | return element_nr / __elements_per_part(fa->element_size); | 122 | return element_nr / __elements_per_part(fa->element_size); |
121 | } | 123 | } |
122 | 124 | ||
123 | /** | 125 | /** |
124 | * flex_array_free_parts - just free the second-level pages | 126 | * flex_array_free_parts - just free the second-level pages |
125 | * @src: address of data to copy into the array | ||
126 | * @element_nr: index of the position in which to insert | ||
127 | * the new element. | ||
128 | * | 127 | * |
129 | * This is to be used in cases where the base 'struct flex_array' | 128 | * This is to be used in cases where the base 'struct flex_array' |
130 | * has been statically allocated and should not be free. | 129 | * has been statically allocated and should not be free. |
@@ -146,14 +145,12 @@ void flex_array_free(struct flex_array *fa) | |||
146 | kfree(fa); | 145 | kfree(fa); |
147 | } | 146 | } |
148 | 147 | ||
149 | static int fa_index_inside_part(struct flex_array *fa, int element_nr) | 148 | static unsigned int index_inside_part(struct flex_array *fa, |
149 | unsigned int element_nr) | ||
150 | { | 150 | { |
151 | return element_nr % __elements_per_part(fa->element_size); | 151 | unsigned int part_offset; |
152 | } | ||
153 | 152 | ||
154 | static int index_inside_part(struct flex_array *fa, int element_nr) | 153 | part_offset = element_nr % __elements_per_part(fa->element_size); |
155 | { | ||
156 | int part_offset = fa_index_inside_part(fa, element_nr); | ||
157 | return part_offset * fa->element_size; | 154 | return part_offset * fa->element_size; |
158 | } | 155 | } |
159 | 156 | ||
@@ -188,7 +185,8 @@ __fa_get_part(struct flex_array *fa, int part_nr, gfp_t flags) | |||
188 | * | 185 | * |
189 | * Locking must be provided by the caller. | 186 | * Locking must be provided by the caller. |
190 | */ | 187 | */ |
191 | int flex_array_put(struct flex_array *fa, int element_nr, void *src, gfp_t flags) | 188 | int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src, |
189 | gfp_t flags) | ||
192 | { | 190 | { |
193 | int part_nr = fa_element_to_part_nr(fa, element_nr); | 191 | int part_nr = fa_element_to_part_nr(fa, element_nr); |
194 | struct flex_array_part *part; | 192 | struct flex_array_part *part; |
@@ -198,10 +196,11 @@ int flex_array_put(struct flex_array *fa, int element_nr, void *src, gfp_t flags | |||
198 | return -ENOSPC; | 196 | return -ENOSPC; |
199 | if (elements_fit_in_base(fa)) | 197 | if (elements_fit_in_base(fa)) |
200 | part = (struct flex_array_part *)&fa->parts[0]; | 198 | part = (struct flex_array_part *)&fa->parts[0]; |
201 | else | 199 | else { |
202 | part = __fa_get_part(fa, part_nr, flags); | 200 | part = __fa_get_part(fa, part_nr, flags); |
203 | if (!part) | 201 | if (!part) |
204 | return -ENOMEM; | 202 | return -ENOMEM; |
203 | } | ||
205 | dst = &part->elements[index_inside_part(fa, element_nr)]; | 204 | dst = &part->elements[index_inside_part(fa, element_nr)]; |
206 | memcpy(dst, src, fa->element_size); | 205 | memcpy(dst, src, fa->element_size); |
207 | return 0; | 206 | return 0; |
@@ -219,7 +218,8 @@ int flex_array_put(struct flex_array *fa, int element_nr, void *src, gfp_t flags | |||
219 | * | 218 | * |
220 | * Locking must be provided by the caller. | 219 | * Locking must be provided by the caller. |
221 | */ | 220 | */ |
222 | int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags) | 221 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, |
222 | unsigned int end, gfp_t flags) | ||
223 | { | 223 | { |
224 | int start_part; | 224 | int start_part; |
225 | int end_part; | 225 | int end_part; |
@@ -250,20 +250,19 @@ int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags) | |||
250 | * | 250 | * |
251 | * Locking must be provided by the caller. | 251 | * Locking must be provided by the caller. |
252 | */ | 252 | */ |
253 | void *flex_array_get(struct flex_array *fa, int element_nr) | 253 | void *flex_array_get(struct flex_array *fa, unsigned int element_nr) |
254 | { | 254 | { |
255 | int part_nr = fa_element_to_part_nr(fa, element_nr); | 255 | int part_nr = fa_element_to_part_nr(fa, element_nr); |
256 | struct flex_array_part *part; | 256 | struct flex_array_part *part; |
257 | int index; | ||
258 | 257 | ||
259 | if (element_nr >= fa->total_nr_elements) | 258 | if (element_nr >= fa->total_nr_elements) |
260 | return NULL; | 259 | return NULL; |
261 | if (!fa->parts[part_nr]) | ||
262 | return NULL; | ||
263 | if (elements_fit_in_base(fa)) | 260 | if (elements_fit_in_base(fa)) |
264 | part = (struct flex_array_part *)&fa->parts[0]; | 261 | part = (struct flex_array_part *)&fa->parts[0]; |
265 | else | 262 | else { |
266 | part = fa->parts[part_nr]; | 263 | part = fa->parts[part_nr]; |
267 | index = index_inside_part(fa, element_nr); | 264 | if (!part) |
265 | return NULL; | ||
266 | } | ||
268 | return &part->elements[index_inside_part(fa, element_nr)]; | 267 | return &part->elements[index_inside_part(fa, element_nr)]; |
269 | } | 268 | } |
@@ -429,7 +429,7 @@ u64 __init lmb_phys_mem_size(void) | |||
429 | return lmb.memory.size; | 429 | return lmb.memory.size; |
430 | } | 430 | } |
431 | 431 | ||
432 | u64 __init lmb_end_of_DRAM(void) | 432 | u64 lmb_end_of_DRAM(void) |
433 | { | 433 | { |
434 | int idx = lmb.memory.cnt - 1; | 434 | int idx = lmb.memory.cnt - 1; |
435 | 435 | ||