Commit 93e2f585c149b5056d5c5eaffcaf747bbe9c3015

Authored by Namhyung Kim
Committed by Linus Torvalds
1 parent 3f0f4a3f20

lkdtm: prefix enum constants

Prefix cname and ctype constants with CN/CT_.  This is especially for the
conflict on BUG which causes a build break if arch defines it as a inline
function, i.e.  MIPS.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Ankita Garg <ankita@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 64 additions and 64 deletions Side-by-side Diff

drivers/misc/lkdtm.c
... ... @@ -52,32 +52,32 @@
52 52 #define REC_NUM_DEFAULT 10
53 53  
54 54 enum cname {
55   - INVALID,
56   - INT_HARDWARE_ENTRY,
57   - INT_HW_IRQ_EN,
58   - INT_TASKLET_ENTRY,
59   - FS_DEVRW,
60   - MEM_SWAPOUT,
61   - TIMERADD,
62   - SCSI_DISPATCH_CMD,
63   - IDE_CORE_CP,
64   - DIRECT,
  55 + CN_INVALID,
  56 + CN_INT_HARDWARE_ENTRY,
  57 + CN_INT_HW_IRQ_EN,
  58 + CN_INT_TASKLET_ENTRY,
  59 + CN_FS_DEVRW,
  60 + CN_MEM_SWAPOUT,
  61 + CN_TIMERADD,
  62 + CN_SCSI_DISPATCH_CMD,
  63 + CN_IDE_CORE_CP,
  64 + CN_DIRECT,
65 65 };
66 66  
67 67 enum ctype {
68   - NONE,
69   - PANIC,
70   - BUG,
71   - EXCEPTION,
72   - LOOP,
73   - OVERFLOW,
74   - CORRUPT_STACK,
75   - UNALIGNED_LOAD_STORE_WRITE,
76   - OVERWRITE_ALLOCATION,
77   - WRITE_AFTER_FREE,
78   - SOFTLOCKUP,
79   - HARDLOCKUP,
80   - HUNG_TASK,
  68 + CT_NONE,
  69 + CT_PANIC,
  70 + CT_BUG,
  71 + CT_EXCEPTION,
  72 + CT_LOOP,
  73 + CT_OVERFLOW,
  74 + CT_CORRUPT_STACK,
  75 + CT_UNALIGNED_LOAD_STORE_WRITE,
  76 + CT_OVERWRITE_ALLOCATION,
  77 + CT_WRITE_AFTER_FREE,
  78 + CT_SOFTLOCKUP,
  79 + CT_HARDLOCKUP,
  80 + CT_HUNG_TASK,
81 81 };
82 82  
83 83 static char* cp_name[] = {
... ... @@ -117,8 +117,8 @@
117 117 static int cpoint_count = DEFAULT_COUNT;
118 118 static int recur_count = REC_NUM_DEFAULT;
119 119  
120   -static enum cname cpoint = INVALID;
121   -static enum ctype cptype = NONE;
  120 +static enum cname cpoint = CN_INVALID;
  121 +static enum ctype cptype = CT_NONE;
122 122 static int count = DEFAULT_COUNT;
123 123  
124 124 module_param(recur_count, int, 0644);
125 125  
... ... @@ -207,12 +207,12 @@
207 207 return i + 1;
208 208 }
209 209  
210   - return NONE;
  210 + return CT_NONE;
