Commit 72fd1c31 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] convert ewrk3 for new locking etc

parent 178035c9
...@@ -245,6 +245,7 @@ struct priv ...@@ -245,6 +245,7 @@ struct priv
int cmdr_addr; int cmdr_addr;
int cardno; int cardno;
int features; int features;
spinlock_t ring_lock;
}; };
static int ni65_probe1(struct net_device *dev,int); static int ni65_probe1(struct net_device *dev,int);
...@@ -299,7 +300,7 @@ static int ni65_open(struct net_device *dev) ...@@ -299,7 +300,7 @@ static int ni65_open(struct net_device *dev)
int irqval = request_irq(dev->irq, &ni65_interrupt,0, int irqval = request_irq(dev->irq, &ni65_interrupt,0,
cards[p->cardno].cardname,dev); cards[p->cardno].cardname,dev);
if (irqval) { if (irqval) {
printk ("%s: unable to get IRQ %d (irqval=%d).\n", printk(KERN_ERR "%s: unable to get IRQ %d (irqval=%d).\n",
dev->name,dev->irq, irqval); dev->name,dev->irq, irqval);
return -EAGAIN; return -EAGAIN;
} }
...@@ -409,12 +410,14 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr) ...@@ -409,12 +410,14 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
p = (struct priv *) dev->priv; p = (struct priv *) dev->priv;
p->cmdr_addr = ioaddr + cards[i].cmd_offset; p->cmdr_addr = ioaddr + cards[i].cmd_offset;
p->cardno = i; p->cardno = i;
spin_lock_init(&p->ring_lock);
printk("%s: %s found at %#3x, ", dev->name, cards[p->cardno].cardname , ioaddr); printk(KERN_INFO "%s: %s found at %#3x, ", dev->name, cards[p->cardno].cardname , ioaddr);
outw(inw(PORT+L_RESET),PORT+L_RESET); /* first: reset the card */ outw(inw(PORT+L_RESET),PORT+L_RESET); /* first: reset the card */
if( (j=readreg(CSR0)) != 0x4) { if( (j=readreg(CSR0)) != 0x4) {
printk(KERN_ERR "can't RESET card: %04x\n",j); printk("failed.\n");
printk(KERN_ERR "%s: Can't RESET card: %04x\n", dev->name, j);
ni65_free_buffer(p); ni65_free_buffer(p);
release_region(ioaddr, cards[p->cardno].total_size); release_region(ioaddr, cards[p->cardno].total_size);
return -EAGAIN; return -EAGAIN;
...@@ -467,7 +470,8 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr) ...@@ -467,7 +470,8 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
break; break;
} }
if(i == 5) { if(i == 5) {
printk("Can't detect DMA channel!\n"); printk("failed.\n");
printk(KERN_ERR "%s: Can't detect DMA channel!\n", dev->name);
ni65_free_buffer(p); ni65_free_buffer(p);
release_region(ioaddr, cards[p->cardno].total_size); release_region(ioaddr, cards[p->cardno].total_size);
return -EAGAIN; return -EAGAIN;
...@@ -480,13 +484,13 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr) ...@@ -480,13 +484,13 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
if(dev->irq < 2) if(dev->irq < 2)
{ {
unsigned long irq_mask, delay; unsigned long irq_mask;
ni65_init_lance(p,dev->dev_addr,0,0); ni65_init_lance(p,dev->dev_addr,0,0);
irq_mask = probe_irq_on(); irq_mask = probe_irq_on();
writereg(CSR0_INIT|CSR0_INEA,CSR0); /* trigger interrupt */ writereg(CSR0_INIT|CSR0_INEA,CSR0); /* trigger interrupt */
delay = jiffies + HZ/50; set_current_state(TASK_UNINTERRUPTIBLE);
while (time_before(jiffies, delay)) ; schedule_timeout(HZ/50);
dev->irq = probe_irq_off(irq_mask); dev->irq = probe_irq_off(irq_mask);
if(!dev->irq) if(!dev->irq)
{ {
...@@ -503,7 +507,7 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr) ...@@ -503,7 +507,7 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
if(request_dma(dev->dma, cards[p->cardno].cardname ) != 0) if(request_dma(dev->dma, cards[p->cardno].cardname ) != 0)
{ {
printk("%s: Can't request dma-channel %d\n",dev->name,(int) dev->dma); printk(KERN_ERR "%s: Can't request dma-channel %d\n",dev->name,(int) dev->dma);
ni65_free_buffer(p); ni65_free_buffer(p);
release_region(ioaddr, cards[p->cardno].total_size); release_region(ioaddr, cards[p->cardno].total_size);
return -EAGAIN; return -EAGAIN;
...@@ -570,7 +574,7 @@ static void *ni65_alloc_mem(struct net_device *dev,char *what,int size,int type) ...@@ -570,7 +574,7 @@ static void *ni65_alloc_mem(struct net_device *dev,char *what,int size,int type)
if(type) { if(type) {
ret = skb = alloc_skb(2+16+size,GFP_KERNEL|GFP_DMA); ret = skb = alloc_skb(2+16+size,GFP_KERNEL|GFP_DMA);
if(!skb) { if(!skb) {
printk("%s: unable to allocate %s memory.\n",dev->name,what); printk(KERN_WARNING "%s: unable to allocate %s memory.\n",dev->name,what);
return NULL; return NULL;
} }
skb->dev = dev; skb->dev = dev;
...@@ -581,12 +585,12 @@ static void *ni65_alloc_mem(struct net_device *dev,char *what,int size,int type) ...@@ -581,12 +585,12 @@ static void *ni65_alloc_mem(struct net_device *dev,char *what,int size,int type)
else { else {
ret = ptr = kmalloc(T_BUF_SIZE,GFP_KERNEL | GFP_DMA); ret = ptr = kmalloc(T_BUF_SIZE,GFP_KERNEL | GFP_DMA);
if(!ret) { if(!ret) {
printk("%s: unable to allocate %s memory.\n",dev->name,what); printk(KERN_WARNING "%s: unable to allocate %s memory.\n",dev->name,what);
return NULL; return NULL;
} }
} }
if( (u32) virt_to_phys(ptr+size) > 0x1000000) { if( (u32) virt_to_phys(ptr+size) > 0x1000000) {
printk("%s: unable to allocate %s memory in lower 16MB!\n",dev->name,what); printk(KERN_WARNING "%s: unable to allocate %s memory in lower 16MB!\n",dev->name,what);
if(type) if(type)
kfree_skb(skb); kfree_skb(skb);
else else
...@@ -692,7 +696,7 @@ static void ni65_stop_start(struct net_device *dev,struct priv *p) ...@@ -692,7 +696,7 @@ static void ni65_stop_start(struct net_device *dev,struct priv *p)
writedatareg(CSR0_STOP); writedatareg(CSR0_STOP);
if(debuglevel > 1) if(debuglevel > 1)
printk("ni65_stop_start\n"); printk(KERN_DEBUG "ni65_stop_start\n");
if(p->features & INIT_RING_BEFORE_START) { if(p->features & INIT_RING_BEFORE_START) {
int i; int i;
...@@ -846,6 +850,8 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs) ...@@ -846,6 +850,8 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs)
p = (struct priv *) dev->priv; p = (struct priv *) dev->priv;
spin_lock(&p->ring_lock);
while(--bcnt) { while(--bcnt) {
csr0 = inw(PORT+L_DATAREG); csr0 = inw(PORT+L_DATAREG);
...@@ -867,7 +873,7 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs) ...@@ -867,7 +873,7 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs)
{ {
struct priv *p = (struct priv *) dev->priv; struct priv *p = (struct priv *) dev->priv;
if(debuglevel > 1) if(debuglevel > 1)
printk("%s: general error: %04x.\n",dev->name,csr0); printk(KERN_ERR "%s: general error: %04x.\n",dev->name,csr0);
if(csr0 & CSR0_BABL) if(csr0 & CSR0_BABL)
p->stats.tx_errors++; p->stats.tx_errors++;
if(csr0 & CSR0_MISS) { if(csr0 & CSR0_MISS) {
...@@ -879,7 +885,7 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs) ...@@ -879,7 +885,7 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs)
} }
if(csr0 & CSR0_MERR) { if(csr0 & CSR0_MERR) {
if(debuglevel > 1) if(debuglevel > 1)
printk("%s: Ooops .. memory error: %04x.\n",dev->name,csr0); printk(KERN_ERR "%s: Ooops .. memory error: %04x.\n",dev->name,csr0);
ni65_stop_start(dev,p); ni65_stop_start(dev,p);
} }
} }
...@@ -932,12 +938,13 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs) ...@@ -932,12 +938,13 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs)
#endif #endif
if( (csr0 & (CSR0_RXON | CSR0_TXON)) != (CSR0_RXON | CSR0_TXON) ) { if( (csr0 & (CSR0_RXON | CSR0_TXON)) != (CSR0_RXON | CSR0_TXON) ) {
printk("%s: RX or TX was offline -> restart\n",dev->name); printk(KERN_DEBUG "%s: RX or TX was offline -> restart\n",dev->name);
ni65_stop_start(dev,p); ni65_stop_start(dev,p);
} }
else else
writedatareg(CSR0_INEA); writedatareg(CSR0_INEA);
spin_unlock(&p->ring_lock);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -1147,9 +1154,7 @@ static int ni65_send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -1147,9 +1154,7 @@ static int ni65_send_packet(struct sk_buff *skb, struct net_device *dev)
memset((char *)p->tmdbounce[p->tmdbouncenum]+skb->len, 0, len-skb->len); memset((char *)p->tmdbounce[p->tmdbouncenum]+skb->len, 0, len-skb->len);
dev_kfree_skb (skb); dev_kfree_skb (skb);
save_flags(flags); spin_lock_irqsave(&p->ring_lock, flags);
cli();
tmdp = p->tmdhead + p->tmdnum; tmdp = p->tmdhead + p->tmdnum;
tmdp->u.buffer = (u32) isa_virt_to_bus(p->tmdbounce[p->tmdbouncenum]); tmdp->u.buffer = (u32) isa_virt_to_bus(p->tmdbounce[p->tmdbouncenum]);
p->tmdbouncenum = (p->tmdbouncenum + 1) & (TMDNUM - 1); p->tmdbouncenum = (p->tmdbouncenum + 1) & (TMDNUM - 1);
...@@ -1157,8 +1162,7 @@ static int ni65_send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -1157,8 +1162,7 @@ static int ni65_send_packet(struct sk_buff *skb, struct net_device *dev)
#ifdef XMT_VIA_SKB #ifdef XMT_VIA_SKB
} }
else { else {
save_flags(flags); spin_lock_irqsave(&p->ring_lock, flags);
cli();
tmdp = p->tmdhead + p->tmdnum; tmdp = p->tmdhead + p->tmdnum;
tmdp->u.buffer = (u32) isa_virt_to_bus(skb->data); tmdp->u.buffer = (u32) isa_virt_to_bus(skb->data);
...@@ -1179,7 +1183,7 @@ static int ni65_send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -1179,7 +1183,7 @@ static int ni65_send_packet(struct sk_buff *skb, struct net_device *dev)
p->lock = 0; p->lock = 0;
dev->trans_start = jiffies; dev->trans_start = jiffies;
restore_flags(flags); spin_unlock_irqrestore(&p->ring_lock, flags);
} }
return 0; return 0;
...@@ -1238,10 +1242,8 @@ void cleanup_module(void) ...@@ -1238,10 +1242,8 @@ void cleanup_module(void)
{ {
struct priv *p; struct priv *p;
p = (struct priv *) dev_ni65.priv; p = (struct priv *) dev_ni65.priv;
if(!p) { if(!p)
printk("Ooops .. no private struct\n"); BUG();
return;
}
disable_dma(dev_ni65.dma); disable_dma(dev_ni65.dma);
free_dma(dev_ni65.dma); free_dma(dev_ni65.dma);
unregister_netdev(&dev_ni65); unregister_netdev(&dev_ni65);
...@@ -1250,6 +1252,7 @@ void cleanup_module(void) ...@@ -1250,6 +1252,7 @@ void cleanup_module(void)
dev_ni65.priv = NULL; dev_ni65.priv = NULL;
} }
#endif /* MODULE */ #endif /* MODULE */
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
/* /*
......
...@@ -86,8 +86,7 @@ ...@@ -86,8 +86,7 @@
#define XMIT_UFLO 0x4000 /* Underflow (late memory) */ #define XMIT_UFLO 0x4000 /* Underflow (late memory) */
#define XMIT_BUFF 0x8000 /* Buffering error (no ENP) */ #define XMIT_BUFF 0x8000 /* Buffering error (no ENP) */
struct init_block struct init_block {
{
unsigned short mode; unsigned short mode;
unsigned char eaddr[6]; unsigned char eaddr[6];
unsigned char filter[8]; unsigned char filter[8];
...@@ -97,13 +96,10 @@ struct init_block ...@@ -97,13 +96,10 @@ struct init_block
u32 trp; /* transmit ring pointer (align 8) */ u32 trp; /* transmit ring pointer (align 8) */
}; };
struct rmd /* Receive Message Descriptor */ struct rmd { /* Receive Message Descriptor */
{ union {
union
{
volatile u32 buffer; volatile u32 buffer;
struct struct {
{
volatile unsigned char dummy[3]; volatile unsigned char dummy[3];
volatile unsigned char status; volatile unsigned char status;
} s; } s;
...@@ -112,13 +108,10 @@ struct rmd /* Receive Message Descriptor */ ...@@ -112,13 +108,10 @@ struct rmd /* Receive Message Descriptor */
volatile unsigned short mlen; volatile unsigned short mlen;
}; };
struct tmd struct tmd {
{ union {
union
{
volatile u32 buffer; volatile u32 buffer;
struct struct {
{
volatile unsigned char dummy[3]; volatile unsigned char dummy[3];
volatile unsigned char status; volatile unsigned char status;
} s; } s;
...@@ -126,5 +119,3 @@ struct tmd ...@@ -126,5 +119,3 @@ struct tmd
volatile unsigned short blen; volatile unsigned short blen;
volatile unsigned short status2; volatile unsigned short status2;
}; };
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