[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>
This commit is contained in:
Satyam Sharma 2007-08-10 15:27:24 -07:00 committed by David S. Miller
parent ab66b4a7a3
commit d39badf05b

View File

@ -35,23 +35,22 @@
****************************************************************/ ****************************************************************/
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/tty.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/console.h> #include <linux/console.h>
#include <linux/tty_driver.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/sysrq.h>
#include <linux/smp.h>
#include <linux/netpoll.h> #include <linux/netpoll.h>
MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>"); MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>");
MODULE_DESCRIPTION("Console driver for network interfaces"); MODULE_DESCRIPTION("Console driver for network interfaces");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static char config[256]; #define MAX_PARAM_LENGTH 256
module_param_string(netconsole, config, 256, 0); #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-ip>/[tgt-macaddr]\n"); MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n");
static struct netpoll np = { static struct netpoll np = {
@ -61,9 +60,7 @@ static struct netpoll np = {
.remote_port = 6666, .remote_port = 6666,
.remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
}; };
static int configured = 0; static int configured;
#define MAX_PRINT_CHUNK 1000
static void write_msg(struct console *con, const char *msg, unsigned int len) 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); local_irq_save(flags);
for(left = len; left; ) { for (left = len; left;) {
frag = min(left, MAX_PRINT_CHUNK); frag = min(left, MAX_PRINT_CHUNK);
netpoll_send_udp(&np, msg, frag); netpoll_send_udp(&np, msg, frag);
msg += frag; msg += frag;
@ -88,10 +85,10 @@ static void write_msg(struct console *con, const char *msg, unsigned int len)
static struct console netconsole = { static struct console netconsole = {
.name = "netcon", .name = "netcon",
.flags = CON_ENABLED | CON_PRINTBUFFER, .flags = CON_ENABLED | CON_PRINTBUFFER,
.write = write_msg .write = write_msg,
}; };
static int option_setup(char *opt) static int __init option_setup(char *opt)
{ {
configured = !netpoll_parse_options(&np, opt); configured = !netpoll_parse_options(&np, opt);
return 1; return 1;
@ -99,28 +96,30 @@ static int option_setup(char *opt)
__setup("netconsole=", option_setup); __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); option_setup(config);
if(!configured) { if (!configured) {
printk("netconsole: not configured, aborting\n"); printk(KERN_INFO "netconsole: not configured, aborting\n");
return 0; goto out;
} }
err = netpoll_setup(&np); err = netpoll_setup(&np);
if (err) if (err)
return err; goto out;
register_console(&netconsole); register_console(&netconsole);
printk(KERN_INFO "netconsole: network logging started\n"); 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); unregister_console(&netconsole);
netpoll_cleanup(&np); netpoll_cleanup(&np);