Commit 84bc69a1 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://kernel.bkbits.net/jgarzik/net-drivers-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents b5939deb d857e540
......@@ -980,7 +980,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
dev->irq = pdev->irq;
/* dev->priv/tp zeroed and aligned in init_etherdev */
/* dev->priv/tp zeroed and aligned in alloc_etherdev */
tp = dev->priv;
/* note: tp->chipset set in rtl8139_init_board */
......@@ -2143,9 +2143,7 @@ static int rtl8139_close (struct net_device *dev)
spin_unlock_irqrestore (&tp->lock, flags);
/* TODO: isn't this code racy? we synchronize the IRQ and then free it, */
/* but another IRQ could've happened in between the sync and free */
synchronize_irq (dev->irq);
synchronize_irq (dev->irq); /* racy, but that's ok here */
free_irq (dev->irq, dev);
rtl8139_tx_clear (tp);
......
This diff is collapsed.
This diff is collapsed.
......@@ -614,6 +614,22 @@ e100_found1(struct pci_dev *pcid, const struct pci_device_id *ent)
goto err_dealloc;
}
dev->vlan_rx_register = e100_vlan_rx_register;
dev->vlan_rx_add_vid = e100_vlan_rx_add_vid;
dev->vlan_rx_kill_vid = e100_vlan_rx_kill_vid;
dev->irq = pcid->irq;
dev->open = &e100_open;
dev->hard_start_xmit = &e100_xmit_frame;
dev->stop = &e100_close;
dev->change_mtu = &e100_change_mtu;
dev->get_stats = &e100_get_stats;
dev->set_multicast_list = &e100_set_multi;
dev->set_mac_address = &e100_set_mac;
dev->do_ioctl = &e100_ioctl;
if (bdp->flags & USE_IPCB)
dev->features = NETIF_F_SG | NETIF_F_HW_CSUM |
NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
if ((rc = register_netdev(dev)) != 0) {
goto err_pci;
}
......@@ -660,23 +676,6 @@ e100_found1(struct pci_dev *pcid, const struct pci_device_id *ent)
goto err_unregister_netdev;
}
dev->vlan_rx_register = e100_vlan_rx_register;
dev->vlan_rx_add_vid = e100_vlan_rx_add_vid;
dev->vlan_rx_kill_vid = e100_vlan_rx_kill_vid;
dev->irq = pcid->irq;
dev->open = &e100_open;
dev->hard_start_xmit = &e100_xmit_frame;
dev->stop = &e100_close;
dev->change_mtu = &e100_change_mtu;
dev->get_stats = &e100_get_stats;
dev->set_multicast_list = &e100_set_multi;
dev->set_mac_address = &e100_set_mac;
dev->do_ioctl = &e100_ioctl;
if (bdp->flags & USE_IPCB)
dev->features = NETIF_F_SG | NETIF_F_HW_CSUM |
NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
e100nics++;
e100_get_speed_duplex_caps(bdp);
......
......@@ -602,7 +602,7 @@ static int __devinit netdrv_init_board (struct pci_dev *pdev,
*ioaddr_out = NULL;
*dev_out = NULL;
/* dev zeroed in init_etherdev */
/* dev zeroed in alloc_etherdev */
dev = alloc_etherdev (sizeof (*tp));
if (dev == NULL) {
printk (KERN_ERR PFX "unable to alloc new ethernet\n");
......@@ -790,7 +790,7 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
dev->irq = pdev->irq;
dev->base_addr = (unsigned long) ioaddr;
/* dev->priv/tp zeroed and aligned in init_etherdev */
/* dev->priv/tp zeroed and aligned in alloc_etherdev */
tp = dev->priv;
/* note: tp->chipset set in netdrv_init_board */
......
......@@ -1002,6 +1002,8 @@ pcnet32_init_ring(struct net_device *dev)
}
skb_reserve (rx_skbuff, 2);
}
if (lp->rx_dma_addr[i] == NULL)
lp->rx_dma_addr[i] = pci_map_single(lp->pci_dev, rx_skbuff->tail, rx_skbuff->len, PCI_DMA_FROMDEVICE);
lp->rx_ring[i].base = (u32)le32_to_cpu(lp->rx_dma_addr[i]);
lp->rx_ring[i].buf_length = le16_to_cpu(-PKT_BUF_SZ);
......@@ -1037,7 +1039,7 @@ pcnet32_restart(struct net_device *dev, unsigned int csr0_bits)
/* ReInit Ring */
lp->a.write_csr (ioaddr, 0, 1);
i = 0;
while (i++ < 100)
while (i++ < 1000)
if (lp->a.read_csr (ioaddr, 0) & 0x0100)
break;
......@@ -1128,6 +1130,7 @@ pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
lp->tx_skbuff[entry] = skb;
lp->tx_dma_addr[entry] = pci_map_single(lp->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE);
lp->tx_ring[entry].base = (u32)le32_to_cpu(lp->tx_dma_addr[entry]);
wmb(); /* Make sure owner changes after all others are visible */
lp->tx_ring[entry].status = le16_to_cpu(status);
lp->cur_tx++;
......
......@@ -365,8 +365,8 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
*ioaddr_out = NULL;
*dev_out = NULL;
// dev zeroed in init_etherdev
dev = init_etherdev(NULL, sizeof (*tp));
// dev zeroed in alloc_etherdev
dev = alloc_etherdev(sizeof (*tp));
if (dev == NULL) {
printk(KERN_ERR PFX "unable to alloc new ethernet\n");
return -ENOMEM;
......@@ -391,18 +391,18 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
printk(KERN_ERR PFX
"region #1 not an MMIO resource, aborting\n");
rc = -ENODEV;
goto err_out;
goto err_out_disable;
}
// check for weird/broken PCI region reporting
if (mmio_len < RTL_MIN_IO_SIZE) {
printk(KERN_ERR PFX "Invalid PCI region size(s), aborting\n");
rc = -ENODEV;
goto err_out;
goto err_out_disable;
}
rc = pci_request_regions(pdev, dev->name);
if (rc)
goto err_out;
goto err_out_disable;
// enable PCI bus-mastering
pci_set_master(pdev);
......@@ -450,8 +450,10 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
err_out_free_res:
pci_release_regions(pdev);
err_out_disable:
pci_disable_device(pdev);
err_out:
unregister_netdev(dev);
kfree(dev);
return rc;
}
......@@ -464,7 +466,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
void *ioaddr = NULL;
static int board_idx = -1;
static int printed_version = 0;
int i;
int i, rc;
int option = -1, Cap10_100 = 0, Cap1000 = 0;
assert(pdev != NULL);
......@@ -477,20 +479,18 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
printed_version = 1;
}
i = rtl8169_init_board(pdev, &dev, &ioaddr);
if (i < 0) {
return i;
}
rc = rtl8169_init_board(pdev, &dev, &ioaddr);
if (rc)
return rc;
tp = dev->priv;
assert(ioaddr != NULL);
assert(dev != NULL);
assert(tp != NULL);
// Get MAC address //
for (i = 0; i < MAC_ADDR_LEN; i++) {
// Get MAC address. FIXME: read EEPROM
for (i = 0; i < MAC_ADDR_LEN; i++)
dev->dev_addr[i] = RTL_R8(MAC0 + i);
}
dev->open = rtl8169_open;
dev->hard_start_xmit = rtl8169_start_xmit;
......@@ -507,11 +507,20 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->pci_dev = pdev;
tp->mmio_addr = ioaddr;
spin_lock_init(&tp->lock);
rc = register_netdev(dev);
if (rc) {
iounmap(ioaddr);
pci_release_regions(pdev);
pci_disable_device(pdev);
kfree(dev);
return rc;
}
printk(KERN_DEBUG "%s: Identified chip type is '%s'.\n", dev->name,
rtl_chip_info[tp->chipset].name);
spin_lock_init(&tp->lock);
pci_set_drvdata(pdev, dev);
printk(KERN_INFO "%s: %s at 0x%lx, "
......@@ -623,7 +632,7 @@ static void __devexit
rtl8169_remove_one(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct rtl8169_private *tp = (struct rtl8169_private *) (dev->priv);
struct rtl8169_private *tp = dev->priv;
assert(dev != NULL);
assert(tp != NULL);
......@@ -636,6 +645,7 @@ rtl8169_remove_one(struct pci_dev *pdev)
memset(dev, 0xBC,
sizeof (struct net_device) + sizeof (struct rtl8169_private));
pci_disable_device(pdev);
kfree(dev);
pci_set_drvdata(pdev, NULL);
}
......
......@@ -346,6 +346,27 @@ static void TLan_EeReceiveByte( u16, u8 *, int );
static int TLan_EeReadByte( struct net_device *, u8, u8 * );
static void
TLan_StoreSKB( struct tlan_list_tag *tag, struct sk_buff *skb)
{
unsigned long addr = (unsigned long)skb;
tag->buffer[9].address = (u32)addr;
addr >>= 31; /* >>= 32 is undefined for 32bit arch, stupid C */
addr >>= 1;
tag->buffer[8].address = (u32)addr;
}
static struct sk_buff *
TLan_GetSKB( struct tlan_list_tag *tag)
{
unsigned long addr = tag->buffer[8].address;
addr <<= 31;
addr <<= 1;
addr |= tag->buffer[9].address;
return (struct sk_buff *) addr;
}
static TLanIntVectorFunc *TLanIntVector[TLAN_INT_NUMBER_OF_INTS] = {
TLan_HandleInvalid,
TLan_HandleTxEOF,
......@@ -424,7 +445,7 @@ static void __devexit tlan_remove_one( struct pci_dev *pdev)
pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage, priv->dmaStorageDMA );
}
release_region( dev->base_addr, 0x10 );
pci_release_regions(pdev);
kfree( dev );
......@@ -510,15 +531,25 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
TLanPrivateInfo *priv;
u8 pci_rev;
u16 device_id;
int reg;
int reg, rc = -ENODEV;
if (pdev) {
rc = pci_enable_device(pdev);
if (rc)
return rc;
if (pdev && pci_enable_device(pdev))
return -EIO;
rc = pci_request_regions(pdev, TLanSignature);
if (rc) {
printk(KERN_ERR "TLAN: Could not reserve IO regions\n");
goto err_out;
}
}
dev = init_etherdev(NULL, sizeof(TLanPrivateInfo));
dev = alloc_etherdev(sizeof(TLanPrivateInfo));
if (dev == NULL) {
printk(KERN_ERR "TLAN: Could not allocate memory for device.\n");
return -ENOMEM;
rc = -ENOMEM;
goto err_out_regions;
}
SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &pdev->dev);
......@@ -533,12 +564,10 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
priv->adapter = &board_info[ent->driver_data];
if(pci_set_dma_mask(pdev, 0xFFFFFFFF))
{
rc = pci_set_dma_mask(pdev, 0xFFFFFFFF);
if (rc) {
printk(KERN_ERR "TLAN: No suitable PCI mapping available.\n");
unregister_netdev(dev);
kfree(dev);
return -ENODEV;
goto err_out_free_dev;
}
pci_read_config_byte ( pdev, PCI_REVISION_ID, &pci_rev);
......@@ -553,9 +582,8 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
}
if (!pci_io_base) {
printk(KERN_ERR "TLAN: No IO mappings available\n");
unregister_netdev(dev);
kfree(dev);
return -ENODEV;
rc = -EIO;
goto err_out_free_dev;
}
dev->base_addr = pci_io_base;
......@@ -605,12 +633,18 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
spin_lock_init(&priv->lock);
if (TLan_Init(dev)) {
rc = TLan_Init(dev);
if (rc) {
printk(KERN_ERR "TLAN: Could not set up device.\n");
goto err_out_free_dev;
}
rc = register_netdev(dev);
if (rc) {
printk(KERN_ERR "TLAN: Could not register device.\n");
unregister_netdev(dev);
kfree(dev);
return -EAGAIN;
} else {
goto err_out_uninit;
}
TLanDevicesInstalled++;
boards_found++;
......@@ -631,8 +665,19 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
priv->adapter->deviceLabel,
priv->adapterRev);
return 0;
}
err_out_uninit:
pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage,
priv->dmaStorageDMA );
err_out_free_dev:
kfree(dev);
err_out_regions:
if (pdev)
pci_release_regions(pdev);
err_out:
if (pdev)
pci_disable_device(pdev);
return rc;
}
......@@ -798,15 +843,6 @@ static int TLan_Init( struct net_device *dev )
priv = dev->priv;
if (!priv->is_eisa) /* EISA devices have already requested IO */
if (!request_region( dev->base_addr, 0x10, TLanSignature )) {
printk(KERN_ERR "TLAN: %s: IO port region 0x%lx size 0x%x in use.\n",
dev->name,
dev->base_addr,
0x10 );
return -EIO;
}
if ( bbuf ) {
dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
* ( sizeof(TLanList) + TLAN_MAX_FRAME_SIZE );
......@@ -820,7 +856,6 @@ static int TLan_Init( struct net_device *dev )
if ( priv->dmaStorage == NULL ) {
printk(KERN_ERR "TLAN: Could not allocate lists and buffers for %s.\n",
dev->name );
release_region( dev->base_addr, 0x10 );
return -ENOMEM;
}
memset( priv->dmaStorage, 0, dma_size );
......@@ -1039,7 +1074,7 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
memcpy( tail_buffer, skb->data, skb->len );
} else {
tail_list->buffer[0].address = pci_map_single(priv->pciDev, skb->data, skb->len, PCI_DMA_TODEVICE);
tail_list->buffer[9].address = (u32) skb;
TLan_StoreSKB(tail_list, skb);
}
pad = TLAN_MIN_FRAME_SIZE - skb->len;
......@@ -1365,9 +1400,10 @@ u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
while (((tmpCStat = head_list->cStat ) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) {
ack++;
if ( ! bbuf ) {
struct sk_buff *skb = (struct sk_buff *) head_list->buffer[9].address;
struct sk_buff *skb = TLan_GetSKB(head_list);
pci_unmap_single(priv->pciDev, head_list->buffer[0].address, skb->len, PCI_DMA_TODEVICE);
dev_kfree_skb_any(skb);
head_list->buffer[8].address = 0;
head_list->buffer[9].address = 0;
}
......@@ -1523,7 +1559,7 @@ u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
new_skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
if ( new_skb != NULL ) {
skb = (struct sk_buff *) head_list->buffer[9].address;
skb = TLan_GetSKB(head_list);
pci_unmap_single(priv->pciDev, head_list->buffer[0].address, TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
skb_trim( skb, frameSize );
......@@ -1537,10 +1573,7 @@ u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
t = (void *) skb_put( new_skb, TLAN_MAX_FRAME_SIZE );
head_list->buffer[0].address = pci_map_single(priv->pciDev, new_skb->data, TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
head_list->buffer[8].address = (u32) t;
#if BITS_PER_LONG==64
#error "Not 64bit clean"
#endif
head_list->buffer[9].address = (u32) new_skb;
TLan_StoreSKB(head_list, new_skb);
} else
printk(KERN_WARNING "TLAN: Couldn't allocate memory for received data.\n" );
}
......@@ -1926,6 +1959,7 @@ void TLan_ResetLists( struct net_device *dev )
}
list->buffer[2].count = 0;
list->buffer[2].address = 0;
list->buffer[8].address = 0;
list->buffer[9].address = 0;
}
......@@ -1951,7 +1985,7 @@ void TLan_ResetLists( struct net_device *dev )
}
list->buffer[0].address = pci_map_single(priv->pciDev, t, TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
list->buffer[8].address = (u32) t;
list->buffer[9].address = (u32) skb;
TLan_StoreSKB(list, skb);
}
list->buffer[1].count = 0;
list->buffer[1].address = 0;
......@@ -1974,20 +2008,22 @@ void TLan_FreeLists( struct net_device *dev )
if ( ! bbuf ) {
for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) {
list = priv->txList + i;
skb = (struct sk_buff *) list->buffer[9].address;
skb = TLan_GetSKB(list);
if ( skb ) {
pci_unmap_single(priv->pciDev, list->buffer[0].address, skb->len, PCI_DMA_TODEVICE);
dev_kfree_skb_any( skb );
list->buffer[8].address = 0;
list->buffer[9].address = 0;
}
}
for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) {
list = priv->rxList + i;
skb = (struct sk_buff *) list->buffer[9].address;
skb = TLan_GetSKB(list);
if ( skb ) {
pci_unmap_single(priv->pciDev, list->buffer[0].address, TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
dev_kfree_skb_any( skb );
list->buffer[8].address = 0;
list->buffer[9].address = 0;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment