aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/netpoll.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-01-29 10:50:43 -0500
committerDavid S. Miller <davem@davemloft.net>2012-02-01 14:20:27 -0500
commite6ec26935aec629f03e76c67f3bbda68dd0155e2 (patch)
tree44623331c45f46177a7ce90831121aedcd5a0754 /net/core/netpoll.c
parentb5d5843a1dd0031d63d9d9484346d86eae9cab3b (diff)
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: Joe Perches <joe@perches.com> Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/netpoll.c')
-rw-r--r--net/core/netpoll.c63
1 files changed, 28 insertions, 35 deletions
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 556b08298669..b5232743d5dc 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -9,6 +9,8 @@
9 * Copyright (C) 2002 Red Hat, Inc. 9 * Copyright (C) 2002 Red Hat, Inc.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
13#include <linux/netdevice.h> 15#include <linux/netdevice.h>
14#include <linux/etherdevice.h> 16#include <linux/etherdevice.h>
@@ -55,6 +57,13 @@ static void arp_reply(struct sk_buff *skb);
55static unsigned int carrier_timeout = 4; 57static unsigned int carrier_timeout = 4;
56module_param(carrier_timeout, uint, 0644); 58module_param(carrier_timeout, uint, 0644);
57 59
60#define np_info(np, fmt, ...) \
61 pr_info("%s: " fmt, np->name, ##__VA_ARGS__)
62#define np_err(np, fmt, ...) \
63 pr_err("%s: " fmt, np->name, ##__VA_ARGS__)
64#define np_notice(np, fmt, ...) \
65 pr_notice("%s: " fmt, np->name, ##__VA_ARGS__)
66
58static void queue_process(struct work_struct *work) 67static void queue_process(struct work_struct *work)
59{ 68{
60 struct netpoll_info *npinfo = 69 struct netpoll_info *npinfo =
@@ -627,18 +636,12 @@ out:
627 636
628void netpoll_print_options(struct netpoll *np) 637void netpoll_print_options(struct netpoll *np)
629{ 638{
630 printk(KERN_INFO "%s: local port %d\n", 639 np_info(np, "local port %d\n", np->local_port);
631 np->name, np->local_port); 640 np_info(np, "local IP %pI4\n", &np->local_ip);
632 printk(KERN_INFO "%s: local IP %pI4\n", 641 np_info(np, "interface '%s'\n", np->dev_name);
633 np->name, &np->local_ip); 642 np_info(np, "remote port %d\n", np->remote_port);
634 printk(KERN_INFO "%s: interface '%s'\n", 643 np_info(np, "remote IP %pI4\n", &np->remote_ip);
635 np->name, np->dev_name); 644 np_info(np, "remote ethernet address %pM\n", np->remote_mac);
636 printk(KERN_INFO "%s: remote port %d\n",
637 np->name, np->remote_port);
638 printk(KERN_INFO "%s: remote IP %pI4\n",
639 np->name, &np->remote_ip);
640 printk(KERN_INFO "%s: remote ethernet address %pM\n",
641 np->name, np->remote_mac);
642} 645}
643EXPORT_SYMBOL(netpoll_print_options); 646EXPORT_SYMBOL(netpoll_print_options);
644 647
@@ -680,8 +683,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
680 goto parse_failed; 683 goto parse_failed;
681 *delim = 0; 684 *delim = 0;
682 if (*cur == ' ' || *cur == '\t') 685 if (*cur == ' ' || *cur == '\t')
683 printk(KERN_INFO "%s: warning: whitespace" 686 np_info(np, "warning: whitespace is not allowed\n");
684 "is not allowed\n", np->name);
685 np->remote_port = simple_strtol(cur, NULL, 10); 687 np->remote_port = simple_strtol(cur, NULL, 10);
686 cur = delim; 688 cur = delim;
687 } 689 }
@@ -705,8 +707,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
705 return 0; 707 return 0;
706 708
707 parse_failed: 709 parse_failed:
708 printk(KERN_INFO "%s: couldn't parse config at '%s'!\n", 710 np_info(np, "couldn't parse config at '%s'!\n", cur);
709 np->name, cur);
710 return -1; 711 return -1;
711} 712}
712EXPORT_SYMBOL(netpoll_parse_options); 713EXPORT_SYMBOL(netpoll_parse_options);
@@ -721,8 +722,8 @@ int __netpoll_setup(struct netpoll *np)
721 722
722 if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) || 723 if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) ||
723 !ndev->netdev_ops->ndo_poll_controller) { 724 !ndev->netdev_ops->ndo_poll_controller) {
724 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", 725 np_err(np, "%s doesn't support polling, aborting\n",
725 np->name, np->dev_name); 726 np->dev_name);
726 err = -ENOTSUPP; 727 err = -ENOTSUPP;
727 goto out; 728 goto out;
728 } 729 }
@@ -785,14 +786,12 @@ int netpoll_setup(struct netpoll *np)
785 if (np->dev_name) 786 if (np->dev_name)
786 ndev = dev_get_by_name(&init_net, np->dev_name); 787 ndev = dev_get_by_name(&init_net, np->dev_name);
787 if (!ndev) { 788 if (!ndev) {
788 printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", 789 np_err(np, "%s doesn't exist, aborting\n", np->dev_name);
789 np->name, np->dev_name);
790 return -ENODEV; 790 return -ENODEV;
791 } 791 }
792 792
793 if (ndev->master) { 793 if (ndev->master) {
794 printk(KERN_ERR "%s: %s is a slave device, aborting.\n", 794 np_err(np, "%s is a slave device, aborting\n", np->dev_name);
795 np->name, np->dev_name);
796 err = -EBUSY; 795 err = -EBUSY;
797 goto put; 796 goto put;
798 } 797 }
@@ -800,16 +799,14 @@ int netpoll_setup(struct netpoll *np)
800 if (!netif_running(ndev)) { 799 if (!netif_running(ndev)) {
801 unsigned long atmost, atleast; 800 unsigned long atmost, atleast;
802 801
803 printk(KERN_INFO "%s: device %s not up yet, forcing it\n", 802 np_info(np, "device %s not up yet, forcing it\n", np->dev_name);
804 np->name, np->dev_name);
805 803
806 rtnl_lock(); 804 rtnl_lock();
807 err = dev_open(ndev); 805 err = dev_open(ndev);
808 rtnl_unlock(); 806 rtnl_unlock();
809 807
810 if (err) { 808 if (err) {
811 printk(KERN_ERR "%s: failed to open %s\n", 809 np_err(np, "failed to open %s\n", ndev->name);
812 np->name, ndev->name);
813 goto put; 810 goto put;
814 } 811 }
815 812
@@ -817,9 +814,7 @@ int netpoll_setup(struct netpoll *np)
817 atmost = jiffies + carrier_timeout * HZ; 814 atmost = jiffies + carrier_timeout * HZ;
818 while (!netif_carrier_ok(ndev)) { 815 while (!netif_carrier_ok(ndev)) {
819 if (time_after(jiffies, atmost)) { 816 if (time_after(jiffies, atmost)) {
820 printk(KERN_NOTICE 817 np_notice(np, "timeout waiting for carrier\n");
821 "%s: timeout waiting for carrier\n",
822 np->name);
823 break; 818 break;
824 } 819 }
825 msleep(1); 820 msleep(1);
@@ -831,9 +826,7 @@ int netpoll_setup(struct netpoll *np)
831 */ 826 */
832 827
833 if (time_before(jiffies, atleast)) { 828 if (time_before(jiffies, atleast)) {
834 printk(KERN_NOTICE "%s: carrier detect appears" 829 np_notice(np, "carrier detect appears untrustworthy, waiting 4 seconds\n");
835 " untrustworthy, waiting 4 seconds\n",
836 np->name);
837 msleep(4000); 830 msleep(4000);
838 } 831 }
839 } 832 }
@@ -844,15 +837,15 @@ int netpoll_setup(struct netpoll *np)
844 837
845 if (!in_dev || !in_dev->ifa_list) { 838 if (!in_dev || !in_dev->ifa_list) {
846 rcu_read_unlock(); 839 rcu_read_unlock();
847 printk(KERN_ERR "%s: no IP address for %s, aborting\n", 840 np_err(np, "no IP address for %s, aborting\n",
848 np->name, np->dev_name); 841 np->dev_name);
849 err = -EDESTADDRREQ; 842 err = -EDESTADDRREQ;
850 goto put; 843 goto put;
851 } 844 }
852 845
853 np->local_ip = in_dev->ifa_list->ifa_local; 846 np->local_ip = in_dev->ifa_list->ifa_local;
854 rcu_read_unlock(); 847 rcu_read_unlock();
855 printk(KERN_INFO "%s: local IP %pI4\n", np->name, &np->local_ip); 848 np_info(np, "local IP %pI4\n", &np->local_ip);
856 } 849 }
857 850
858 np->dev = ndev; 851 np->dev = ndev;