drivers/net/mlx4: Use %pV, pr_<level>, printk_once
authorJoe Perches <joe@perches.com>
Sat, 10 Jul 2010 07:22:46 +0000 (07:22 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Jul 2010 02:05:17 +0000 (19:05 -0700)
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>
drivers/net/mlx4/catas.c
drivers/net/mlx4/en_main.c
drivers/net/mlx4/eq.c
drivers/net/mlx4/main.c
drivers/net/mlx4/mlx4.h
drivers/net/mlx4/mlx4_en.h

index f599294fa8abbe0f7195fb8a7e6b539a60faf618..68aaa42d0ced7b1f93771cacce3ca5abeec786db 100644 (file)
@@ -101,8 +101,8 @@ static void catas_reset(struct work_struct *work)
                ret = mlx4_restart_one(priv->dev.pdev);
                /* 'priv' now is not valid */
                if (ret)
-                       printk(KERN_ERR "mlx4 %s: Reset failed (%d)\n",
-                               pci_name(pdev), ret);
+                       pr_err("mlx4 %s: Reset failed (%d)\n",
+                              pci_name(pdev), ret);
                else {
                        dev  = pci_get_drvdata(pdev);
                        mlx4_dbg(dev, "Reset succeeded\n");
index cbabf14f95d027aa57be9cf77126cd30bae4b0d2..97934f1ec53af83c0dfe40e3b9e8730c83ae1c1e 100644 (file)
@@ -79,6 +79,29 @@ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]."
 MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]."
                           " Per priority bit mask");
 
