[ovs-dev] [PATCH 2/2] treewide: Use pr_fmt and pr_<level>

Joe Perches joe at perches.com
Mon Aug 30 07:24:54 UTC 2010


Signed-off-by: Joe Perches <joe at perches.com>
---
 datapath/brc_procfs.c                              |    8 ++++--
 datapath/brcompat.c                                |    6 +++-
 datapath/datapath.c                                |   15 ++++++-----
 datapath/linux-2.6/compat-2.6/skbuff-openvswitch.c |    6 +++-
 datapath/vport-capwap.c                            |    8 ++++--
 datapath/vport-gre.c                               |    2 +-
 datapath/vport.c                                   |   24 +++++++++++--------
 7 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/datapath/brc_procfs.c b/datapath/brc_procfs.c
index cfe0175..bf328c9 100644
--- a/datapath/brc_procfs.c
+++ b/datapath/brc_procfs.c
@@ -6,6 +6,8 @@
  * kernel, by Linus Torvalds and others.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
@@ -69,9 +71,9 @@ static struct proc_dir_entry *brc_open_dir(const char *dir_name,
 	if (!*dirp) {
 		struct proc_dir_entry *dir;
 		if (brc_lookup_entry(parent, dir_name)) {
-			printk(KERN_WARNING "%s proc directory exists, can't "
-			       "simulate--probably its real module is "
-			       "loaded\n", dir_name);
+			pr_warn("%s proc directory exists, can't simulate--"
+				"probably its real module is loaded\n",
+				dir_name);
 			return NULL;
 		}
 		dir = *dirp = proc_mkdir(dir_name, parent);
diff --git a/datapath/brcompat.c b/datapath/brcompat.c
index f68b698..3e84011 100644
--- a/datapath/brcompat.c
+++ b/datapath/brcompat.c
@@ -6,6 +6,8 @@
  * kernel, by Linus Torvalds and others.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <asm/uaccess.h>
 #include <linux/completion.h>
@@ -481,7 +483,7 @@ static struct sk_buff *brc_send_command(struct sk_buff *request,
 	/* Wait for reply. */
 	error = -ETIMEDOUT;
 	if (!wait_for_completion_timeout(&brc_done, BRC_TIMEOUT)) {
-		printk(KERN_WARNING "brcompat: timed out waiting for userspace\n");
+		pr_warn("timed out waiting for userspace\n");
 		goto error;
     }
 
@@ -551,7 +553,7 @@ static int __init brc_init(void)
 err_unregister:
 	genl_unregister_family(&brc_genl_family);
 error:
-	printk(KERN_EMERG "brcompat: failed to install!");
+	pr_emerg("failed to install!\n");
 	return err;
 }
 
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 4f15ea0..5ee9157 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -8,6 +8,8 @@
 
 /* Functions for managing the dp interface/device. */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/fs.h>
@@ -531,8 +533,8 @@ out:
 static void suppress_loop(struct datapath *dp, struct sw_flow_actions *actions)
 {
 	if (net_ratelimit())
-		printk(KERN_WARNING "%s: flow looped %d times, dropping\n",
-		       dp_name(dp), DP_MAX_LOOPS);
+		pr_warn("%s: flow looped %d times, dropping\n",
+			dp_name(dp), DP_MAX_LOOPS);
 	actions->n_actions = 0;
 }
 
@@ -645,9 +647,9 @@ int vswitch_skb_checksum_setup(struct sk_buff *skb)
 		break;
 	default:
 		if (net_ratelimit())
-			printk(KERN_ERR "Attempting to checksum a non-"
-			       "TCP/UDP packet, dropping a protocol"
-			       " %d packet", iph->protocol);
+			pr_err("Attempting to checksum a non-TCP/UDP packet, "
+			       "dropping a protocol %d packet",
+			       iph->protocol);
 		goto out;
 	}
 
@@ -750,8 +752,7 @@ void compute_ip_summed(struct sk_buff *skb, bool xmit)
 		break;
 #endif
 	default:
-		printk(KERN_ERR "openvswitch: unknown checksum type %d\n",
-		       skb->ip_summed);
+		pr_err("unknown checksum type %d\n", skb->ip_summed);
 		/* None seems the safest... */
 		OVS_CB(skb)->ip_summed = OVS_CSUM_NONE;
 	}
