diff options
Diffstat (limited to 'net/wanrouter/wanmain.c')
-rw-r--r-- | net/wanrouter/wanmain.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c index 7f07152bc109..39701dec1dba 100644 --- a/net/wanrouter/wanmain.c +++ b/net/wanrouter/wanmain.c | |||
@@ -60,6 +60,8 @@ | |||
60 | 60 | ||
61 | #define KMEM_SAFETYZONE 8 | 61 | #define KMEM_SAFETYZONE 8 |
62 | 62 | ||
63 | #define DEV_TO_SLAVE(dev) (*((struct net_device **)netdev_priv(dev))) | ||
64 | |||
63 | /* | 65 | /* |
64 | * Function Prototypes | 66 | * Function Prototypes |
65 | */ | 67 | */ |
@@ -511,7 +513,7 @@ static int wanrouter_device_shutdown(struct wan_device *wandev) | |||
511 | if (err) | 513 | if (err) |
512 | return err; | 514 | return err; |
513 | /* The above function deallocates the current dev | 515 | /* The above function deallocates the current dev |
514 | * structure. Therefore, we cannot use dev->priv | 516 | * structure. Therefore, we cannot use netdev_priv(dev) |
515 | * as the next element: wandev->dev points to the | 517 | * as the next element: wandev->dev points to the |
516 | * next element */ | 518 | * next element */ |
517 | dev = wandev->dev; | 519 | dev = wandev->dev; |
@@ -589,10 +591,6 @@ static int wanrouter_device_new_if(struct wan_device *wandev, | |||
589 | err = -EPROTONOSUPPORT; | 591 | err = -EPROTONOSUPPORT; |
590 | goto out; | 592 | goto out; |
591 | } else { | 593 | } else { |
592 | dev = kzalloc(sizeof(struct net_device), GFP_KERNEL); | ||
593 | err = -ENOBUFS; | ||
594 | if (dev == NULL) | ||
595 | goto out; | ||
596 | err = wandev->new_if(wandev, dev, cnf); | 594 | err = wandev->new_if(wandev, dev, cnf); |
597 | } | 595 | } |
598 | 596 | ||
@@ -622,10 +620,9 @@ static int wanrouter_device_new_if(struct wan_device *wandev, | |||
622 | wandev->dev = dev; | 620 | wandev->dev = dev; |
623 | } else { | 621 | } else { |
624 | for (slave=wandev->dev; | 622 | for (slave=wandev->dev; |
625 | *((struct net_device **)slave->priv); | 623 | DEV_TO_SLAVE(slave); |
626 | slave = *((struct net_device **)slave->priv)); | 624 | slave = DEV_TO_SLAVE(slave)) |
627 | 625 | DEV_TO_SLAVE(slave) = dev; | |
628 | *((struct net_device **)slave->priv) = dev; | ||
629 | } | 626 | } |
630 | ++wandev->ndev; | 627 | ++wandev->ndev; |
631 | 628 | ||
@@ -636,15 +633,9 @@ static int wanrouter_device_new_if(struct wan_device *wandev, | |||
636 | } | 633 | } |
637 | if (wandev->del_if) | 634 | if (wandev->del_if) |
638 | wandev->del_if(wandev, dev); | 635 | wandev->del_if(wandev, dev); |
636 | free_netdev(dev); | ||
639 | } | 637 | } |
640 | 638 | ||
641 | /* This code has moved from del_if() function */ | ||
642 | kfree(dev->priv); | ||
643 | dev->priv = NULL; | ||
644 | |||
645 | /* Sync PPP is disabled */ | ||
646 | if (cnf->config_id != WANCONFIG_MPPP) | ||
647 | kfree(dev); | ||
648 | out: | 639 | out: |
649 | kfree(cnf); | 640 | kfree(cnf); |
650 | return err; | 641 | return err; |
@@ -734,7 +725,7 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name) | |||
734 | dev = wandev->dev; | 725 | dev = wandev->dev; |
735 | prev = NULL; | 726 | prev = NULL; |
736 | while (dev && strcmp(name, dev->name)) { | 727 | while (dev && strcmp(name, dev->name)) { |
737 | struct net_device **slave = dev->priv; | 728 | struct net_device **slave = netdev_priv(dev); |
738 | prev = dev; | 729 | prev = dev; |
739 | dev = *slave; | 730 | dev = *slave; |
740 | } | 731 | } |
@@ -751,12 +742,12 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name) | |||
751 | 742 | ||
752 | lock_adapter_irq(&wandev->lock, &smp_flags); | 743 | lock_adapter_irq(&wandev->lock, &smp_flags); |
753 | if (prev) { | 744 | if (prev) { |
754 | struct net_device **prev_slave = prev->priv; | 745 | struct net_device **prev_slave = netdev_priv(prev); |
755 | struct net_device **slave = dev->priv; | 746 | struct net_device **slave = netdev_priv(dev); |
756 | 747 | ||
757 | *prev_slave = *slave; | 748 | *prev_slave = *slave; |
758 | } else { | 749 | } else { |
759 | struct net_device **slave = dev->priv; | 750 | struct net_device **slave = netdev_priv(dev); |
760 | wandev->dev = *slave; | 751 | wandev->dev = *slave; |
761 | } | 752 | } |
762 | --wandev->ndev; | 753 | --wandev->ndev; |
@@ -764,11 +755,6 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name) | |||
764 | 755 | ||
765 | printk(KERN_INFO "%s: unregistering '%s'\n", wandev->name, dev->name); | 756 | printk(KERN_INFO "%s: unregistering '%s'\n", wandev->name, dev->name); |
766 | 757 | ||
767 | /* Due to new interface linking method using dev->priv, | ||
768 | * this code has moved from del_if() function.*/ | ||
769 | kfree(dev->priv); | ||
770 | dev->priv=NULL; | ||
771 | |||
772 | unregister_netdev(dev); | 758 | unregister_netdev(dev); |
773 | 759 | ||
774 | free_netdev(dev); | 760 | free_netdev(dev); |