diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2011-05-22 00:52:08 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-22 21:01:22 -0400 |
commit | ce14f8946a294ffa741ec29558a1c7e455cecd3b (patch) | |
tree | 0c96385fe8647f750a6a797bf0c192a732a1f69c /net | |
parent | 68d5ac2ed6180567407e4187e206df3ba6466373 (diff) | |
download | op-kernel-dev-ce14f8946a294ffa741ec29558a1c7e455cecd3b.zip op-kernel-dev-ce14f8946a294ffa741ec29558a1c7e455cecd3b.tar.gz |
pktgen: refactor pg_init() code
This also shrinks the object size a little.
text data bss dec hex filename
28834 186 8 29028 7164 net/core/pktgen.o
28816 186 8 29010 7152 net/core/pktgen.o.AFTER
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
Cc: "David Miller" <davem@davemloft.net>,
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/pktgen.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 3b85c0d..f76079c 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -3707,6 +3707,7 @@ static int __init pg_init(void) { int cpu; struct proc_dir_entry *pe; + int ret = 0; pr_info("%s", version); @@ -3717,11 +3718,10 @@ static int __init pg_init(void) pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops); if (pe == NULL) { pr_err("ERROR: cannot create %s procfs entry\n", PGCTRL); - proc_net_remove(&init_net, PG_PROC_DIR); - return -EINVAL; + ret = -EINVAL; + goto remove_dir; } - /* Register us to receive netdevice events */ register_netdevice_notifier(&pktgen_notifier_block); for_each_online_cpu(cpu) { @@ -3735,13 +3735,18 @@ static int __init pg_init(void) if (list_empty(&pktgen_threads)) { pr_err("ERROR: Initialization failed for all threads\n"); - unregister_netdevice_notifier(&pktgen_notifier_block); - remove_proc_entry(PGCTRL, pg_proc_dir); - proc_net_remove(&init_net, PG_PROC_DIR); - return -ENODEV; + ret = -ENODEV; + goto unregister; } return 0; + + unregister: + unregister_netdevice_notifier(&pktgen_notifier_block); + remove_proc_entry(PGCTRL, pg_proc_dir); + remove_dir: + proc_net_remove(&init_net, PG_PROC_DIR); + return ret; } static void __exit pg_cleanup(void) |