+int en_print(const char *level, const struct mlx4_en_priv *priv,
+            const char *format, ...)
+{
+       va_list args;
+       struct va_format vaf;
+       int i;
+
+       va_start(args, format);
+
+       vaf.fmt = format;
+       vaf.va = &args;
+       if (priv->registered)
+               i = printk("%s%s: %s: %pV",
+                          level, DRV_NAME, priv->dev->name, &vaf);
+       else
+               i = printk("%s%s: %s: Port %d: %pV",
+                          level, DRV_NAME, dev_name(&priv->mdev->pdev->dev),
+                          priv->port, &vaf);
+       va_end(args);
+
+       return i;
+}
+
 static int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
 {
        struct mlx4_en_profile *params = &mdev->profile;
@@ -152,15 +175,11 @@ static void mlx4_en_remove(struct mlx4_dev *dev, void *endev_ptr)
 
 static void *mlx4_en_add(struct mlx4_dev *dev)
 {
-       static int mlx4_en_version_printed;
        struct mlx4_en_dev *mdev;
        int i;
        int err;
 
-       if (!mlx4_en_version_printed) {
-               printk(KERN_INFO "%s", mlx4_en_version);
-               mlx4_en_version_printed++;
-       }
+       printk_once(KERN_INFO "%s", mlx4_en_version);
 
        mdev = kzalloc(sizeof *mdev, GFP_KERNEL);
        if (!mdev) {
index 22d0b3b796b49cc26721d8d8f47361e9acec6467..6d7b2bf210ceb8818a811699d179819304df8510 100644 (file)
@@ -475,10 +475,10 @@ static void mlx4_free_eq(struct mlx4_dev *dev,
                mlx4_dbg(dev, "Dumping EQ context %02x:\n", eq->eqn);
                for (i = 0; i < sizeof (struct mlx4_eq_context) / 4; ++i) {
                        if (i % 4 == 0)
-                               printk("[%02x] ", i * 4);
-                       printk(" %08x", be32_to_cpup(mailbox->buf + i * 4));
+                               pr_cont("[%02x] ", i * 4);
+                       pr_cont(" %08x", be32_to_cpup(mailbox->buf + i * 4));
                        if ((i + 1) % 4 == 0)
-                               printk("\n");
+                               pr_cont("\n");
                }
        }
 
index e3e0d54a7c87851ca15df3f640326de174dc9a42..5102ab1ac561dbaece380465a9806d886d29f651 100644 (file)
@@ -1050,8 +1050,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        int err;
        int port;
 
-       printk(KERN_INFO PFX "Initializing %s\n",
-              pci_name(pdev));
+       pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev));
 
        err = pci_enable_device(pdev);
        if (err) {
@@ -1216,12 +1215,7 @@ err_disable_pdev:
 static int __devinit mlx4_init_one(struct pci_dev *pdev,
                                   const struct pci_device_id *id)
 {
-       static int mlx4_version_printed;
-
-       if (!mlx4_version_printed) {
-               printk(KERN_INFO "%s", mlx4_version);
-               ++mlx4_version_printed;
-       }
+       printk_once(KERN_INFO "%s", mlx4_version);
 
        return __mlx4_init_one(pdev, id);
 }
@@ -1301,17 +1295,17 @@ static struct pci_driver mlx4_driver = {
 static int __init mlx4_verify_params(void)
 {
        if ((log_num_mac < 0) || (log_num_mac > 7)) {
-               printk(KERN_WARNING "mlx4_core: bad num_mac: %d\n", log_num_mac);
+               pr_warning("mlx4_core: bad num_mac: %d\n", log_num_mac);
                return -1;
        }
 
        if ((log_num_vlan < 0) || (log_num_vlan > 7)) {
-               printk(KERN_WARNING "mlx4_core: bad num_vlan: %d\n", log_num_vlan);
+               pr_warning("mlx4_core: bad num_vlan: %d\n", log_num_vlan);
                return -1;
        }
 
        if ((log_mtts_per_seg < 1) || (log_mtts_per_seg > 5)) {
-               printk(KERN_WARNING "mlx4_core: bad log_mtts_per_seg: %d\n", log_mtts_per_seg);
+               pr_warning("mlx4_core: bad log_mtts_per_seg: %d\n", log_mtts_per_seg);
                return -1;
        }
 
index 13343e8849997d46b0b408e81b7b629f97be9528..0da5bb7285b4c98f1646f5e0ae88cd23d698798b 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/mlx4/doorbell.h>
 
 #define DRV_NAME       "mlx4_core"
-#define PFX            DRV_NAME ": "
 #define DRV_VERSION    "0.01"
 #define DRV_RELDATE    "May 1, 2007"
 
@@ -88,17 +87,17 @@ extern int mlx4_debug_level;
 #endif /* CONFIG_MLX4_DEBUG */
 
 #define mlx4_dbg(mdev, format, arg...)                                 \
-       do {                                                            \
-               if (mlx4_debug_level)                                   \
-                       dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ## arg); \
-       } while (0)
+do {                                                                   \
+       if (mlx4_debug_level)                                           \
+               dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ##arg); \
+} while (0)
 
 #define mlx4_err(mdev, format, arg...) \
-       dev_err(&mdev->pdev->dev, format, ## arg)
+       dev_err(&mdev->pdev->dev, format, ##arg)
 #define mlx4_info(mdev, format, arg...) \
-       dev_info(&mdev->pdev->dev, format, ## arg)
+       dev_info(&mdev->pdev->dev, format, ##arg)
 #define mlx4_warn(mdev, format, arg...) \
-       dev_warn(&mdev->pdev->dev, format, ## arg)
+       dev_warn(&mdev->pdev->dev, format, ##arg)
 
 struct mlx4_bitmap {
        u32                     last;
index b55e46c8b682cefce93fa7179b9964f10c1cf518..449210994ee9cee94323fb3646af114aa4ca3619 100644 (file)
 #define DRV_VERSION    "1.4.1.1"
 #define DRV_RELDATE    "June 2009"
 
-
 #define MLX4_EN_MSG_LEVEL      (NETIF_MSG_LINK | NETIF_MSG_IFDOWN)
 
-#define en_print(level, priv, format, arg...)                  \
-       {                                                       \
-       if ((priv)->registered)                                 \
-               printk(level "%s: %s: " format, DRV_NAME,       \
-                       (priv->dev)->name, ## arg);             \
-       else                                                    \
-               printk(level "%s: %s: Port %d: " format,        \
-                       DRV_NAME, dev_name(&priv->mdev->pdev->dev), \
-                       (priv)->port, ## arg);                  \
-       }
-
-#define en_dbg(mlevel, priv, format, arg...)                   \
-       {                                                       \
-       if (NETIF_MSG_##mlevel & priv->msg_enable)              \
-               en_print(KERN_DEBUG, priv, format, ## arg)      \
-       }
-#define en_warn(priv, format, arg...)                          \
-       en_print(KERN_WARNING, priv, format, ## arg)
-#define en_err(priv, format, arg...)                           \
-       en_print(KERN_ERR, priv, format, ## arg)
-
-#define mlx4_err(mdev, format, arg...) \
-       printk(KERN_ERR "%s %s: " format , DRV_NAME ,\
-               dev_name(&mdev->pdev->dev) , ## arg)
-#define mlx4_info(mdev, format, arg...) \
-       printk(KERN_INFO "%s %s: " format , DRV_NAME ,\
-               dev_name(&mdev->pdev->dev) , ## arg)
-#define mlx4_warn(mdev, format, arg...) \
-       printk(KERN_WARNING "%s %s: " format , DRV_NAME ,\
-               dev_name(&mdev->pdev->dev) , ## arg)
-
 /*
  * Device constants
  */
@@ -568,4 +536,34 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset);
  * Globals
  */
 extern const struct ethtool_ops mlx4_en_ethtool_ops;
+
+
+
+/*
+ * printk / logging functions
+ */
+
+int en_print(const char *level, const struct mlx4_en_priv *priv,
+            const char *format, ...) __attribute__ ((format (printf, 3, 4)));
+
+#define en_dbg(mlevel, priv, format, arg...)                   \
+do {                                                           \
+       if (NETIF_MSG_##mlevel & priv->msg_enable)              \
+               en_print(KERN_DEBUG, priv, format, ##arg);      \
+} while (0)
+#define en_warn(priv, format, arg...)                  \
+       en_print(KERN_WARNING, priv, format, ##arg)
+#define en_err(priv, format, arg...)                   \
+       en_print(KERN_ERR, priv, format, ##arg)
+
+#define mlx4_err(mdev, format, arg...)                 \
+       pr_err("%s %s: " format, DRV_NAME,              \
+              dev_name(&mdev->pdev->dev), ##arg)
+#define mlx4_info(mdev, format, arg...)                        \
+       pr_info("%s %s: " format, DRV_NAME,             \
+               dev_name(&mdev->pdev->dev), ##arg)
+#define mlx4_warn(mdev, format, arg...)                        \
+       pr_warning("%s %s: " format, DRV_NAME,          \
+                  dev_name(&mdev->pdev->dev), ##arg)
+
 #endif