Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi/NCR5380: fix and standardize NDEBUG macros

All three NCR5380 core driver implementations share the same NCR5380.h
header file so they need to agree on certain macro definitions.

The flag bit used by the NDEBUG_MERGING macro in atari_NCR5380 and
sun3_NCR5380 collides with the bit used by NDEBUG_LISTS.

Moreover, NDEBUG_ABORT appears in NCR5380.c so it should be defined in
NCR5380.h rather than in each of the many drivers using that core.

An undefined NDEBUG_ABORT macro caused compiler errors and led to dodgy
workarounds in the core driver that can now be removed.
(See commits f566a576bca09de85bf477fc0ab2c8c96405b77b and
185a7a1cd79b9891e3c17abdb103ba1c98d6ca7a.)

Move all of the NDEBUG_ABORT, NDEBUG_TAGS and NDEBUG_MERGING macro
definitions into NCR5380.h where all the other NDEBUG macros live.

Also, incorrect "#ifdef NDEBUG" becomes "#if NDEBUG" to fix the warning:
drivers/scsi/mac_scsi.c: At top level:
drivers/scsi/NCR5380.c:418: warning: 'NCR5380_print' defined but not used
drivers/scsi/NCR5380.c:459: warning: 'NCR5380_print_phase' defined but not used

The debugging code is now enabled when NDEBUG != 0.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Acked-by: Sam Creasey <sammy@sammy.net>
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by

Finn Thain and committed by
Christoph Hellwig
9829e528 d65e634a

