diff options
author | Satyam Sharma <satyam@infradead.org> | 2007-08-10 18:27:24 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:48:02 -0400 |
commit | d39badf05b52f99169b22ce324fd31c8b44a0473 (patch) | |
tree | 42a08b0253860cae60bbc54cb7b279d00aa583be | |
parent | ab66b4a7a3969077f6e2a18a0d2d849d3b84a337 (diff) |
[NET] netconsole: Cleanups, codingstyle, prettyfication
Based upon initial work by Keiichi Kii <k-keiichi@bx.jp.nec.com>.
(1) Remove unwanted headers.
(2) Mark __init and __exit as appropriate.
(3) Various trivial codingstyle and prettification stuff.
Signed-off-by: Satyam Sharma <satyam@infradead.org>
Signed-off-by: Keiichi Kii <k-keiichi@bx.jp.nec.com>
Acked-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/netconsole.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 69233f6aa05c..f1c2a2defd70 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c | |||
@@ -35,35 +35,32 @@ | |||
35 | ****************************************************************/ | 35 | ****************************************************************/ |
36 | 36 | ||
37 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
38 | #include <linux/tty.h> | ||
39 | #include <linux/init.h> | 38 | #include <linux/init.h> |
40 | #include <linux/module.h> | 39 | #include <linux/module.h> |
41 | #include <linux/console.h> | 40 | #include <linux/console.h> |
42 | #include <linux/tty_driver.h> | ||
43 | #include <linux/moduleparam.h> | 41 | #include <linux/moduleparam.h> |
44 | #include <linux/string.h> | 42 | #include <linux/string.h> |
45 | #include <linux/sysrq.h> | ||
46 | #include <linux/smp.h> | ||
47 | #include <linux/netpoll.h> | 43 | #include <linux/netpoll.h> |
48 | 44 | ||
49 | MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>"); | 45 | MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>"); |
50 | MODULE_DESCRIPTION("Console driver for network interfaces"); | 46 | MODULE_DESCRIPTION("Console driver for network interfaces"); |
51 | MODULE_LICENSE("GPL"); | 47 | MODULE_LICENSE("GPL"); |
52 | 48 | ||
53 | static char config[256]; | 49 | #define MAX_PARAM_LENGTH 256 |
54 | module_param_string(netconsole, config, 256, 0); | 50 | #define MAX_PRINT_CHUNK 1000 |
51 | |||
52 | static char config[MAX_PARAM_LENGTH]; | ||
53 | module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0); | ||
55 | MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n"); | 54 | MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n"); |
56 | 55 | ||
57 | static struct netpoll np = { | 56 | static struct netpoll np = { |
58 | .name = "netconsole", | 57 | .name = "netconsole", |
59 | .dev_name = "eth0", | 58 | .dev_name = "eth0", |
60 | .local_port = 6665, | 59 | .local_port = 6665, |
61 | .remote_port = 6666, | 60 | .remote_port = 6666, |
62 | .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, | 61 | .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, |
63 | }; | 62 | }; |
64 | static int configured = 0; | 63 | static int configured; |
65 | |||
66 | #define MAX_PRINT_CHUNK 1000 | ||
67 | 64 | ||
68 | static void write_msg(struct console *con, const char *msg, unsigned int len) | 65 | static void write_msg(struct console *con, const char *msg, unsigned int len) |
69 | { | 66 | { |
@@ -75,7 +72,7 @@ static void write_msg(struct console *con, const char *msg, unsigned int len) | |||
75 | 72 | ||
76 | local_irq_save(flags); | 73 | local_irq_save(flags); |
77 | 74 | ||
78 | for(left = len; left; ) { | 75 | for (left = len; left;) { |
79 | frag = min(left, MAX_PRINT_CHUNK); | 76 | frag = min(left, MAX_PRINT_CHUNK); |
80 | netpoll_send_udp(&np, msg, frag); | 77 | netpoll_send_udp(&np, msg, frag); |
81 | msg += frag; | 78 | msg += frag; |
@@ -86,12 +83,12 @@ static void write_msg(struct console *con, const char *msg, unsigned int len) | |||
86 | } | 83 | } |
87 | 84 | ||
88 | static struct console netconsole = { | 85 | static struct console netconsole = { |
89 | .name = "netcon", | 86 | .name = "netcon", |
90 | .flags = CON_ENABLED | CON_PRINTBUFFER, | 87 | .flags = CON_ENABLED | CON_PRINTBUFFER, |
91 | .write = write_msg | 88 | .write = write_msg, |
92 | }; | 89 | }; |
93 | 90 | ||
94 | static int option_setup(char *opt) | 91 | static int __init option_setup(char *opt) |
95 | { | 92 | { |
96 | configured = !netpoll_parse_options(&np, opt); | 93 | configured = !netpoll_parse_options(&np, opt); |
97 | return 1; | 94 | return 1; |
@@ -99,28 +96,30 @@ static int option_setup(char *opt) | |||
99 | 96 | ||
100 | __setup("netconsole=", option_setup); | 97 | __setup("netconsole=", option_setup); |
101 | 98 | ||
102 | static int init_netconsole(void) | 99 | static int __init init_netconsole(void) |
103 | { | 100 | { |
104 | int err; | 101 | int err = 0; |
105 | 102 | ||
106 | if(strlen(config)) | 103 | if (strnlen(config, MAX_PARAM_LENGTH)) |
107 | option_setup(config); | 104 | option_setup(config); |
108 | 105 | ||
109 | if(!configured) { | 106 | if (!configured) { |
110 | printk("netconsole: not configured, aborting\n"); | 107 | printk(KERN_INFO "netconsole: not configured, aborting\n"); |
111 | return 0; | 108 | goto out; |
112 | } | 109 | } |
113 | 110 | ||
114 | err = netpoll_setup(&np); | 111 | err = netpoll_setup(&np); |
115 | if (err) | 112 | if (err) |
116 | return err; | 113 | goto out; |
117 | 114 | ||
118 | register_console(&netconsole); | 115 | register_console(&netconsole); |
119 | printk(KERN_INFO "netconsole: network logging started\n"); | 116 | printk(KERN_INFO "netconsole: network logging started\n"); |
120 | return 0; | 117 | |
118 | out: | ||
119 | return err; | ||
121 | } | 120 | } |
122 | 121 | ||
123 | static void cleanup_netconsole(void) | 122 | static void __exit cleanup_netconsole(void) |
124 | { | 123 | { |
125 | unregister_console(&netconsole); | 124 | unregister_console(&netconsole); |
126 | netpoll_cleanup(&np); | 125 | netpoll_cleanup(&np); |