提交 e6ec2693 编写于 作者: J Joe Perches 提交者: David S. Miller

netpoll: Convert printks to np_<level> and add pr_fmt

Use a more current message logging style.
Add pr_fmt to prefix dmesg output with "netpoll: "
Add macros to print np->name.
Signed-off-by: NJoe Perches <joe@perches.com>
Reviewed-by: NWANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b5d5843a
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* Copyright (C) 2002 Red Hat, Inc. * Copyright (C) 2002 Red Hat, Inc.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
...@@ -55,6 +57,13 @@ static void arp_reply(struct sk_buff *skb); ...@@ -55,6 +57,13 @@ static void arp_reply(struct sk_buff *skb);
static unsigned int carrier_timeout = 4; static unsigned int carrier_timeout = 4;
module_param(carrier_timeout, uint, 0644); module_param(carrier_timeout, uint, 0644);
#define np_info(np, fmt, ...) \
pr_info("%s: " fmt, np->name, ##__VA_ARGS__)
#define np_err(np, fmt, ...) \
pr_err("%s: " fmt, np->name, ##__VA_ARGS__)
#define np_notice(np, fmt, ...) \
pr_notice("%s: " fmt, np->name, ##__VA_ARGS__)
static void queue_process(struct work_struct *work) static void queue_process(struct work_struct *work)
{ {
struct netpoll_info *npinfo = struct netpoll_info *npinfo =
...@@ -627,18 +636,12 @@ int __netpoll_rx(struct sk_buff *skb) ...@@ -627,18 +636,12 @@ int __netpoll_rx(struct sk_buff *skb)
void netpoll_print_options(struct netpoll *np) void netpoll_print_options(struct netpoll *np)
{ {
printk(KERN_INFO "%s: local port %d\n", np_info(np, "local port %d\n", np->local_port);
np->name, np->local_port); np_info(np, "local IP %pI4\n", &np->local_ip);
printk(KERN_INFO "%s: local IP %pI4\n", np_info(np, "interface '%s'\n", np->dev_name);
np->name, &np->local_ip); np_info(np, "remote port %d\n", np->remote_port);
printk(KERN_INFO "%s: interface '%s'\n", np_info(np, "remote IP %pI4\n", &np->remote_ip);
np->name, np->dev_name); np_info(np, "remote ethernet address %pM\n", np->remote_mac);
printk(KERN_INFO "%s: remote port %d\n",
np->name, np->remote_port);
printk(KERN_INFO "%s: remote IP %pI4\n",
np->name, &np->remote_ip);
printk(KERN_INFO "%s: remote ethernet address %pM\n",
np->name, np->remote_mac);
} }
EXPORT_SYMBOL(netpoll_print_options); EXPORT_SYMBOL(netpoll_print_options);
...@@ -680,8 +683,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt) ...@@ -680,8 +683,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
goto parse_failed; goto parse_failed;
*delim = 0; *delim = 0;
if (*cur == ' ' || *cur == '\t') if (*cur == ' ' || *cur == '\t')
printk(KERN_INFO "%s: warning: whitespace" np_info(np, "warning: whitespace is not allowed\n");
"is not allowed\n", np->name);
np->remote_port = simple_strtol(cur, NULL, 10); np->remote_port = simple_strtol(cur, NULL, 10);
cur = delim; cur = delim;
} }
...@@ -705,8 +707,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt) ...@@ -705,8 +707,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
return 0; return 0;
parse_failed: parse_failed:
printk(KERN_INFO "%s: couldn't parse config at '%s'!\n", np_info(np, "couldn't parse config at '%s'!\n", cur);
np->name, cur);
return -1; return -1;
} }
EXPORT_SYMBOL(netpoll_parse_options); EXPORT_SYMBOL(netpoll_parse_options);
...@@ -721,8 +722,8 @@ int __netpoll_setup(struct netpoll *np) ...@@ -721,8 +722,8 @@ int __netpoll_setup(struct netpoll *np)
if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) || if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) ||
!ndev->netdev_ops->ndo_poll_controller) { !ndev->netdev_ops->ndo_poll_controller) {
printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", np_err(np, "%s doesn't support polling, aborting\n",
np->name, np->dev_name); np->dev_name);
err = -ENOTSUPP; err = -ENOTSUPP;
goto out; goto out;
} }
...@@ -785,14 +786,12 @@ int netpoll_setup(struct netpoll *np) ...@@ -785,14 +786,12 @@ int netpoll_setup(struct netpoll *np)
if (np->dev_name) if (np->dev_name)
ndev = dev_get_by_name(&init_net, np->dev_name); ndev = dev_get_by_name(&init_net, np->dev_name);
if (!ndev) { if (!ndev) {
printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", np_err(np, "%s doesn't exist, aborting\n", np->dev_name);
np->name, np->dev_name);
return -ENODEV; return -ENODEV;
} }
if (ndev->master) { if (ndev->master) {
printk(KERN_ERR "%s: %s is a slave device, aborting.\n", np_err(np, "%s is a slave device, aborting\n", np->dev_name);
np->name, np->dev_name);
err = -EBUSY; err = -EBUSY;
goto put; goto put;
} }
...@@ -800,16 +799,14 @@ int netpoll_setup(struct netpoll *np) ...@@ -800,16 +799,14 @@ int netpoll_setup(struct netpoll *np)
if (!netif_running(ndev)) { if (!netif_running(ndev)) {
unsigned long atmost, atleast; unsigned long atmost, atleast;
printk(KERN_INFO "%s: device %s not up yet, forcing it\n", np_info(np, "device %s not up yet, forcing it\n", np->dev_name);
np->name, np->dev_name);
rtnl_lock(); rtnl_lock();
err = dev_open(ndev); err = dev_open(ndev);
rtnl_unlock(); rtnl_unlock();
if (err) { if (err) {
printk(KERN_ERR "%s: failed to open %s\n", np_err(np, "failed to open %s\n", ndev->name);
np->name, ndev->name);
goto put; goto put;
} }
...@@ -817,9 +814,7 @@ int netpoll_setup(struct netpoll *np) ...@@ -817,9 +814,7 @@ int netpoll_setup(struct netpoll *np)
atmost = jiffies + carrier_timeout * HZ; atmost = jiffies + carrier_timeout * HZ;
while (!netif_carrier_ok(ndev)) { while (!netif_carrier_ok(ndev)) {
if (time_after(jiffies, atmost)) { if (time_after(jiffies, atmost)) {
printk(KERN_NOTICE np_notice(np, "timeout waiting for carrier\n");
"%s: timeout waiting for carrier\n",
np->name);
break; break;
} }
msleep(1); msleep(1);
...@@ -831,9 +826,7 @@ int netpoll_setup(struct netpoll *np) ...@@ -831,9 +826,7 @@ int netpoll_setup(struct netpoll *np)
*/ */
if (time_before(jiffies, atleast)) { if (time_before(jiffies, atleast)) {
printk(KERN_NOTICE "%s: carrier detect appears" np_notice(np, "carrier detect appears untrustworthy, waiting 4 seconds\n");
" untrustworthy, waiting 4 seconds\n",
np->name);
msleep(4000); msleep(4000);
} }
} }
...@@ -844,15 +837,15 @@ int netpoll_setup(struct netpoll *np) ...@@ -844,15 +837,15 @@ int netpoll_setup(struct netpoll *np)
if (!in_dev || !in_dev->ifa_list) { if (!in_dev || !in_dev->ifa_list) {
rcu_read_unlock(); rcu_read_unlock();
printk(KERN_ERR "%s: no IP address for %s, aborting\n", np_err(np, "no IP address for %s, aborting\n",
np->name, np->dev_name); np->dev_name);
err = -EDESTADDRREQ; err = -EDESTADDRREQ;
goto put; goto put;
} }
np->local_ip = in_dev->ifa_list->ifa_local; np->local_ip = in_dev->ifa_list->ifa_local;
rcu_read_unlock(); rcu_read_unlock();
printk(KERN_INFO "%s: local IP %pI4\n", np->name, &np->local_ip); np_info(np, "local IP %pI4\n", &np->local_ip);
} }
np->dev = ndev; np->dev = ndev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册