diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-08 14:25:41 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-08 14:25:41 -0800 |
commit | 5fbbf5f648a9c4ef99276854f05b2255d1b004d3 (patch) | |
tree | 59c9ae762c3df2800e894001b3de58c5f1972486 /drivers/isdn | |
parent | ce279e6ec91c49f2c5f59f7492e19d39edbf8bbd (diff) | |
parent | 56cf391a9462a4897ea660a6af3662dda5ae8c84 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (84 commits)
wimax: fix kernel-doc for debufs_dentry member of struct wimax_dev
net: convert pegasus driver to net_device_ops
bnx2x: Prevent eeprom set when driver is down
net: switch kaweth driver to netdevops
pcnet32: round off carrier watch timer
i2400m/usb: wrap USB power saving in #ifdef CONFIG_PM
wimax: testing for rfkill support should also test for CONFIG_RFKILL_MODULE
wimax: fix kconfig interactions with rfkill and input layers
wimax: fix '#ifndef CONFIG_BUG' layout to avoid warning
r6040: bump release number to 0.20
r6040: warn about MAC address being unset
r6040: check PHY status when bringing interface up
r6040: make printks consistent with DRV_NAME
gianfar: Fixup use of BUS_ID_SIZE
mlx4_en: Returning real Max in get_ringparam
mlx4_en: Consider inline packets on completion
netdev: bfin_mac: enable bfin_mac net dev driver for BF51x
qeth: convert to net_device_ops
vlan: add neigh_setup
dm9601: warn on invalid mac address
...
Diffstat (limited to 'drivers/isdn')
-rw-r--r-- | drivers/isdn/hysdn/hysdn_net.c | 77 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_net.c | 69 |
2 files changed, 76 insertions, 70 deletions
diff --git a/drivers/isdn/hysdn/hysdn_net.c b/drivers/isdn/hysdn/hysdn_net.c index 7ee5bd9f2bb..579974cf4c9 100644 --- a/drivers/isdn/hysdn/hysdn_net.c +++ b/drivers/isdn/hysdn/hysdn_net.c @@ -38,16 +38,12 @@ char *hysdn_net_revision = "$Revision: 1.8.6.4 $"; /* inside the definition. */ /****************************************************************************/ struct net_local { - struct net_device netdev; /* the network device */ - struct net_device_stats stats; - /* additional vars may be added here */ - char dev_name[9]; /* our own device name */ - /* Tx control lock. This protects the transmit buffer ring * state along with the "tx full" state of the driver. This * means all netif_queue flow control actions are protected * by this lock as well. */ + struct net_device *dev; spinlock_t lock; struct sk_buff *skbs[MAX_SKB_BUFFERS]; /* pointers to tx-skbs */ int in_idx, out_idx; /* indexes to buffer ring */ @@ -55,15 +51,6 @@ struct net_local { }; /* net_local */ -/*****************************************************/ -/* Get the current statistics for this card. */ -/* This may be called with the card open or closed ! */ -/*****************************************************/ -static struct net_device_stats * -net_get_stats(struct net_device *dev) -{ - return (&((struct net_local *) dev)->stats); -} /* net_device_stats */ /*********************************************************************/ /* Open/initialize the board. This is called (in the current kernel) */ @@ -182,8 +169,8 @@ hysdn_tx_netack(hysdn_card * card) if (!lp->sk_count) return; /* error condition */ - lp->stats.tx_packets++; - lp->stats.tx_bytes += lp->skbs[lp->out_idx]->len; + lp->dev->stats.tx_packets++; + lp->dev->stats.tx_bytes += lp->skbs[lp->out_idx]->len; dev_kfree_skb(lp->skbs[lp->out_idx++]); /* free skb */ if (lp->out_idx >= MAX_SKB_BUFFERS) @@ -200,29 +187,30 @@ void hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len) { struct net_local *lp = card->netif; + struct net_device *dev = lp->dev; struct sk_buff *skb; if (!lp) return; /* non existing device */ - lp->stats.rx_bytes += len; + dev->stats.rx_bytes += len; skb = dev_alloc_skb(len); if (skb == NULL) { printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", - lp->netdev.name); - lp->stats.rx_dropped++; + dev->name); + dev->stats.rx_dropped++; return; } /* copy the data */ memcpy(skb_put(skb, len), buf, len); /* determine the used protocol */ - skb->protocol = eth_type_trans(skb, &lp->netdev); + skb->protocol = eth_type_trans(skb, dev); - netif_rx(skb); - lp->stats.rx_packets++; /* adjust packet count */ + dev->stats.rx_packets++; /* adjust packet count */ + netif_rx(skb); } /* hysdn_rx_netpkt */ /*****************************************************/ @@ -242,24 +230,15 @@ hysdn_tx_netget(hysdn_card * card) return (lp->skbs[lp->out_idx]); /* next packet to send */ } /* hysdn_tx_netget */ +static const struct net_device_ops hysdn_netdev_ops = { + .ndo_open = net_open, + .ndo_stop = net_close, + .ndo_start_xmit = net_send_packet, + .ndo_change_mtu = eth_change_mtu, + .ndo_set_mac_address = eth_mac_addr, + .ndo_validate_addr = eth_validate_addr, +}; -/*******************************************/ -/* init function called by register device */ -/*******************************************/ -static int -net_init(struct net_device *dev) -{ - /* setup the function table */ - dev->open = net_open; - dev->stop = net_close; - dev->hard_start_xmit = net_send_packet; - dev->get_stats = net_get_stats; - - /* Fill in the fields of the device structure with ethernet values. */ - ether_setup(dev); - - return (0); /* success */ -} /* net_init */ /*****************************************************************************/ /* hysdn_net_create creates a new net device for the given card. If a device */ @@ -271,28 +250,34 @@ hysdn_net_create(hysdn_card * card) { struct net_device *dev; int i; + struct net_local *lp; + if(!card) { printk(KERN_WARNING "No card-pt in hysdn_net_create!\n"); return (-ENOMEM); } hysdn_net_release(card); /* release an existing net device */ - if ((dev = kzalloc(sizeof(struct net_local), GFP_KERNEL)) == NULL) { + + dev = alloc_etherdev(sizeof(struct net_local)); + if (!dev) { printk(KERN_WARNING "HYSDN: unable to allocate mem\n"); return (-ENOMEM); } + lp = netdev_priv(dev); + lp->dev = dev; + + dev->netdev_ops = &hysdn_netdev_ops; spin_lock_init(&((struct net_local *) dev)->lock); /* initialise necessary or informing fields */ dev->base_addr = card->iobase; /* IO address */ dev->irq = card->irq; /* irq */ - dev->init = net_init; /* the init function of the device */ - if(dev->name) { - strcpy(dev->name, ((struct net_local *) dev)->dev_name); - } + + dev->netdev_ops = &hysdn_netdev_ops; if ((i = register_netdev(dev))) { printk(KERN_WARNING "HYSDN: unable to create network device\n"); - kfree(dev); + free_netdev(dev); return (i); } dev->ml_priv = card; /* remember pointer to own data structure */ @@ -316,7 +301,7 @@ hysdn_net_release(hysdn_card * card) return (0); /* non existing */ card->netif = NULL; /* clear out pointer */ - dev->stop(dev); /* close the device */ + net_close(dev); flush_tx_buffers((struct net_local *) dev); /* empty buffers */ diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 023ea11d2f9..7c5f97033b9 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -1485,6 +1485,24 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) return (rc); } + +static int isdn_net_ioctl(struct net_device *dev, + struct ifreq *ifr, int cmd) +{ + isdn_net_local *lp = (isdn_net_local *) netdev_priv(dev); + + switch (lp->p_encap) { +#ifdef CONFIG_ISDN_PPP + case ISDN_NET_ENCAP_SYNCPPP: + return isdn_ppp_dev_ioctl(dev, ifr, cmd); +#endif + case ISDN_NET_ENCAP_CISCOHDLCK: + return isdn_ciscohdlck_dev_ioctl(dev, ifr, cmd); + default: + return -EINVAL; + } +} + /* called via cisco_timer.function */ static void isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data) @@ -1998,23 +2016,6 @@ isdn_net_init(struct net_device *ndev) ushort max_hlhdr_len = 0; int drvidx; - ether_setup(ndev); - ndev->header_ops = NULL; - - /* Setup the generic properties */ - ndev->mtu = 1500; - ndev->flags = IFF_NOARP|IFF_POINTOPOINT; - ndev->type = ARPHRD_ETHER; - ndev->addr_len = ETH_ALEN; - ndev->validate_addr = NULL; - - /* for clients with MPPP maybe higher values better */ - ndev->tx_queue_len = 30; - - /* The ISDN-specific entries in the device structure. */ - ndev->open = &isdn_net_open; - ndev->hard_start_xmit = &isdn_net_start_xmit; - /* * up till binding we ask the protocol layer to reserve as much * as we might need for HL layer @@ -2026,9 +2027,6 @@ isdn_net_init(struct net_device *ndev) max_hlhdr_len = dev->drv[drvidx]->interface->hl_hdrlen; ndev->hard_header_len = ETH_HLEN + max_hlhdr_len; - ndev->stop = &isdn_net_close; - ndev->get_stats = &isdn_net_get_stats; - ndev->do_ioctl = NULL; return 0; } @@ -2508,6 +2506,19 @@ isdn_net_force_dial(char *name) return (isdn_net_force_dial_lp(p->local)); } +/* The ISDN-specific entries in the device structure. */ +static const struct net_device_ops isdn_netdev_ops = { + .ndo_init = isdn_net_init, + .ndo_open = isdn_net_open, + .ndo_stop = isdn_net_close, + .ndo_do_ioctl = isdn_net_ioctl, + + .ndo_validate_addr = NULL, + .ndo_start_xmit = isdn_net_start_xmit, + .ndo_get_stats = isdn_net_get_stats, + .ndo_tx_timeout = isdn_net_tx_timeout, +}; + /* * Helper for alloc_netdev() */ @@ -2515,7 +2526,20 @@ static void _isdn_setup(struct net_device *dev) { isdn_net_local *lp = netdev_priv(dev); + ether_setup(dev); + dev->flags = IFF_NOARP | IFF_POINTOPOINT; + /* Setup the generic properties */ + dev->mtu = 1500; + dev->flags = IFF_NOARP|IFF_POINTOPOINT; + dev->type = ARPHRD_ETHER; + dev->addr_len = ETH_ALEN; + dev->header_ops = NULL; + dev->netdev_ops = &isdn_netdev_ops; + + /* for clients with MPPP maybe higher values better */ + dev->tx_queue_len = 30; + lp->p_encap = ISDN_NET_ENCAP_RAWIP; lp->magic = ISDN_NET_MAGIC; lp->last = lp; @@ -2570,7 +2594,7 @@ isdn_net_new(char *name, struct net_device *master) return NULL; } netdev->local = netdev_priv(netdev->dev); - netdev->dev->init = isdn_net_init; + if (master) { /* Device shall be a slave */ struct net_device *p = MASTER_TO_SLAVE(master); @@ -2588,7 +2612,6 @@ isdn_net_new(char *name, struct net_device *master) /* * Watchdog timer (currently) for master only. */ - netdev->dev->tx_timeout = isdn_net_tx_timeout; netdev->dev->watchdog_timeo = ISDN_NET_TX_TIMEOUT; if (register_netdev(netdev->dev) != 0) { printk(KERN_WARNING "isdn_net: Could not register net-device\n"); @@ -2704,7 +2727,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) #else p->dev->type = ARPHRD_PPP; /* change ARP type */ p->dev->addr_len = 0; - p->dev->do_ioctl = isdn_ppp_dev_ioctl; #endif break; case ISDN_NET_ENCAP_X25IFACE: @@ -2718,7 +2740,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) #endif break; case ISDN_NET_ENCAP_CISCOHDLCK: - p->dev->do_ioctl = isdn_ciscohdlck_dev_ioctl; break; default: if( cfg->p_encap >= 0 && |