aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2011-05-21 20:52:08 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-22 21:01:22 -0400
commitce14f8946a294ffa741ec29558a1c7e455cecd3b (patch)
tree0c96385fe8647f750a6a797bf0c192a732a1f69c
parent68d5ac2ed6180567407e4187e206df3ba6466373 (diff)
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>
-rw-r--r--net/core/pktgen.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 3b85c0dffa61..f76079cd750c 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3707,6 +3707,7 @@ static int __init pg_init(void)
3707{ 3707{
3708 int cpu; 3708 int cpu;
3709 struct proc_dir_entry *pe; 3709 struct proc_dir_entry *pe;
3710 int ret = 0;
3710 3711
3711 pr_info("%s", version); 3712 pr_info("%s", version);
3712 3713
@@ -3717,11 +3718,10 @@ static int __init pg_init(void)
3717 pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops); 3718 pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops);
3718 if (pe == NULL) { 3719 if (pe == NULL) {
3719 pr_err("ERROR: cannot create %s procfs entry\n", PGCTRL); 3720 pr_err("ERROR: cannot create %s procfs entry\n", PGCTRL);
3720 proc_net_remove(&init_net, PG_PROC_DIR); 3721 ret = -EINVAL;
3721 return -EINVAL; 3722 goto remove_dir;
3722 } 3723 }
3723 3724
3724 /* Register us to receive netdevice events */
3725 register_netdevice_notifier(&pktgen_notifier_block); 3725 register_netdevice_notifier(&pktgen_notifier_block);
3726 3726
3727 for_each_online_cpu(cpu) { 3727 for_each_online_cpu(cpu) {
@@ -3735,13 +3735,18 @@ static int __init pg_init(void)
3735 3735
3736 if (list_empty(&pktgen_threads)) { 3736 if (list_empty(&pktgen_threads)) {
3737 pr_err("ERROR: Initialization failed for all threads\n"); 3737 pr_err("ERROR: Initialization failed for all threads\n");
3738 unregister_netdevice_notifier(&pktgen_notifier_block); 3738 ret = -ENODEV;
3739 remove_proc_entry(PGCTRL, pg_proc_dir); 3739 goto unregister;
3740 proc_net_remove(&init_net, PG_PROC_DIR);
3741 return -ENODEV;
3742 } 3740 }
3743 3741
3744 return 0; 3742 return 0;
3743
3744 unregister:
3745 unregister_netdevice_notifier(&pktgen_notifier_block);
3746 remove_proc_entry(PGCTRL, pg_proc_dir);
3747 remove_dir:
3748 proc_net_remove(&init_net, PG_PROC_DIR);
3749 return ret;
3745} 3750}
3746 3751
3747static void __exit pg_cleanup(void) 3752static void __exit pg_cleanup(void)