diff --git a/datapath/linux-2.6/compat-2.6/skbuff-openvswitch.c b/datapath/linux-2.6/compat-2.6/skbuff-openvswitch.c
index e639b5a..ef43ba9 100644
--- a/datapath/linux-2.6/compat-2.6/skbuff-openvswitch.c
+++ b/datapath/linux-2.6/compat-2.6/skbuff-openvswitch.c
@@ -1,12 +1,14 @@
 #if !defined(HAVE_SKB_WARN_LRO) && defined(NETIF_F_LRO)
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/netdevice.h>
 
 void __skb_warn_lro_forwarding(const struct sk_buff *skb)
 {
 	if (net_ratelimit())
-		printk(KERN_WARNING "%s: received packets cannot be forwarded"
-				    " while LRO is enabled\n", skb->dev->name);
+		pr_warn("%s: received packets cannot be forwarded while LRO is enabled\n",
+			skb->dev->name);
 }
 
 #endif
diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c
index 59fb051..ce8cc43 100644
--- a/datapath/vport-capwap.c
+++ b/datapath/vport-capwap.c
@@ -6,6 +6,8 @@
  * kernel, by Linus Torvalds and others.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/version.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
 
@@ -160,7 +162,7 @@ static inline struct sk_buff *process_capwap_proto(struct sk_buff *skb)
 		return defrag(skb, true);
 	else {
 		if (net_ratelimit())
-			printk(KERN_WARNING "openvswitch: unparsable packet receive on capwap socket\n");
+			pr_warn("unparsable packet receive on capwap socket\n");
 
 		kfree_skb(skb);
 		return NULL;
@@ -243,7 +245,7 @@ static int capwap_init(void)
 error_sock:
 	sock_release(capwap_rcv_socket);
 error:
-	printk(KERN_WARNING "openvswitch: cannot register capwap protocol handler\n");
+	pr_warn("cannot register capwap protocol handler\n");
 	return err;
 }
 
@@ -288,7 +290,7 @@ static struct sk_buff *fragment(struct sk_buff *skb, const struct vport *vport,
 
 	if (hlen + ~FRAG_OFF_MASK + 1 > dst_mtu(dst)) {
 		if (net_ratelimit())
-			printk(KERN_WARNING "openvswitch: capwap link mtu (%d) is less than minimum packet (%d)\n",
+			pr_warn("capwap link mtu (%d) is less than minimum packet (%d)\n",
 				dst_mtu(dst), hlen + ~FRAG_OFF_MASK + 1);
 		goto error;
 	}
diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
index 223644e..789d32e 100644
--- a/datapath/vport-gre.c
+++ b/datapath/vport-gre.c
@@ -345,7 +345,7 @@ static int gre_init(void)
 
 	err = inet_add_protocol(&gre_protocol_handlers, IPPROTO_GRE);
 	if (err) {
-		printk(KERN_WARNING "openvswitch: cannot register gre protocol handler\n");
+		pr_warn("cannot register gre protocol handler\n");
 		goto out;
 	}
 
diff --git a/datapath/vport.c b/datapath/vport.c
index 4dd6cfe..91b650e 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -6,6 +6,8 @@
  * kernel, by Linus Torvalds and others.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/dcache.h>
 #include <linux/etherdevice.h>
 #include <linux/if.h>
@@ -76,13 +78,14 @@ void vport_unlock(void)
 	mutex_unlock(&vport_mutex);
 }
 
-#define ASSERT_VPORT() do { \
-	if (unlikely(!mutex_is_locked(&vport_mutex))) { \
-		printk(KERN_ERR "openvswitch: vport lock not held at %s (%d)\n", \
-			__FILE__, __LINE__); \
-		dump_stack(); \
-	} \
-} while(0)
+#define ASSERT_VPORT()						\
+do {								\
+	if (unlikely(!mutex_is_locked(&vport_mutex))) {		\
+		pr_err("vport lock not held at %s (%d)\n",	\
+		       __FILE__, __LINE__);			\
+		dump_stack();					\
+	}							\
+} while (0)
 
 /**
  *	vport_init - initialize vport subsystem
@@ -616,7 +619,7 @@ struct vport *vport_locate(const char *name)
 	struct hlist_node *node;
 
 	if (unlikely(!mutex_is_locked(&vport_mutex) && !rtnl_is_locked())) {
-		printk(KERN_ERR "openvswitch: neither RTNL nor vport lock held in vport_locate\n");
+		pr_err("neither RTNL nor vport lock held in vport_locate\n");
 		dump_stack();
 	}
 
@@ -1247,8 +1250,9 @@ int vport_send(struct vport *vport, struct sk_buff *skb)
 	mtu = vport_get_mtu(vport);
 	if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) {
 		if (net_ratelimit())
-			printk(KERN_WARNING "%s: dropped over-mtu packet: %d > %d\n",
-			       dp_name(vport_get_dp_port(vport)->dp), packet_length(skb), mtu);
+			pr_warn("%s: dropped over-mtu packet: %d > %d\n",
+				dp_name(vport_get_dp_port(vport)->dp),
+				packet_length(skb), mtu);
 		goto error;
 	}
 
-- 
1.7.2.19.g9a302





More information about the dev mailing list