aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPeter Tiedemann <ptiedem@de.ibm.com>2007-11-29 11:36:27 -0500
committerJeff Garzik <jeff@garzik.org>2007-12-01 16:32:28 -0500
commit1c1478859017452a1179dbbdf7b9eb5b48438746 (patch)
tree45bde61bfb4f496d5d899735939c327608e79274 /drivers
parent9f74ffdebf3f81cb69e6c90026c6cff89e57c262 (diff)
ctc: make use of alloc_netdev()
Currently ctc-device initialization is broken (kernel bug in ctc_new_device). The new network namespace code reveals a deficiency of the ctc driver. It should make use of alloc_netdev() as described in Documentation/networking/netdevices.txt. Signed-off-by: Peter Tiedemann <ptiedem@de.ibm.com> Signed-off-by: Ursula Braun <braunu@de.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/s390/net/ctcmain.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index 6bf3ebbe985a..b3b6f654365c 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -2782,35 +2782,14 @@ ctc_probe_device(struct ccwgroup_device *cgdev)
2782} 2782}
2783 2783
2784/** 2784/**
2785 * Initialize everything of the net device except the name and the 2785 * Device setup function called by alloc_netdev().
2786 * channel structs. 2786 *
2787 * @param dev Device to be setup.
2787 */ 2788 */
2788static struct net_device * 2789void ctc_init_netdevice(struct net_device * dev)
2789ctc_init_netdevice(struct net_device * dev, int alloc_device,
2790 struct ctc_priv *privptr)
2791{ 2790{
2792 if (!privptr)
2793 return NULL;
2794
2795 DBF_TEXT(setup, 3, __FUNCTION__); 2791 DBF_TEXT(setup, 3, __FUNCTION__);
2796 2792
2797 if (alloc_device) {
2798 dev = kzalloc(sizeof(struct net_device), GFP_KERNEL);
2799 if (!dev)
2800 return NULL;
2801 }
2802
2803 dev->priv = privptr;
2804 privptr->fsm = init_fsm("ctcdev", dev_state_names,
2805 dev_event_names, CTC_NR_DEV_STATES, CTC_NR_DEV_EVENTS,
2806 dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
2807 if (privptr->fsm == NULL) {
2808 if (alloc_device)
2809 kfree(dev);
2810 return NULL;
2811 }
2812 fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
2813 fsm_settimer(privptr->fsm, &privptr->restart_timer);
2814 if (dev->mtu == 0) 2793 if (dev->mtu == 0)
2815 dev->mtu = CTC_BUFSIZE_DEFAULT - LL_HEADER_LENGTH - 2; 2794 dev->mtu = CTC_BUFSIZE_DEFAULT - LL_HEADER_LENGTH - 2;
2816 dev->hard_start_xmit = ctc_tx; 2795 dev->hard_start_xmit = ctc_tx;
@@ -2823,7 +2802,7 @@ ctc_init_netdevice(struct net_device * dev, int alloc_device,
2823 dev->type = ARPHRD_SLIP; 2802 dev->type = ARPHRD_SLIP;
2824 dev->tx_queue_len = 100; 2803 dev->tx_queue_len = 100;
2825 dev->flags = IFF_POINTOPOINT | IFF_NOARP; 2804 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
2826 return dev; 2805 SET_MODULE_OWNER(dev);
2827} 2806}
2828 2807
2829 2808
@@ -2879,14 +2858,22 @@ ctc_new_device(struct ccwgroup_device *cgdev)
2879 "ccw_device_set_online (cdev[1]) failed with ret = %d\n", ret); 2858 "ccw_device_set_online (cdev[1]) failed with ret = %d\n", ret);
2880 } 2859 }
2881 2860
2882 dev = ctc_init_netdevice(NULL, 1, privptr); 2861 dev = alloc_netdev(0, "ctc%d", ctc_init_netdevice);
2883
2884 if (!dev) { 2862 if (!dev) {
2885 ctc_pr_warn("ctc_init_netdevice failed\n"); 2863 ctc_pr_warn("ctc_init_netdevice failed\n");
2886 goto out; 2864 goto out;
2887 } 2865 }
2866 dev->priv = privptr;
2888 2867
2889 strlcpy(dev->name, "ctc%d", IFNAMSIZ); 2868 privptr->fsm = init_fsm("ctcdev", dev_state_names,
2869 dev_event_names, CTC_NR_DEV_STATES, CTC_NR_DEV_EVENTS,
2870 dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
2871 if (privptr->fsm == NULL) {
2872 free_netdev(dev);
2873 goto out;
2874 }
2875 fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
2876 fsm_settimer(privptr->fsm, &privptr->restart_timer);
2890 2877
2891 for (direction = READ; direction <= WRITE; direction++) { 2878 for (direction = READ; direction <= WRITE; direction++) {
2892 privptr->channel[direction] = 2879 privptr->channel[direction] =