diff options
author | Joe Perches <joe@perches.com> | 2012-06-04 19:15:43 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-07-20 03:58:17 -0400 |
commit | 3db8cc106569aa81088ee83d46f52a631471811c (patch) | |
tree | ddade5c46c44efe7758347a526ed31d36780de60 /drivers/scsi/bnx2fc | |
parent | 69614270e19cc0ea1be6539f99b59b0dd0be142a (diff) |
[SCSI] bnx2fc: Reduce object size by consolidating formats
Deduplication of formats and consolidating tests
makes the object much smaller.
Add bnx2fc_debug.c, add functions for a few logging
functions (BNX2FC_IO_DBG, BNX2FC_TGT_DBG, BNX2FC_HBA_DBG).
Use printf extension %pV.
Add and use pr_fmt and pr_<level>.
Move the debug #include below structure definitions.
$ size drivers/scsi/bnx2fc/built-in.o*
text data bss dec hex filename
101563 1165 24976 127704 1f2d8 drivers/scsi/bnx2fc/built-in.o.new
138473 1109 33400 172982 2a3b6 drivers/scsi/bnx2fc/built-in.o.old
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bnx2fc')
-rw-r--r-- | drivers/scsi/bnx2fc/Makefile | 3 | ||||
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc.h | 6 | ||||
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_debug.c | 70 | ||||
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_debug.h | 73 |
4 files changed, 95 insertions, 57 deletions
diff --git a/drivers/scsi/bnx2fc/Makefile b/drivers/scsi/bnx2fc/Makefile index a92695a25176..141149e8cdad 100644 --- a/drivers/scsi/bnx2fc/Makefile +++ b/drivers/scsi/bnx2fc/Makefile | |||
@@ -1,3 +1,4 @@ | |||
1 | obj-$(CONFIG_SCSI_BNX2X_FCOE) += bnx2fc.o | 1 | obj-$(CONFIG_SCSI_BNX2X_FCOE) += bnx2fc.o |
2 | 2 | ||
3 | bnx2fc-y := bnx2fc_els.o bnx2fc_fcoe.o bnx2fc_hwi.o bnx2fc_io.o bnx2fc_tgt.o | 3 | bnx2fc-y := bnx2fc_els.o bnx2fc_fcoe.o bnx2fc_hwi.o bnx2fc_io.o bnx2fc_tgt.o \ |
4 | bnx2fc_debug.o | ||
diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index 0578fa0dc14b..2f1bea42336f 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h | |||
@@ -11,6 +11,8 @@ | |||
11 | * Written by: Bhanu Prakash Gollapudi (bprakash@broadcom.com) | 11 | * Written by: Bhanu Prakash Gollapudi (bprakash@broadcom.com) |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
14 | #include <linux/module.h> | 16 | #include <linux/module.h> |
15 | #include <linux/moduleparam.h> | 17 | #include <linux/moduleparam.h> |
16 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
@@ -57,7 +59,6 @@ | |||
57 | #include <scsi/fc/fc_fcp.h> | 59 | #include <scsi/fc/fc_fcp.h> |
58 | 60 | ||
59 | #include "57xx_hsi_bnx2fc.h" | 61 | #include "57xx_hsi_bnx2fc.h" |
60 | #include "bnx2fc_debug.h" | ||
61 | #include "../../net/ethernet/broadcom/cnic_if.h" | 62 | #include "../../net/ethernet/broadcom/cnic_if.h" |
62 | #include "bnx2fc_constants.h" | 63 | #include "bnx2fc_constants.h" |
63 | 64 | ||
@@ -554,4 +555,7 @@ void bnx2fc_process_seq_cleanup_compl(struct bnx2fc_cmd *seq_clnup_req, | |||
554 | int bnx2fc_initiate_seq_cleanup(struct bnx2fc_cmd *orig_io_req, u32 offset, | 555 | int bnx2fc_initiate_seq_cleanup(struct bnx2fc_cmd *orig_io_req, u32 offset, |
555 | enum fc_rctl r_ctl); | 556 | enum fc_rctl r_ctl); |
556 | 557 | ||
558 | |||
559 | #include "bnx2fc_debug.h" | ||
560 | |||
557 | #endif | 561 | #endif |
diff --git a/drivers/scsi/bnx2fc/bnx2fc_debug.c b/drivers/scsi/bnx2fc/bnx2fc_debug.c new file mode 100644 index 000000000000..0cbee1b23ee2 --- /dev/null +++ b/drivers/scsi/bnx2fc/bnx2fc_debug.c | |||
@@ -0,0 +1,70 @@ | |||
1 | #include "bnx2fc.h" | ||
2 | |||
3 | void BNX2FC_IO_DBG(const struct bnx2fc_cmd *io_req, const char *fmt, ...) | ||
4 | { | ||
5 | struct va_format vaf; | ||
6 | va_list args; | ||
7 | |||
8 | if (likely(!(bnx2fc_debug_level & LOG_IO))) | ||
9 | return; | ||
10 | |||
11 | va_start(args, fmt); | ||
12 | |||
13 | vaf.fmt = fmt; | ||
14 | vaf.va = &args; | ||
15 | |||
16 | if (io_req && io_req->port && io_req->port->lport && | ||
17 | io_req->port->lport->host) | ||
18 | shost_printk(KERN_INFO, io_req->port->lport->host, | ||
19 | PFX "xid:0x%x %pV", | ||
20 | io_req->xid, &vaf); | ||
21 | else | ||
22 | pr_info("NULL %pV", &vaf); | ||
23 | |||
24 | va_end(args); | ||
25 | } | ||
26 | |||
27 | void BNX2FC_TGT_DBG(const struct bnx2fc_rport *tgt, const char *fmt, ...) | ||
28 | { | ||
29 | struct va_format vaf; | ||
30 | va_list args; | ||
31 | |||
32 | if (likely(!(bnx2fc_debug_level & LOG_TGT))) | ||
33 | return; | ||
34 | |||
35 | va_start(args, fmt); | ||
36 | |||
37 | vaf.fmt = fmt; | ||
38 | vaf.va = &args; | ||
39 | |||
40 | if (tgt && tgt->port && tgt->port->lport && tgt->port->lport->host && | ||
41 | tgt->rport) | ||
42 | shost_printk(KERN_INFO, tgt->port->lport->host, | ||
43 | PFX "port:%x %pV", | ||
44 | tgt->rport->port_id, &vaf); | ||
45 | else | ||
46 | pr_info("NULL %pV", &vaf); | ||
47 | |||
48 | va_end(args); | ||
49 | } | ||
50 | |||
51 | void BNX2FC_HBA_DBG(const struct fc_lport *lport, const char *fmt, ...) | ||
52 | { | ||
53 | struct va_format vaf; | ||
54 | va_list args; | ||
55 | |||
56 | if (likely(!(bnx2fc_debug_level & LOG_HBA))) | ||
57 | return; | ||
58 | |||
59 | va_start(args, fmt); | ||
60 | |||
61 | vaf.fmt = fmt; | ||
62 | vaf.va = &args; | ||
63 | |||
64 | if (lport && lport->host) | ||
65 | shost_printk(KERN_INFO, lport->host, PFX "%pV", &vaf); | ||
66 | else | ||
67 | pr_info("NULL %pV", &vaf); | ||
68 | |||
69 | va_end(args); | ||
70 | } | ||
diff --git a/drivers/scsi/bnx2fc/bnx2fc_debug.h b/drivers/scsi/bnx2fc/bnx2fc_debug.h index 3416d9a746c7..4808ff99621f 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_debug.h +++ b/drivers/scsi/bnx2fc/bnx2fc_debug.h | |||
@@ -11,60 +11,23 @@ | |||
11 | 11 | ||
12 | extern unsigned int bnx2fc_debug_level; | 12 | extern unsigned int bnx2fc_debug_level; |
13 | 13 | ||
14 | #define BNX2FC_CHK_LOGGING(LEVEL, CMD) \ | 14 | #define BNX2FC_ELS_DBG(fmt, ...) \ |
15 | do { \ | 15 | do { \ |
16 | if (unlikely(bnx2fc_debug_level & LEVEL)) \ | 16 | if (unlikely(bnx2fc_debug_level & LOG_ELS)) \ |
17 | do { \ | 17 | pr_info(fmt, ##__VA_ARGS__); \ |
18 | CMD; \ | 18 | } while (0) |
19 | } while (0); \ | 19 | |
20 | } while (0) | 20 | #define BNX2FC_MISC_DBG(fmt, ...) \ |
21 | 21 | do { \ | |
22 | #define BNX2FC_ELS_DBG(fmt, arg...) \ | 22 | if (unlikely(bnx2fc_debug_level & LOG_MISC)) \ |
23 | BNX2FC_CHK_LOGGING(LOG_ELS, \ | 23 | pr_info(fmt, ##__VA_ARGS__); \ |
24 | printk(KERN_INFO PFX fmt, ##arg)) | 24 | } while (0) |
25 | 25 | ||
26 | #define BNX2FC_MISC_DBG(fmt, arg...) \ | 26 | __printf(2, 3) |
27 | BNX2FC_CHK_LOGGING(LOG_MISC, \ | 27 | void BNX2FC_IO_DBG(const struct bnx2fc_cmd *io_req, const char *fmt, ...); |
28 | printk(KERN_INFO PFX fmt, ##arg)) | 28 | __printf(2, 3) |
29 | 29 | void BNX2FC_TGT_DBG(const struct bnx2fc_rport *tgt, const char *fmt, ...); | |
30 | #define BNX2FC_IO_DBG(io_req, fmt, arg...) \ | 30 | __printf(2, 3) |
31 | do { \ | 31 | void BNX2FC_HBA_DBG(const struct fc_lport *lport, const char *fmt, ...); |
32 | if (!io_req || !io_req->port || !io_req->port->lport || \ | ||
33 | !io_req->port->lport->host) \ | ||
34 | BNX2FC_CHK_LOGGING(LOG_IO, \ | ||
35 | printk(KERN_INFO PFX "NULL " fmt, ##arg)); \ | ||
36 | else \ | ||
37 | BNX2FC_CHK_LOGGING(LOG_IO, \ | ||
38 | shost_printk(KERN_INFO, \ | ||
39 | (io_req)->port->lport->host, \ | ||
40 | PFX "xid:0x%x " fmt, \ | ||
41 | (io_req)->xid, ##arg)); \ | ||
42 | } while (0) | ||
43 | |||
44 | #define BNX2FC_TGT_DBG(tgt, fmt, arg...) \ | ||
45 | do { \ | ||
46 | if (!tgt || !tgt->port || !tgt->port->lport || \ | ||
47 | !tgt->port->lport->host || !tgt->rport) \ | ||
48 | BNX2FC_CHK_LOGGING(LOG_TGT, \ | ||
49 | printk(KERN_INFO PFX "NULL " fmt, ##arg)); \ | ||
50 | else \ | ||
51 | BNX2FC_CHK_LOGGING(LOG_TGT, \ | ||
52 | shost_printk(KERN_INFO, \ | ||
53 | (tgt)->port->lport->host, \ | ||
54 | PFX "port:%x " fmt, \ | ||
55 | (tgt)->rport->port_id, ##arg)); \ | ||
56 | } while (0) | ||
57 | |||
58 | |||
59 | #define BNX2FC_HBA_DBG(lport, fmt, arg...) \ | ||
60 | do { \ | ||
61 | if (!lport || !lport->host) \ | ||
62 | BNX2FC_CHK_LOGGING(LOG_HBA, \ | ||
63 | printk(KERN_INFO PFX "NULL " fmt, ##arg)); \ | ||
64 | else \ | ||
65 | BNX2FC_CHK_LOGGING(LOG_HBA, \ | ||
66 | shost_printk(KERN_INFO, lport->host, \ | ||
67 | PFX fmt, ##arg)); \ | ||
68 | } while (0) | ||
69 | 32 | ||
70 | #endif | 33 | #endif |