From 75ed38a1a5ed358ca62f980d1fa7ea39376f44bd Mon Sep 17 00:00:00 2001 From: Satyam Sharma Date: Fri, 10 Aug 2007 15:27:24 -0700 Subject: [PATCH] --- yaml --- r: 66271 b: refs/heads/master c: d39badf05b52f99169b22ce324fd31c8b44a0473 h: refs/heads/master i: 66269: ac1e7eaa81be819ab84c8f2d4e2ca6f8a744d975 66267: 438ab1d870c00c65637c6cf5fbf45153423c8237 66263: 3f8c960749f88b75dbace341c414cdf8b0340e0c 66255: f6e2657d2ac2404fe29b9c74bebc2af6aa524c56 66239: 49be0d420444a51c26d8e81814a1aa4506c1c165 v: v3 --- [refs] | 2 +- trunk/drivers/net/netconsole.c | 55 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/[refs] b/[refs] index 15144f27eaa7..5a24ac292600 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ab66b4a7a3969077f6e2a18a0d2d849d3b84a337 +refs/heads/master: d39badf05b52f99169b22ce324fd31c8b44a0473 diff --git a/trunk/drivers/net/netconsole.c b/trunk/drivers/net/netconsole.c index 69233f6aa05c..f1c2a2defd70 100644 --- a/trunk/drivers/net/netconsole.c +++ b/trunk/drivers/net/netconsole.c @@ -35,35 +35,32 @@ ****************************************************************/ #include -#include #include #include #include -#include #include #include -#include -#include #include MODULE_AUTHOR("Maintainer: Matt Mackall "); MODULE_DESCRIPTION("Console driver for network interfaces"); MODULE_LICENSE("GPL"); -static char config[256]; -module_param_string(netconsole, config, 256, 0); +#define MAX_PARAM_LENGTH 256 +#define MAX_PRINT_CHUNK 1000 + +static char config[MAX_PARAM_LENGTH]; +module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0); MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@/[tgt-macaddr]\n"); static struct netpoll np = { - .name = "netconsole", - .dev_name = "eth0", - .local_port = 6665, - .remote_port = 6666, - .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + .name = "netconsole", + .dev_name = "eth0", + .local_port = 6665, + .remote_port = 6666, + .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, }; -static int configured = 0; - -#define MAX_PRINT_CHUNK 1000 +static int configured; static void write_msg(struct console *con, const char *msg, unsigned int len) { @@ -75,7 +72,7 @@ static void write_msg(struct console *con, const char *msg, unsigned int len) local_irq_save(flags); - for(left = len; left; ) { + for (left = len; left;) { frag = min(left, MAX_PRINT_CHUNK); netpoll_send_udp(&np, msg, frag); msg += frag; @@ -86,12 +83,12 @@ static void write_msg(struct console *con, const char *msg, unsigned int len) } static struct console netconsole = { - .name = "netcon", - .flags = CON_ENABLED | CON_PRINTBUFFER, - .write = write_msg + .name = "netcon", + .flags = CON_ENABLED | CON_PRINTBUFFER, + .write = write_msg, }; -static int option_setup(char *opt) +static int __init option_setup(char *opt) { configured = !netpoll_parse_options(&np, opt); return 1; @@ -99,28 +96,30 @@ static int option_setup(char *opt) __setup("netconsole=", option_setup); -static int init_netconsole(void) +static int __init init_netconsole(void) { - int err; + int err = 0; - if(strlen(config)) + if (strnlen(config, MAX_PARAM_LENGTH)) option_setup(config); - if(!configured) { - printk("netconsole: not configured, aborting\n"); - return 0; + if (!configured) { + printk(KERN_INFO "netconsole: not configured, aborting\n"); + goto out; } err = netpoll_setup(&np); if (err) - return err; + goto out; register_console(&netconsole); printk(KERN_INFO "netconsole: network logging started\n"); - return 0; + +out: + return err; } -static void cleanup_netconsole(void) +static void __exit cleanup_netconsole(void) { unregister_console(&netconsole); netpoll_cleanup(&np);