diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2009-11-29 10:46:09 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-01 19:15:56 -0500 |
commit | 741a6fa210c5c8828af3819134f644842e0e9c09 (patch) | |
tree | 54d90c7bdbe7701c5876d9ad59c42fbde7122d7c /drivers | |
parent | e8d02885997081f09272af6b9a27061a142da4c5 (diff) |
net: Simplify ppp_generic pernet operations.
Take advantage of the new pernet automatic storage management,
and stop using compatibility network namespace functions.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ppp_generic.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 0a56a778af0a..f671bb810047 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -864,12 +864,7 @@ static const struct file_operations ppp_device_fops = { | |||
864 | 864 | ||
865 | static __net_init int ppp_init_net(struct net *net) | 865 | static __net_init int ppp_init_net(struct net *net) |
866 | { | 866 | { |
867 | struct ppp_net *pn; | 867 | struct ppp_net *pn = net_generic(net, ppp_net_id); |
868 | int err; | ||
869 | |||
870 | pn = kzalloc(sizeof(*pn), GFP_KERNEL); | ||
871 | if (!pn) | ||
872 | return -ENOMEM; | ||
873 | 868 | ||
874 | idr_init(&pn->units_idr); | 869 | idr_init(&pn->units_idr); |
875 | mutex_init(&pn->all_ppp_mutex); | 870 | mutex_init(&pn->all_ppp_mutex); |
@@ -879,32 +874,21 @@ static __net_init int ppp_init_net(struct net *net) | |||
879 | 874 | ||
880 | spin_lock_init(&pn->all_channels_lock); | 875 | spin_lock_init(&pn->all_channels_lock); |
881 | 876 | ||
882 | err = net_assign_generic(net, ppp_net_id, pn); | ||
883 | if (err) { | ||
884 | kfree(pn); | ||
885 | return err; | ||
886 | } | ||
887 | |||
888 | return 0; | 877 | return 0; |
889 | } | 878 | } |
890 | 879 | ||
891 | static __net_exit void ppp_exit_net(struct net *net) | 880 | static __net_exit void ppp_exit_net(struct net *net) |
892 | { | 881 | { |
893 | struct ppp_net *pn; | 882 | struct ppp_net *pn = net_generic(net, ppp_net_id); |
894 | 883 | ||
895 | pn = net_generic(net, ppp_net_id); | ||
896 | idr_destroy(&pn->units_idr); | 884 | idr_destroy(&pn->units_idr); |
897 | /* | ||
898 | * if someone has cached our net then | ||
899 | * further net_generic call will return NULL | ||
900 | */ | ||
901 | net_assign_generic(net, ppp_net_id, NULL); | ||
902 | kfree(pn); | ||
903 | } | 885 | } |
904 | 886 | ||
905 | static struct pernet_operations ppp_net_ops = { | 887 | static struct pernet_operations ppp_net_ops = { |
906 | .init = ppp_init_net, | 888 | .init = ppp_init_net, |
907 | .exit = ppp_exit_net, | 889 | .exit = ppp_exit_net, |
890 | .id = &ppp_net_id, | ||
891 | .size = sizeof(struct ppp_net), | ||
908 | }; | 892 | }; |
909 | 893 | ||
910 | #define PPP_MAJOR 108 | 894 | #define PPP_MAJOR 108 |
@@ -917,7 +901,7 @@ static int __init ppp_init(void) | |||
917 | 901 | ||
918 | printk(KERN_INFO "PPP generic driver version " PPP_VERSION "\n"); | 902 | printk(KERN_INFO "PPP generic driver version " PPP_VERSION "\n"); |
919 | 903 | ||
920 | err = register_pernet_gen_device(&ppp_net_id, &ppp_net_ops); | 904 | err = register_pernet_device(&ppp_net_ops); |
921 | if (err) { | 905 | if (err) { |
922 | printk(KERN_ERR "failed to register PPP pernet device (%d)\n", err); | 906 | printk(KERN_ERR "failed to register PPP pernet device (%d)\n", err); |
923 | goto out; | 907 | goto out; |
@@ -943,7 +927,7 @@ static int __init ppp_init(void) | |||
943 | out_chrdev: | 927 | out_chrdev: |
944 | unregister_chrdev(PPP_MAJOR, "ppp"); | 928 | unregister_chrdev(PPP_MAJOR, "ppp"); |
945 | out_net: | 929 | out_net: |
946 | unregister_pernet_gen_device(ppp_net_id, &ppp_net_ops); | 930 | unregister_pernet_device(&ppp_net_ops); |
947 | out: | 931 | out: |
948 | return err; | 932 | return err; |
949 | } | 933 | } |
@@ -2835,7 +2819,7 @@ static void __exit ppp_cleanup(void) | |||
2835 | unregister_chrdev(PPP_MAJOR, "ppp"); | 2819 | unregister_chrdev(PPP_MAJOR, "ppp"); |
2836 | device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0)); | 2820 | device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0)); |
2837 | class_destroy(ppp_class); | 2821 | class_destroy(ppp_class); |
2838 | unregister_pernet_gen_device(ppp_net_id, &ppp_net_ops); | 2822 | unregister_pernet_device(&ppp_net_ops); |
2839 | } | 2823 | } |
2840 | 2824 | ||
2841 | /* | 2825 | /* |