patch-2.3.32 linux/drivers/net/tlan.c
Next file: linux/drivers/net/tlan.h
Previous file: linux/drivers/net/sb1000.c
Back to the patch index
Back to the overall index
- Lines: 250
- Date:
Sun Dec 12 22:55:54 1999
- Orig file:
v2.3.31/linux/drivers/net/tlan.c
- Orig date:
Tue Nov 23 22:42:21 1999
diff -u --recursive --new-file v2.3.31/linux/drivers/net/tlan.c linux/drivers/net/tlan.c
@@ -31,6 +31,8 @@
* new PCI BIOS interface.
* Alan Cox <alan@redhat.com>: Fixed the out of memory
* handling.
+ *
+ * Torben Mathiasen <torben.mathiasen@compaq.com> New Maintainer!
*
********************************************************************/
@@ -43,7 +45,7 @@
#include <linux/pci.h>
#include <linux/etherdevice.h>
#include <linux/delay.h>
-
+#include <linux/spinlock.h>
typedef u32 (TLanIntVectorFunc)( struct net_device *, u16 );
@@ -234,13 +236,15 @@
TLan_SetTimer( struct net_device *dev, u32 ticks, u32 type )
{
TLanPrivateInfo *priv = (TLanPrivateInfo *) dev->priv;
+ unsigned long flags;
- cli();
+ spin_lock_irqsave(&priv->lock, flags);
if ( priv->timer.function != NULL ) {
+ spin_unlock_irqrestore(&priv->lock, flags);
return;
}
priv->timer.function = &TLan_Timer;
- sti();
+ spin_unlock_irqrestore(&priv->lock, flags);
priv->timer.data = (unsigned long) dev;
priv->timer.expires = jiffies + ticks;
@@ -336,6 +340,8 @@
priv->speed = speed;
priv->sa_int = sa_int;
priv->debug = debug;
+
+ spin_lock_init(&priv->lock);
ether_setup( dev );
@@ -464,9 +470,6 @@
priv = (TLanPrivateInfo *) dev->priv;
- dev->name = priv->devName;
- strcpy( priv->devName, " " );
-
dev = init_etherdev( dev, sizeof(TLanPrivateInfo) );
dev->base_addr = io_base;
@@ -485,7 +488,7 @@
}
priv->sa_int = dev->mem_start & 0x02;
priv->debug = dev->mem_end;
-
+ spin_lock_init(&priv->lock);
printk("TLAN %d.%d: %s irq=%2d io=%04x, %s, Rev. %d\n",
TLanVersionMajor,
@@ -770,6 +773,7 @@
TLanList *tail_list;
u8 *tail_buffer;
int pad;
+ unsigned long flags;
if ( ! priv->phyOnline ) {
TLAN_DBG( TLAN_DEBUG_TX, "TLAN TRANSMIT: %s PHY is not ready\n", dev->name );
@@ -810,7 +814,7 @@
tail_list->buffer[1].address = 0;
}
- cli();
+ spin_lock_irqsave(&priv->lock, flags);
tail_list->cStat = TLAN_CSTAT_READY;
if ( ! priv->txInProgress ) {
priv->txInProgress = 1;
@@ -826,7 +830,7 @@
( priv->txList + ( priv->txTail - 1 ) )->forward = virt_to_bus( tail_list );
}
}
- sti();
+ spin_unlock_irqrestore(&priv->lock, flags);
CIRC_INC( priv->txTail, TLAN_NUM_TX_LISTS );
@@ -870,10 +874,12 @@
u32 host_cmd;
u16 host_int;
int type;
+ TLanPrivateInfo *priv;
dev = (struct net_device *) dev_id;
+ priv = (TLanPrivateInfo *) dev->priv;
- cli();
+ spin_lock(&priv->lock);
if ( dev->interrupt ) {
printk( "TLAN: Re-entering interrupt handler for %s: %ld.\n" , dev->name, dev->interrupt );
}
@@ -892,7 +898,7 @@
}
dev->interrupt--;
- sti();
+ spin_unlock(&priv->lock);
} /* TLan_HandleInterrupts */
@@ -1558,6 +1564,7 @@
struct net_device *dev = (struct net_device *) data;
TLanPrivateInfo *priv = (TLanPrivateInfo *) dev->priv;
u32 elapsed;
+ unsigned long flags;
priv->timer.function = NULL;
@@ -1581,7 +1588,7 @@
TLan_FinishReset( dev );
break;
case TLAN_TIMER_ACTIVITY:
- cli();
+ spin_lock_irqsave(&priv->lock, flags);
if ( priv->timer.function == NULL ) {
elapsed = jiffies - priv->timerSetAt;
if ( elapsed >= TLAN_TIMER_ACT_DELAY ) {
@@ -1589,11 +1596,12 @@
} else {
priv->timer.function = &TLan_Timer;
priv->timer.expires = priv->timerSetAt + TLAN_TIMER_ACT_DELAY;
- sti();
+ spin_unlock_irqrestore(&priv->lock, flags);
add_timer( &priv->timer );
+ break;
}
}
- sti();
+ spin_unlock_irqrestore(&priv->lock, flags);
break;
default:
break;
@@ -2435,16 +2443,19 @@
{
u8 nack;
u16 sio, tmp;
- u32 i;
+ u32 i;
int err;
int minten;
+ TLanPrivateInfo *priv = (TLanPrivateInfo *) dev->priv;
+ int irq;
+ unsigned long flags;
err = FALSE;
outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
if ( dev->interrupt == 0 )
- cli();
+ spin_lock_irqsave(&priv->lock, flags);
dev->interrupt++;
TLan_MiiSync(dev->base_addr);
@@ -2494,7 +2505,7 @@
dev->interrupt--;
if ( dev->interrupt == 0 )
- sti();
+ spin_unlock_irqrestore(&priv->lock, flags);
return err;
@@ -2606,12 +2617,14 @@
{
u16 sio;
int minten;
+ unsigned long flags;
+ TLanPrivateInfo *priv = (TLanPrivateInfo *) dev->priv;
outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
if ( dev->interrupt == 0 )
- cli();
+ spin_lock_irqsave(&priv->lock, flags);
dev->interrupt++;
TLan_MiiSync( dev->base_addr );
@@ -2636,7 +2649,7 @@
dev->interrupt--;
if ( dev->interrupt == 0 )
- sti();
+ spin_unlock_irqrestore(&priv->lock, flags);
} /* TLan_MiiWriteReg */
@@ -2834,29 +2847,41 @@
int TLan_EeReadByte( struct net_device *dev, u8 ee_addr, u8 *data )
{
int err;
+ TLanPrivateInfo *priv = (TLanPrivateInfo *) dev->priv;
+ unsigned long flags;
+ int ret=0;
if ( dev->interrupt == 0 )
- cli();
+ spin_lock_irqsave(&priv->lock, flags);
dev->interrupt++;
TLan_EeSendStart( dev->base_addr );
err = TLan_EeSendByte( dev->base_addr, 0xA0, TLAN_EEPROM_ACK );
if (err)
- return 1;
+ {
+ ret=1;
+ goto fail;
+ }
err = TLan_EeSendByte( dev->base_addr, ee_addr, TLAN_EEPROM_ACK );
if (err)
- return 2;
+ {
+ ret=2;
+ goto fail;
+ }
TLan_EeSendStart( dev->base_addr );
err = TLan_EeSendByte( dev->base_addr, 0xA1, TLAN_EEPROM_ACK );
if (err)
- return 3;
+ {
+ ret=3;
+ goto fail;
+ }
TLan_EeReceiveByte( dev->base_addr, data, TLAN_EEPROM_STOP );
-
+fail:
dev->interrupt--;
if ( dev->interrupt == 0 )
- sti();
+ spin_unlock_irqrestore(&priv->lock, flags);
- return 0;
+ return ret;
} /* TLan_EeReadByte */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)