diff options
author | Joe Perches <joe@perches.com> | 2010-07-10 03:22:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-15 22:05:17 -0400 |
commit | 0a645e809759a4b9c876d3e9ca6c139784a97a38 (patch) | |
tree | d9e2e46a9207020fc840f52a869eed045e03fa97 /drivers/net/mlx4 | |
parent | 54874868585ffa5d73d7ab8a5a32ea7dcdec1441 (diff) |
drivers/net/mlx4: Use %pV, pr_<level>, printk_once
Remove near duplication of format string constants by using the newly
introduced vsprintf extention %pV to reduce text by 20k or so.
$ size drivers/net/mlx4/built-in.o*
text data bss dec hex filename
161367 1866 48784 212017 33c31 drivers/net/mlx4/built-in.o
142621 1866 46248 190735 2e90f drivers/net/mlx4/built-in.o.new
Use printk_once as appropriate.
Convert printks to pr_<level>, some bare printks now use pr_cont.
Remove now unused #define PFX.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/mlx4')
-rw-r--r-- | drivers/net/mlx4/catas.c | 4 | ||||
-rw-r--r-- | drivers/net/mlx4/en_main.c | 29 | ||||
-rw-r--r-- | drivers/net/mlx4/eq.c | 6 | ||||
-rw-r--r-- | drivers/net/mlx4/main.c | 16 | ||||
-rw-r--r-- | drivers/net/mlx4/mlx4.h | 15 | ||||
-rw-r--r-- | drivers/net/mlx4/mlx4_en.h | 62 |
6 files changed, 71 insertions, 61 deletions
diff --git a/drivers/net/mlx4/catas.c b/drivers/net/mlx4/catas.c index f599294fa8ab..68aaa42d0ced 100644 --- a/drivers/net/mlx4/catas.c +++ b/drivers/net/mlx4/catas.c | |||
@@ -101,8 +101,8 @@ static void catas_reset(struct work_struct *work) | |||
101 | ret = mlx4_restart_one(priv->dev.pdev); | 101 | ret = mlx4_restart_one(priv->dev.pdev); |
102 | /* 'priv' now is not valid */ | 102 | /* 'priv' now is not valid */ |
103 | if (ret) | 103 | if (ret) |
104 | printk(KERN_ERR "mlx4 %s: Reset failed (%d)\n", | 104 | pr_err("mlx4 %s: Reset failed (%d)\n", |
105 | pci_name(pdev), ret); | 105 | pci_name(pdev), ret); |
106 | else { | 106 | else { |
107 | dev = pci_get_drvdata(pdev); | 107 | dev = pci_get_drvdata(pdev); |
108 | mlx4_dbg(dev, "Reset succeeded\n"); | 108 | mlx4_dbg(dev, "Reset succeeded\n"); |
diff --git a/drivers/net/mlx4/en_main.c b/drivers/net/mlx4/en_main.c index cbabf14f95d0..97934f1ec53a 100644 --- a/drivers/net/mlx4/en_main.c +++ b/drivers/net/mlx4/en_main.c | |||
@@ -79,6 +79,29 @@ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]." | |||
79 | MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]." | 79 | MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]." |
80 | " Per priority bit mask"); | 80 | " Per priority bit mask"); |
81 | 81 | ||
82 | int en_print(const char *level, const struct mlx4_en_priv *priv, | ||
83 | const char *format, ...) | ||
84 | { | ||
85 | va_list args; | ||
86 | struct va_format vaf; | ||
87 | int i; | ||
88 | |||
89 | va_start(args, format); | ||
90 | |||
91 | vaf.fmt = format; | ||
92 | vaf.va = &args; | ||
93 | if (priv->registered) | ||
94 | i = printk("%s%s: %s: %pV", | ||
95 | level, DRV_NAME, priv->dev->name, &vaf); | ||
96 | else | ||
97 | i = printk("%s%s: %s: Port %d: %pV", | ||
98 | level, DRV_NAME, dev_name(&priv->mdev->pdev->dev), | ||
99 | priv->port, &vaf); | ||
100 | va_end(args); | ||
101 | |||
102 | return i; | ||
103 | } | ||
104 | |||
82 | static int mlx4_en_get_profile(struct mlx4_en_dev *mdev) | 105 | static int mlx4_en_get_profile(struct mlx4_en_dev *mdev) |
83 | { | 106 | { |
84 | struct mlx4_en_profile *params = &mdev->profile; | 107 | struct mlx4_en_profile *params = &mdev->profile; |
@@ -152,15 +175,11 @@ static void mlx4_en_remove(struct mlx4_dev *dev, void *endev_ptr) | |||
152 | 175 | ||
153 | static void *mlx4_en_add(struct mlx4_dev *dev) | 176 | static void *mlx4_en_add(struct mlx4_dev *dev) |
154 | { | 177 | { |
155 | static int mlx4_en_version_printed; | ||
156 | struct mlx4_en_dev *mdev; | 178 | struct mlx4_en_dev *mdev; |
157 | int i; | 179 | int i; |
158 | int err; | 180 | int err; |
159 | 181 | ||
160 | if (!mlx4_en_version_printed) { | 182 | printk_once(KERN_INFO "%s", mlx4_en_version); |
161 | printk(KERN_INFO "%s", mlx4_en_version); | ||
162 | mlx4_en_version_printed++; | ||
163 | } | ||
164 | 183 | ||
165 | mdev = kzalloc(sizeof *mdev, GFP_KERNEL); | 184 | mdev = kzalloc(sizeof *mdev, GFP_KERNEL); |
166 | if (!mdev) { | 185 | if (!mdev) { |
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c index 22d0b3b796b4..6d7b2bf210ce 100644 --- a/drivers/net/mlx4/eq.c +++ b/drivers/net/mlx4/eq.c | |||
@@ -475,10 +475,10 @@ static void mlx4_free_eq(struct mlx4_dev *dev, | |||
475 | mlx4_dbg(dev, "Dumping EQ context %02x:\n", eq->eqn); | 475 | mlx4_dbg(dev, "Dumping EQ context %02x:\n", eq->eqn); |
476 | for (i = 0; i < sizeof (struct mlx4_eq_context) / 4; ++i) { | 476 | for (i = 0; i < sizeof (struct mlx4_eq_context) / 4; ++i) { |
477 | if (i % 4 == 0) | 477 | if (i % 4 == 0) |
478 | printk("[%02x] ", i * 4); | 478 | pr_cont("[%02x] ", i * 4); |
479 | printk(" %08x", be32_to_cpup(mailbox->buf + i * 4)); | 479 | pr_cont(" %08x", be32_to_cpup(mailbox->buf + i * 4)); |
480 | if ((i + 1) % 4 == 0) | 480 | if ((i + 1) % 4 == 0) |
481 | printk("\n"); | 481 | pr_cont("\n"); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | 484 | ||
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c index e3e0d54a7c87..5102ab1ac561 100644 --- a/drivers/net/mlx4/main.c +++ b/drivers/net/mlx4/main.c | |||
@@ -1050,8 +1050,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1050 | int err; | 1050 | int err; |
1051 | int port; | 1051 | int port; |
1052 | 1052 | ||
1053 | printk(KERN_INFO PFX "Initializing %s\n", | 1053 | pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev)); |
1054 | pci_name(pdev)); | ||
1055 | 1054 | ||
1056 | err = pci_enable_device(pdev); | 1055 | err = pci_enable_device(pdev); |
1057 | if (err) { | 1056 | if (err) { |
@@ -1216,12 +1215,7 @@ err_disable_pdev: | |||
1216 | static int __devinit mlx4_init_one(struct pci_dev *pdev, | 1215 | static int __devinit mlx4_init_one(struct pci_dev *pdev, |
1217 | const struct pci_device_id *id) | 1216 | const struct pci_device_id *id) |
1218 | { | 1217 | { |
1219 | static int mlx4_version_printed; | 1218 | printk_once(KERN_INFO "%s", mlx4_version); |
1220 | |||
1221 | if (!mlx4_version_printed) { | ||
1222 | printk(KERN_INFO "%s", mlx4_version); | ||
1223 | ++mlx4_version_printed; | ||
1224 | } | ||
1225 | 1219 | ||
1226 | return __mlx4_init_one(pdev, id); | 1220 | return __mlx4_init_one(pdev, id); |
1227 | } | 1221 | } |
@@ -1301,17 +1295,17 @@ static struct pci_driver mlx4_driver = { | |||
1301 | static int __init mlx4_verify_params(void) | 1295 | static int __init mlx4_verify_params(void) |
1302 | { | 1296 | { |
1303 | if ((log_num_mac < 0) || (log_num_mac > 7)) { | 1297 | if ((log_num_mac < 0) || (log_num_mac > 7)) { |
1304 | printk(KERN_WARNING "mlx4_core: bad num_mac: %d\n", log_num_mac); | 1298 | pr_warning("mlx4_core: bad num_mac: %d\n", log_num_mac); |
1305 | return -1; | 1299 | return -1; |
1306 | } | 1300 | } |
1307 | 1301 | ||
1308 | if ((log_num_vlan < 0) || (log_num_vlan > 7)) { | 1302 | if ((log_num_vlan < 0) || (log_num_vlan > 7)) { |
1309 | printk(KERN_WARNING "mlx4_core: bad num_vlan: %d\n", log_num_vlan); | 1303 | pr_warning("mlx4_core: bad num_vlan: %d\n", log_num_vlan); |
1310 | return -1; | 1304 | return -1; |
1311 | } | 1305 | } |
1312 | 1306 | ||
1313 | if ((log_mtts_per_seg < 1) || (log_mtts_per_seg > 5)) { | 1307 | if ((log_mtts_per_seg < 1) || (log_mtts_per_seg > 5)) { |
1314 | printk(KERN_WARNING "mlx4_core: bad log_mtts_per_seg: %d\n", log_mtts_per_seg); | 1308 | pr_warning("mlx4_core: bad log_mtts_per_seg: %d\n", log_mtts_per_seg); |
1315 | return -1; | 1309 | return -1; |
1316 | } | 1310 | } |
1317 | 1311 | ||
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 13343e884999..0da5bb7285b4 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h | |||
@@ -48,7 +48,6 @@ | |||
48 | #include <linux/mlx4/doorbell.h> | 48 | #include <linux/mlx4/doorbell.h> |
49 | 49 | ||
50 | #define DRV_NAME "mlx4_core" | 50 | #define DRV_NAME "mlx4_core" |
51 | #define PFX DRV_NAME ": " | ||
52 | #define DRV_VERSION "0.01" | 51 | #define DRV_VERSION "0.01" |
53 | #define DRV_RELDATE "May 1, 2007" | 52 | #define DRV_RELDATE "May 1, 2007" |
54 | 53 | ||
@@ -88,17 +87,17 @@ extern int mlx4_debug_level; | |||
88 | #endif /* CONFIG_MLX4_DEBUG */ | 87 | #endif /* CONFIG_MLX4_DEBUG */ |
89 | 88 | ||
90 | #define mlx4_dbg(mdev, format, arg...) \ | 89 | #define mlx4_dbg(mdev, format, arg...) \ |
91 | do { \ | 90 | do { \ |
92 | if (mlx4_debug_level) \ | 91 | if (mlx4_debug_level) \ |
93 | dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ## arg); \ | 92 | dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ##arg); \ |
94 | } while (0) | 93 | } while (0) |
95 | 94 | ||
96 | #define mlx4_err(mdev, format, arg...) \ | 95 | #define mlx4_err(mdev, format, arg...) \ |
97 | dev_err(&mdev->pdev->dev, format, ## arg) | 96 | dev_err(&mdev->pdev->dev, format, ##arg) |
98 | #define mlx4_info(mdev, format, arg...) \ | 97 | #define mlx4_info(mdev, format, arg...) \ |
99 | dev_info(&mdev->pdev->dev, format, ## arg) | 98 | dev_info(&mdev->pdev->dev, format, ##arg) |
100 | #define mlx4_warn(mdev, format, arg...) \ | 99 | #define mlx4_warn(mdev, format, arg...) \ |
101 | dev_warn(&mdev->pdev->dev, format, ## arg) | 100 | dev_warn(&mdev->pdev->dev, format, ##arg) |
102 | 101 | ||
103 | struct mlx4_bitmap { | 102 | struct mlx4_bitmap { |
104 | u32 last; | 103 | u32 last; |
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h index b55e46c8b682..449210994ee9 100644 --- a/drivers/net/mlx4/mlx4_en.h +++ b/drivers/net/mlx4/mlx4_en.h | |||
@@ -52,40 +52,8 @@ | |||
52 | #define DRV_VERSION "1.4.1.1" | 52 | #define DRV_VERSION "1.4.1.1" |
53 | #define DRV_RELDATE "June 2009" | 53 | #define DRV_RELDATE "June 2009" |
54 | 54 | ||
55 | |||
56 | #define MLX4_EN_MSG_LEVEL (NETIF_MSG_LINK | NETIF_MSG_IFDOWN) | 55 | #define MLX4_EN_MSG_LEVEL (NETIF_MSG_LINK | NETIF_MSG_IFDOWN) |
57 | 56 | ||
58 | #define en_print(level, priv, format, arg...) \ | ||
59 | { \ | ||
60 | if ((priv)->registered) \ | ||
61 | printk(level "%s: %s: " format, DRV_NAME, \ | ||
62 | (priv->dev)->name, ## arg); \ | ||
63 | else \ | ||
64 | printk(level "%s: %s: Port %d: " format, \ | ||
65 | DRV_NAME, dev_name(&priv->mdev->pdev->dev), \ | ||
66 | (priv)->port, ## arg); \ | ||
67 | } | ||
68 | |||
69 | #define en_dbg(mlevel, priv, format, arg...) \ | ||
70 | { \ | ||
71 | if (NETIF_MSG_##mlevel & priv->msg_enable) \ | ||
72 | en_print(KERN_DEBUG, priv, format, ## arg) \ | ||
73 | } | ||
74 | #define en_warn(priv, format, arg...) \ | ||
75 | en_print(KERN_WARNING, priv, format, ## arg) | ||
76 | #define en_err(priv, format, arg...) \ | ||
77 | en_print(KERN_ERR, priv, format, ## arg) | ||
78 | |||
79 | #define mlx4_err(mdev, format, arg...) \ | ||
80 | printk(KERN_ERR "%s %s: " format , DRV_NAME ,\ | ||
81 | dev_name(&mdev->pdev->dev) , ## arg) | ||
82 | #define mlx4_info(mdev, format, arg...) \ | ||
83 | printk(KERN_INFO "%s %s: " format , DRV_NAME ,\ | ||
84 | dev_name(&mdev->pdev->dev) , ## arg) | ||
85 | #define mlx4_warn(mdev, format, arg...) \ | ||
86 | printk(KERN_WARNING "%s %s: " format , DRV_NAME ,\ | ||
87 | dev_name(&mdev->pdev->dev) , ## arg) | ||
88 | |||
89 | /* | 57 | /* |
90 | * Device constants | 58 | * Device constants |
91 | */ | 59 | */ |
@@ -568,4 +536,34 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset); | |||
568 | * Globals | 536 | * Globals |
569 | */ | 537 | */ |
570 | extern const struct ethtool_ops mlx4_en_ethtool_ops; | 538 | extern const struct ethtool_ops mlx4_en_ethtool_ops; |
539 | |||
540 | |||
541 | |||
542 | /* | ||
543 | * printk / logging functions | ||
544 | */ | ||
545 | |||
546 | int en_print(const char *level, const struct mlx4_en_priv *priv, | ||
547 | const char *format, ...) __attribute__ ((format (printf, 3, 4))); | ||
548 | |||
549 | #define en_dbg(mlevel, priv, format, arg...) \ | ||
550 | do { \ | ||
551 | if (NETIF_MSG_##mlevel & priv->msg_enable) \ | ||
552 | en_print(KERN_DEBUG, priv, format, ##arg); \ | ||
553 | } while (0) | ||
554 | #define en_warn(priv, format, arg...) \ | ||
555 | en_print(KERN_WARNING, priv, format, ##arg) | ||
556 | #define en_err(priv, format, arg...) \ | ||
557 | en_print(KERN_ERR, priv, format, ##arg) | ||
558 | |||
559 | #define mlx4_err(mdev, format, arg...) \ | ||
560 | pr_err("%s %s: " format, DRV_NAME, \ | ||
561 | dev_name(&mdev->pdev->dev), ##arg) | ||
562 | #define mlx4_info(mdev, format, arg...) \ | ||
563 | pr_info("%s %s: " format, DRV_NAME, \ | ||
564 | dev_name(&mdev->pdev->dev), ##arg) | ||
565 | #define mlx4_warn(mdev, format, arg...) \ | ||
566 | pr_warning("%s %s: " format, DRV_NAME, \ | ||
567 | dev_name(&mdev->pdev->dev), ##arg) | ||
568 | |||
571 | #endif | 569 | #endif |