211 211 }
212 212  
213 213 static const char *cp_type_to_str(enum ctype type)
214 214 {
215   - if (type == NONE || type < 0 || type > ARRAY_SIZE(cp_type))
  215 + if (type == CT_NONE || type < 0 || type > ARRAY_SIZE(cp_type))
216 216 return "None";
217 217  
218 218 return cp_type[type - 1];
... ... @@ -220,7 +220,7 @@
220 220  
221 221 static const char *cp_name_to_str(enum cname name)
222 222 {
223   - if (name == INVALID || name < 0 || name > ARRAY_SIZE(cp_name))
  223 + if (name == CN_INVALID || name < 0 || name > ARRAY_SIZE(cp_name))
224 224 return "INVALID";
225 225  
226 226 return cp_name[name - 1];
... ... @@ -245,7 +245,7 @@
245 245 return -EINVAL;
246 246  
247 247 cptype = parse_cp_type(cpoint_type, strlen(cpoint_type));
248   - if (cptype == NONE)
  248 + if (cptype == CT_NONE)
249 249 return -EINVAL;
250 250  
251 251 for (i = 0; i < ARRAY_SIZE(cp_name); i++) {
252 252  
253 253  
254 254  
255 255  
256 256  
257 257  
... ... @@ -274,30 +274,30 @@
274 274 static void lkdtm_do_action(enum ctype which)
275 275 {
276 276 switch (which) {
277   - case PANIC:
  277 + case CT_PANIC:
278 278 panic("dumptest");
279 279 break;
280   - case BUG:
  280 + case CT_BUG:
281 281 BUG();
282 282 break;
283   - case EXCEPTION:
  283 + case CT_EXCEPTION:
284 284 *((int *) 0) = 0;
285 285 break;
286   - case LOOP:
  286 + case CT_LOOP:
287 287 for (;;)
288 288 ;
289 289 break;
290   - case OVERFLOW:
  290 + case CT_OVERFLOW:
291 291 (void) recursive_loop(0);
292 292 break;
293   - case CORRUPT_STACK: {
  293 + case CT_CORRUPT_STACK: {
294 294 volatile u32 data[8];
295 295 volatile u32 *p = data;
296 296  
297 297 p[12] = 0x12345678;
298 298 break;
299 299 }
300   - case UNALIGNED_LOAD_STORE_WRITE: {
  300 + case CT_UNALIGNED_LOAD_STORE_WRITE: {
301 301 static u8 data[5] __attribute__((aligned(4))) = {1, 2,
302 302 3, 4, 5};
303 303 u32 *p;
... ... @@ -309,7 +309,7 @@
309 309 *p = val;
310 310 break;
311 311 }
312   - case OVERWRITE_ALLOCATION: {
  312 + case CT_OVERWRITE_ALLOCATION: {
313 313 size_t len = 1020;
314 314 u32 *data = kmalloc(len, GFP_KERNEL);
315 315  
... ... @@ -317,7 +317,7 @@
317 317 kfree(data);
318 318 break;
319 319 }
320   - case WRITE_AFTER_FREE: {
  320 + case CT_WRITE_AFTER_FREE: {
321 321 size_t len = 1024;
322 322 u32 *data = kmalloc(len, GFP_KERNEL);
323 323  
324 324  
325 325  
326 326  
... ... @@ -326,21 +326,21 @@
326 326 memset(data, 0x78, len);
327 327 break;
328 328 }
329   - case SOFTLOCKUP:
  329 + case CT_SOFTLOCKUP:
330 330 preempt_disable();
331 331 for (;;)
332 332 cpu_relax();
333 333 break;
334   - case HARDLOCKUP:
  334 + case CT_HARDLOCKUP:
335 335 local_irq_disable();
336 336 for (;;)
337 337 cpu_relax();
338 338 break;
339   - case HUNG_TASK:
  339 + case CT_HUNG_TASK:
340 340 set_current_state(TASK_UNINTERRUPTIBLE);
341 341 schedule();
342 342 break;
343   - case NONE:
  343 + case CT_NONE:
344 344 default:
345 345 break;
346 346 }
347 347  
348 348  
349 349  
350 350  
351 351  
352 352  
353 353  
354 354  
355 355  
... ... @@ -363,43 +363,43 @@
363 363 {
364 364 int ret;
365 365  
366   - cpoint = INVALID;
  366 + cpoint = CN_INVALID;
367 367 if (lkdtm.entry != NULL)
368 368 unregister_jprobe(&lkdtm);
369 369  
370 370 switch (which) {
371   - case DIRECT:
  371 + case CN_DIRECT:
372 372 lkdtm_do_action(cptype);
373 373 return 0;
374   - case INT_HARDWARE_ENTRY:
  374 + case CN_INT_HARDWARE_ENTRY:
375 375 lkdtm.kp.symbol_name = "do_IRQ";
376 376 lkdtm.entry = (kprobe_opcode_t*) jp_do_irq;
377 377 break;
378   - case INT_HW_IRQ_EN:
  378 + case CN_INT_HW_IRQ_EN:
379 379 lkdtm.kp.symbol_name = "handle_IRQ_event";
380 380 lkdtm.entry = (kprobe_opcode_t*) jp_handle_irq_event;
381 381 break;
382   - case INT_TASKLET_ENTRY:
  382 + case CN_INT_TASKLET_ENTRY:
383 383 lkdtm.kp.symbol_name = "tasklet_action";
384 384 lkdtm.entry = (kprobe_opcode_t*) jp_tasklet_action;
385 385 break;
386   - case FS_DEVRW:
  386 + case CN_FS_DEVRW:
387 387 lkdtm.kp.symbol_name = "ll_rw_block";
388 388 lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block;
389 389 break;
390   - case MEM_SWAPOUT:
  390 + case CN_MEM_SWAPOUT:
391 391 lkdtm.kp.symbol_name = "shrink_inactive_list";
392 392 lkdtm.entry = (kprobe_opcode_t*) jp_shrink_inactive_list;
393 393 break;
394   - case TIMERADD:
  394 + case CN_TIMERADD:
395 395 lkdtm.kp.symbol_name = "hrtimer_start";
396 396 lkdtm.entry = (kprobe_opcode_t*) jp_hrtimer_start;
397 397 break;
398   - case SCSI_DISPATCH_CMD:
  398 + case CN_SCSI_DISPATCH_CMD:
399 399 lkdtm.kp.symbol_name = "scsi_dispatch_cmd";
400 400 lkdtm.entry = (kprobe_opcode_t*) jp_scsi_dispatch_cmd;
401 401 break;
402   - case IDE_CORE_CP:
  402 + case CN_IDE_CORE_CP:
403 403 #ifdef CONFIG_IDE
404 404 lkdtm.kp.symbol_name = "generic_ide_ioctl";
405 405 lkdtm.entry = (kprobe_opcode_t*) jp_generic_ide_ioctl;
... ... @@ -416,7 +416,7 @@
416 416 cpoint = which;
417 417 if ((ret = register_jprobe(&lkdtm)) < 0) {
418 418 printk(KERN_INFO "lkdtm: Couldn't register jprobe\n");
419   - cpoint = INVALID;
  419 + cpoint = CN_INVALID;
420 420 }
421 421  
422 422 return ret;
... ... @@ -445,7 +445,7 @@
445 445 cptype = parse_cp_type(buf, count);
446 446 free_page((unsigned long) buf);
447 447  
448   - if (cptype == NONE)
  448 + if (cptype == CT_NONE)
449 449 return -EINVAL;
450 450  
451 451 err = lkdtm_register_cpoint(which);
452 452  
453 453  
454 454  
455 455  
456 456  
457 457  
458 458  
... ... @@ -487,49 +487,49 @@
487 487 static ssize_t int_hardware_entry(struct file *f, const char __user *buf,
488 488 size_t count, loff_t *off)
489 489 {
490   - return do_register_entry(INT_HARDWARE_ENTRY, f, buf, count, off);
  490 + return do_register_entry(CN_INT_HARDWARE_ENTRY, f, buf, count, off);
491 491 }
492 492  
493 493 static ssize_t int_hw_irq_en(struct file *f, const char __user *buf,
494 494 size_t count, loff_t *off)
495 495 {
496   - return do_register_entry(INT_HW_IRQ_EN, f, buf, count, off);
  496 + return do_register_entry(CN_INT_HW_IRQ_EN, f, buf, count, off);
497 497 }
498 498  
499 499 static ssize_t int_tasklet_entry(struct file *f, const char __user *buf,
500 500 size_t count, loff_t *off)
501 501 {
502   - return do_register_entry(INT_TASKLET_ENTRY, f, buf, count, off);
  502 + return do_register_entry(CN_INT_TASKLET_ENTRY, f, buf, count, off);
503 503 }
504 504  
505 505 static ssize_t fs_devrw_entry(struct file *f, const char __user *buf,
506 506 size_t count, loff_t *off)
507 507 {
508   - return do_register_entry(FS_DEVRW, f, buf, count, off);
  508 + return do_register_entry(CN_FS_DEVRW, f, buf, count, off);
509 509 }
510 510  
511 511 static ssize_t mem_swapout_entry(struct file *f, const char __user *buf,
512 512 size_t count, loff_t *off)
513 513 {
514   - return do_register_entry(MEM_SWAPOUT, f, buf, count, off);
  514 + return do_register_entry(CN_MEM_SWAPOUT, f, buf, count, off);
515 515 }
516 516  
517 517 static ssize_t timeradd_entry(struct file *f, const char __user *buf,
518 518 size_t count, loff_t *off)
519 519 {
520   - return do_register_entry(TIMERADD, f, buf, count, off);
  520 + return do_register_entry(CN_TIMERADD, f, buf, count, off);
521 521 }
522 522  
523 523 static ssize_t scsi_dispatch_cmd_entry(struct file *f,
524 524 const char __user *buf, size_t count, loff_t *off)
525 525 {
526   - return do_register_entry(SCSI_DISPATCH_CMD, f, buf, count, off);
  526 + return do_register_entry(CN_SCSI_DISPATCH_CMD, f, buf, count, off);
527 527 }
528 528  
529 529 static ssize_t ide_core_cp_entry(struct file *f, const char __user *buf,
530 530 size_t count, loff_t *off)
531 531 {
532   - return do_register_entry(IDE_CORE_CP, f, buf, count, off);
  532 + return do_register_entry(CN_IDE_CORE_CP, f, buf, count, off);
533 533 }
534 534  
535 535 /* Special entry to just crash directly. Available without KPROBEs */
... ... @@ -557,7 +557,7 @@
557 557  
558 558 type = parse_cp_type(buf, count);
559 559 free_page((unsigned long) buf);
560   - if (type == NONE)
  560 + if (type == CT_NONE)
561 561 return -EINVAL;
562 562  
563 563 printk(KERN_INFO "lkdtm: Performing direct entry %s\n",
... ... @@ -649,7 +649,7 @@
649 649 goto out_err;
650 650 }
651 651  
652   - if (cpoint != INVALID && cptype != NONE) {
  652 + if (cpoint != CN_INVALID && cptype != CT_NONE) {
653 653 ret = lkdtm_register_cpoint(cpoint);
654 654 if (ret < 0) {
655 655 printk(KERN_INFO "lkdtm: Invalid crash point %d\n",