aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-09-04 03:28:52 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-04 03:29:05 -0400
commit29e2035bddecce3eb584a8304528b50da8370a24 (patch)
tree13155df7d90a8e287b83a1cd6c0d02c3018212ab /lib
parent868489660dabc0c28087cca3dbc1adbbc398c6fe (diff)
parent37d0892c5a94e208cf863e3b7bac014edee4346d (diff)
Merge branch 'linus' into core/rcu
Merge reason: Avoid fuzz in init/main.c and update from rc6 to rc8. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'lib')
-rw-r--r--lib/bitmap.c12
-rw-r--r--lib/dma-debug.c28
-rw-r--r--lib/flex_array.c41
-rw-r--r--lib/lmb.c2
4 files changed, 46 insertions, 37 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}
180EXPORT_SYMBOL(__bitmap_shift_left); 180EXPORT_SYMBOL(__bitmap_shift_left);
181 181
182void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 182int __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}
191EXPORT_SYMBOL(__bitmap_and); 193EXPORT_SYMBOL(__bitmap_and);
192 194
@@ -212,14 +214,16 @@ void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
212} 214}
213EXPORT_SYMBOL(__bitmap_xor); 215EXPORT_SYMBOL(__bitmap_xor);
214 216
215void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 217int __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}
224EXPORT_SYMBOL(__bitmap_andnot); 228EXPORT_SYMBOL(__bitmap_andnot);
225 229
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 08f1636d296a..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 */
102struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags) 102struct 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
118static int fa_element_to_part_nr(struct flex_array *fa, int element_nr) 119static 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
149static int fa_index_inside_part(struct flex_array *fa, int element_nr) 148static 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
154static 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 */
191int flex_array_put(struct flex_array *fa, int element_nr, void *src, gfp_t flags) 188int 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 */
222int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags) 221int 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,18 +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 */
253void *flex_array_get(struct flex_array *fa, int element_nr) 253void *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 257
258 if (element_nr >= fa->total_nr_elements) 258 if (element_nr >= fa->total_nr_elements)
259 return NULL; 259 return NULL;
260 if (!fa->parts[part_nr])
261 return NULL;
262 if (elements_fit_in_base(fa)) 260 if (elements_fit_in_base(fa))
263 part = (struct flex_array_part *)&fa->parts[0]; 261 part = (struct flex_array_part *)&fa->parts[0];
264 else 262 else {
265 part = fa->parts[part_nr]; 263 part = fa->parts[part_nr];
264 if (!part)
265 return NULL;
266 }
266 return &part->elements[index_inside_part(fa, element_nr)]; 267 return &part->elements[index_inside_part(fa, element_nr)];
267} 268}
diff --git a/lib/lmb.c b/lib/lmb.c
index e4a6482d8b26..0343c05609f0 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -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
432u64 __init lmb_end_of_DRAM(void) 432u64 lmb_end_of_DRAM(void)
433{ 433{
434 int idx = lmb.memory.cnt - 1; 434 int idx = lmb.memory.cnt - 1;
435 435