aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2014-08-06 19:09:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 21:01:25 -0400
commitd0da23b0debcef135c866cc8117d197fb40a6079 (patch)
tree501e642c5142ff02cd03352fcee8fc4fbe7115f4
parent61b3d6c48f059bb054b0019088736dab6c2ac0ec (diff)
lib/list_sort.c: convert to pr_foo
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: Don Mullis <don.mullis@gmail.com> Cc: Dave Chinner <david@fromorbit.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--lib/list_sort.c49
1 files changed, 21 insertions, 28 deletions
diff --git a/lib/list_sort.c b/lib/list_sort.c
index 6b9fdaf1d32e..12bcba1c8612 100644
--- a/lib/list_sort.c
+++ b/lib/list_sort.c
@@ -1,3 +1,6 @@
1
2#define pr_fmt(fmt) "list_sort_test: " fmt
3
1#include <linux/kernel.h> 4#include <linux/kernel.h>
2#include <linux/module.h> 5#include <linux/module.h>
3#include <linux/list_sort.h> 6#include <linux/list_sort.h>
@@ -125,9 +128,7 @@ void list_sort(void *priv, struct list_head *head,
125 } 128 }
126 if (lev > max_lev) { 129 if (lev > max_lev) {
127 if (unlikely(lev >= ARRAY_SIZE(part)-1)) { 130 if (unlikely(lev >= ARRAY_SIZE(part)-1)) {
128 printk_once(KERN_DEBUG "list passed to" 131 printk_once(KERN_DEBUG "list too long for efficiency\n");
129 " list_sort() too long for"
130 " efficiency\n");
131 lev--; 132 lev--;
132 } 133 }
133 max_lev = lev; 134 max_lev = lev;
@@ -170,27 +171,25 @@ static struct debug_el **elts __initdata;
170static int __init check(struct debug_el *ela, struct debug_el *elb) 171static int __init check(struct debug_el *ela, struct debug_el *elb)
171{ 172{
172 if (ela->serial >= TEST_LIST_LEN) { 173 if (ela->serial >= TEST_LIST_LEN) {
173 printk(KERN_ERR "list_sort_test: error: incorrect serial %d\n", 174 pr_err("error: incorrect serial %d\n", ela->serial);
174 ela->serial);
175 return -EINVAL; 175 return -EINVAL;
176 } 176 }
177 if (elb->serial >= TEST_LIST_LEN) { 177 if (elb->serial >= TEST_LIST_LEN) {
178 printk(KERN_ERR "list_sort_test: error: incorrect serial %d\n", 178 pr_err("error: incorrect serial %d\n", elb->serial);
179 elb->serial);
180 return -EINVAL; 179 return -EINVAL;
181 } 180 }
182 if (elts[ela->serial] != ela || elts[elb->serial] != elb) { 181 if (elts[ela->serial] != ela || elts[elb->serial] != elb) {
183 printk(KERN_ERR "list_sort_test: error: phantom element\n"); 182 pr_err("error: phantom element\n");
184 return -EINVAL; 183 return -EINVAL;
185 } 184 }
186 if (ela->poison1 != TEST_POISON1 || ela->poison2 != TEST_POISON2) { 185 if (ela->poison1 != TEST_POISON1 || ela->poison2 != TEST_POISON2) {
187 printk(KERN_ERR "list_sort_test: error: bad poison: %#x/%#x\n", 186 pr_err("error: bad poison: %#x/%#x\n",
188 ela->poison1, ela->poison2); 187 ela->poison1, ela->poison2);
189 return -EINVAL; 188 return -EINVAL;
190 } 189 }
191 if (elb->poison1 != TEST_POISON1 || elb->poison2 != TEST_POISON2) { 190 if (elb->poison1 != TEST_POISON1 || elb->poison2 != TEST_POISON2) {
192 printk(KERN_ERR "list_sort_test: error: bad poison: %#x/%#x\n", 191 pr_err("error: bad poison: %#x/%#x\n",
193 elb->poison1, elb->poison2); 192 elb->poison1, elb->poison2);
194 return -EINVAL; 193 return -EINVAL;
195 } 194 }
196 return 0; 195 return 0;
@@ -214,20 +213,18 @@ static int __init list_sort_test(void)
214 struct list_head *cur; 213 struct list_head *cur;
215 LIST_HEAD(head); 214 LIST_HEAD(head);
216 215
217 printk(KERN_DEBUG "list_sort_test: start testing list_sort()\n"); 216 pr_debug("start testing list_sort()\n");
218 217
219 elts = kcalloc(TEST_LIST_LEN, sizeof(*elts), GFP_KERNEL); 218 elts = kcalloc(TEST_LIST_LEN, sizeof(*elts), GFP_KERNEL);
220 if (!elts) { 219 if (!elts) {
221 printk(KERN_ERR "list_sort_test: error: cannot allocate " 220 pr_err("error: cannot allocate memory\n");
222 "memory\n");
223 return err; 221 return err;
224 } 222 }
225 223
226 for (i = 0; i < TEST_LIST_LEN; i++) { 224 for (i = 0; i < TEST_LIST_LEN; i++) {
227 el = kmalloc(sizeof(*el), GFP_KERNEL); 225 el = kmalloc(sizeof(*el), GFP_KERNEL);
228 if (!el) { 226 if (!el) {
229 printk(KERN_ERR "list_sort_test: error: cannot " 227 pr_err("error: cannot allocate memory\n");
230 "allocate memory\n");
231 goto exit; 228 goto exit;
232 } 229 }
233 /* force some equivalencies */ 230 /* force some equivalencies */
@@ -247,42 +244,38 @@ static int __init list_sort_test(void)
247 int cmp_result; 244 int cmp_result;
248 245
249 if (cur->next->prev != cur) { 246 if (cur->next->prev != cur) {
250 printk(KERN_ERR "list_sort_test: error: list is " 247 pr_err("error: list is corrupted\n");
251 "corrupted\n");
252 goto exit; 248 goto exit;
253 } 249 }
254 250
255 cmp_result = cmp(NULL, cur, cur->next); 251 cmp_result = cmp(NULL, cur, cur->next);
256 if (cmp_result > 0) { 252 if (cmp_result > 0) {
257 printk(KERN_ERR "list_sort_test: error: list is not " 253 pr_err("error: list is not sorted\n");
258 "sorted\n");
259 goto exit; 254 goto exit;
260 } 255 }
261 256
262 el = container_of(cur, struct debug_el, list); 257 el = container_of(cur, struct debug_el, list);
263 el1 = container_of(cur->next, struct debug_el, list); 258 el1 = container_of(cur->next, struct debug_el, list);
264 if (cmp_result == 0 && el->serial >= el1->serial) { 259 if (cmp_result == 0 && el->serial >= el1->serial) {
265 printk(KERN_ERR "list_sort_test: error: order of " 260 pr_err("error: order of equivalent elements not "
266 "equivalent elements not preserved\n"); 261 "preserved\n");
267 goto exit; 262 goto exit;
268 } 263 }
269 264
270 if (check(el, el1)) { 265 if (check(el, el1)) {
271 printk(KERN_ERR "list_sort_test: error: element check " 266 pr_err("error: element check failed\n");
272 "failed\n");
273 goto exit; 267 goto exit;
274 } 268 }
275 count++; 269 count++;
276 } 270 }
277 if (head.prev != cur) { 271 if (head.prev != cur) {
278 printk(KERN_ERR "list_sort_test: error: list is corrupted\n"); 272 pr_err("error: list is corrupted\n");
279 goto exit; 273 goto exit;
280 } 274 }
281 275
282 276
283 if (count != TEST_LIST_LEN) { 277 if (count != TEST_LIST_LEN) {
284 printk(KERN_ERR "list_sort_test: error: bad list length %d", 278 pr_err("error: bad list length %d", count);
285 count);
286 goto exit; 279 goto exit;
287 } 280 }
288 281