+19 -54
-7
drivers/scsi/NCR5380.c
··· 87 87 #include <scsi/scsi_dbg.h> 88 88 #include <scsi/scsi_transport_spi.h> 89 89 90 - #ifndef NDEBUG 91 - #define NDEBUG 0 92 - #endif 93 - #ifndef NDEBUG_ABORT 94 - #define NDEBUG_ABORT 0 95 - #endif 96 - 97 90 #if (NDEBUG & NDEBUG_LISTS) 98 91 #define LIST(x,y) {printk("LINE:%d Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); if ((x)==(y)) udelay(5); } 99 92 #define REMOVE(w,x,y,z) {printk("LINE:%d Removing: %p->%p %p->%p \n", __LINE__, (void*)(w), (void*)(x), (void*)(y), (void*)(z)); if ((x)==(y)) udelay(5); }
+18 -4
drivers/scsi/NCR5380.h
··· 56 56 #define NDEBUG_C400_PREAD 0x100000 57 57 #define NDEBUG_C400_PWRITE 0x200000 58 58 #define NDEBUG_LISTS 0x400000 59 + #define NDEBUG_ABORT 0x800000 60 + #define NDEBUG_TAGS 0x1000000 61 + #define NDEBUG_MERGING 0x2000000 59 62 60 63 #define NDEBUG_ANY 0xFFFFFFFFUL 61 64 ··· 291 288 292 289 #ifdef __KERNEL__ 293 290 291 + #ifndef NDEBUG 292 + #define NDEBUG (0) 293 + #endif 294 + 295 + #if NDEBUG 296 + #define dprintk(flg, fmt, args...) \ 297 + do { if ((NDEBUG) & (flg)) pr_debug(fmt, ## args); } while (0) 298 + #define NCR5380_dprint(flg, arg) \ 299 + do { if ((NDEBUG) & (flg)) NCR5380_print(arg); } while (0) 300 + #define NCR5380_dprint_phase(flg, arg) \ 301 + do { if ((NDEBUG) & (flg)) NCR5380_print_phase(arg); } while (0) 302 + static void NCR5380_print_phase(struct Scsi_Host *instance); 303 + static void NCR5380_print(struct Scsi_Host *instance); 304 + #else 294 305 #define dprintk(flg, fmt, args...) do {} while (0) 295 306 #define NCR5380_dprint(flg, arg) do {} while (0) 296 307 #define NCR5380_dprint_phase(flg, arg) do {} while (0) 308 + #endif 297 309 298 310 #if defined(AUTOPROBE_IRQ) 299 311 static int NCR5380_probe_irq(struct Scsi_Host *instance, int possible); ··· 321 303 #endif 322 304 static void NCR5380_main(struct work_struct *work); 323 305 static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance); 324 - #ifdef NDEBUG 325 - static void NCR5380_print_phase(struct Scsi_Host *instance); 326 - static void NCR5380_print(struct Scsi_Host *instance); 327 - #endif 328 306 static int NCR5380_abort(Scsi_Cmnd * cmd); 329 307 static int NCR5380_bus_reset(Scsi_Cmnd * cmd); 330 308 static int NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
-10
drivers/scsi/atari_NCR5380.c
··· 626 626 } 627 627 } 628 628 629 - #else /* !NDEBUG */ 630 - 631 - /* dummies... */ 632 - static inline void NCR5380_print(struct Scsi_Host *instance) 633 - { 634 - }; 635 - static inline void NCR5380_print_phase(struct Scsi_Host *instance) 636 - { 637 - }; 638 - 639 629 #endif 640 630 641 631 /*
-6
drivers/scsi/atari_scsi.c
··· 67 67 68 68 #include <linux/module.h> 69 69 70 - #define NDEBUG (0) 71 - 72 - #define NDEBUG_ABORT 0x00100000 73 - #define NDEBUG_TAGS 0x00200000 74 - #define NDEBUG_MERGING 0x00400000 75 - 76 70 #define AUTOSENSE 77 71 /* For the Atari version, use only polled IO or REAL_DMA */ 78 72 #define REAL_DMA
-2
drivers/scsi/dtc.c
··· 3 3 #define PSEUDO_DMA 4 4 #define DONT_USE_INTR 5 5 #define UNSAFE /* Leave interrupts enabled during pseudo-dma I/O */ 6 - #define xNDEBUG (NDEBUG_INTR+NDEBUG_RESELECTION+\ 7 - NDEBUG_SELECTION+NDEBUG_ARBITRATION) 8 6 #define DMA_WORKS_RIGHT 9 7 10 8
-6
drivers/scsi/mac_scsi.c
··· 54 54 55 55 #include "NCR5380.h" 56 56 57 - #if 0 58 - #define NDEBUG (NDEBUG_INTR | NDEBUG_PSEUDO_DMA | NDEBUG_ARBITRATION | NDEBUG_SELECTION | NDEBUG_RESELECTION) 59 - #else 60 - #define NDEBUG (NDEBUG_ABORT) 61 - #endif 62 - 63 57 #define RESET_BOOT 64 58 #define DRIVER_SETUP 65 59
+1 -7
drivers/scsi/sun3_NCR5380.c
··· 484 484 485 485 #include <linux/delay.h> 486 486 487 - #if 1 487 + #if NDEBUG 488 488 static struct { 489 489 unsigned char mask; 490 490 const char * name;} ··· 571 571 printk(KERN_DEBUG "scsi%d: phase %s\n", HOSTNO, phases[i].name); 572 572 } 573 573 } 574 - 575 - #else /* !NDEBUG */ 576 - 577 - /* dummies... */ 578 - __inline__ void NCR5380_print(struct Scsi_Host *instance) { }; 579 - __inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { }; 580 574 581 575 #endif 582 576
-6
drivers/scsi/sun3_scsi.c
··· 65 65 #include <asm/idprom.h> 66 66 #include <asm/machines.h> 67 67 68 - #define NDEBUG 0 69 - 70 - #define NDEBUG_ABORT 0x00100000 71 - #define NDEBUG_TAGS 0x00200000 72 - #define NDEBUG_MERGING 0x00400000 73 - 74 68 /* dma on! */ 75 69 #define REAL_DMA 76 70
-6
drivers/scsi/sun3_scsi_vme.c
··· 38 38 /* dma on! */ 39 39 #define REAL_DMA 40 40 41 - #define NDEBUG 0 42 - 43 - #define NDEBUG_ABORT 0x00100000 44 - #define NDEBUG_TAGS 0x00200000 45 - #define NDEBUG_MERGING 0x00400000 46 - 47 41 #include "scsi.h" 48 42 #include "initio.h" 49 43 #include <scsi/scsi_host.h>