- turn #if THROTTLE_TX into C code - adjust some debug messages - factorize code a litle - fix warnings with gcc-3.4.1 - etc. Signed-off-by: Nicolas Pitre Signed-off-by: Andrew Morton --- 25-akpm/drivers/net/smc91x.c | 42 ++++++++++++++++-------------------------- 25-akpm/drivers/net/smc91x.h | 12 ++++++++---- 2 files changed, 24 insertions(+), 30 deletions(-) diff -puN drivers/net/smc91x.c~smc91x-assorted-minor-cleanups drivers/net/smc91x.c --- 25/drivers/net/smc91x.c~smc91x-assorted-minor-cleanups 2004-10-01 20:16:31.575269048 -0700 +++ 25-akpm/drivers/net/smc91x.c 2004-10-01 20:16:31.581268136 -0700 @@ -212,7 +212,7 @@ struct smc_local { #define DBG(n, args...) \ do { \ if (SMC_DEBUG >= (n)) \ - printk(KERN_DEBUG args); \ + printk(args); \ } while (0) #define PRINTK(args...) printk(args) @@ -361,11 +361,10 @@ static void smc_reset(struct net_device * transmitted packets, to make the best use out of our limited * memory */ -#if ! THROTTLE_TX_PKTS - ctl |= CTL_AUTO_RELEASE; -#else - ctl &= ~CTL_AUTO_RELEASE; -#endif + if(!THROTTLE_TX_PKTS) + ctl |= CTL_AUTO_RELEASE; + else + ctl &= ~CTL_AUTO_RELEASE; SMC_SET_CTL(ctl); /* Disable all interrupts */ @@ -526,10 +525,10 @@ static void smc_hardware_send_packet(str DBG(3, "%s: %s\n", dev->name, __FUNCTION__); + lp->saved_skb = NULL; packet_no = SMC_GET_AR(); if (unlikely(packet_no & AR_FAILED)) { printk("%s: Memory allocation failed.\n", dev->name); - lp->saved_skb = NULL; lp->stats.tx_errors++; lp->stats.tx_fifo_errors++; dev_kfree_skb_any(skb); @@ -564,7 +563,6 @@ static void smc_hardware_send_packet(str dev->trans_start = jiffies; dev_kfree_skb_any(skb); - lp->saved_skb = NULL; lp->stats.tx_packets++; lp->stats.tx_bytes += len; } @@ -644,9 +642,8 @@ static int smc_hard_start_xmit(struct sk * away for better TX throughput, in which case the queue is * left active. */ -#if THROTTLE_TX_PKTS - netif_stop_queue(dev); -#endif + if (THROTTLE_TX_PKTS) + netif_stop_queue(dev); smc_hardware_send_packet(dev); SMC_ENABLE_INT(IM_TX_INT | IM_TX_EMPTY_INT); } @@ -1178,7 +1175,7 @@ static irqreturn_t smc_interrupt(int irq do { status = SMC_GET_INT(); - DBG(2, "%s: IRQ 0x%02x MASK 0x%02x MEM 0x%04x FIFO 0x%04x\n", + DBG(2, "%s: INT 0x%02x MASK 0x%02x MEM 0x%04x FIFO 0x%04x\n", dev->name, status, mask, ({ int meminfo; SMC_SELECT_BANK(0); meminfo = SMC_GET_MIR(); @@ -1198,17 +1195,15 @@ static irqreturn_t smc_interrupt(int irq DBG(3, "%s: TX int\n", dev->name); smc_tx(dev); SMC_ACK_INT(IM_TX_INT); -#if THROTTLE_TX_PKTS - netif_wake_queue(dev); -#endif + if (THROTTLE_TX_PKTS) + netif_wake_queue(dev); } else if (status & IM_ALLOC_INT) { DBG(3, "%s: Allocation irq\n", dev->name); smc_hardware_send_packet(dev); mask |= (IM_TX_INT | IM_TX_EMPTY_INT); mask &= ~IM_ALLOC_INT; -#if ! THROTTLE_TX_PKTS - netif_wake_queue(dev); -#endif + if (!THROTTLE_TX_PKTS) + netif_wake_queue(dev); } else if (status & IM_TX_EMPTY_INT) { DBG(3, "%s: TX empty\n", dev->name); mask &= ~IM_TX_EMPTY_INT; @@ -1438,7 +1433,7 @@ smc_open(struct net_device *dev) * address using ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx */ if (!is_valid_ether_addr(dev->dev_addr)) { - DBG(2, (KERN_DEBUG "smc_open: no valid ethernet hw addr\n")); + PRINTK("%s: no valid ethernet hw addr\n", __FUNCTION__); return -EINVAL; } @@ -1464,7 +1459,7 @@ smc_open(struct net_device *dev) SMC_SELECT_BANK(1); SMC_SET_MAC_ADDR(dev->dev_addr); - /* Configure the PHY */ + /* Configure the PHY, initialize the link state */ if (lp->phy_type != 0) smc_phy_configure(dev); else { @@ -1473,12 +1468,6 @@ smc_open(struct net_device *dev) spin_unlock_irq(&lp->lock); } - /* - * make sure to initialize the link state with netif_carrier_off() - * somewhere, too --jgarzik - * - * smc_phy_configure() and smc_10bt_check_media() does that. --rmk - */ netif_start_queue(dev); return 0; } @@ -1879,6 +1868,7 @@ static int __init smc_probe(struct net_d goto err_out; set_irq_type(dev->irq, IRQT_RISING); + #ifdef SMC_USE_PXA_DMA { int dma = pxa_request_dma(dev->name, DMA_PRIO_LOW, diff -puN drivers/net/smc91x.h~smc91x-assorted-minor-cleanups drivers/net/smc91x.h --- 25/drivers/net/smc91x.h~smc91x-assorted-minor-cleanups 2004-10-01 20:16:31.576268896 -0700 +++ 25-akpm/drivers/net/smc91x.h 2004-10-01 20:16:31.582267984 -0700 @@ -266,7 +266,8 @@ smc_pxa_dma_insl(u_long ioaddr, u_long p /* 64 bit alignment is required for memory to memory DMA */ if ((long)buf & 4) { - *((u32 *)buf)++ = SMC_inl(ioaddr, reg); + *((u32 *)buf) = SMC_inl(ioaddr, reg); + buf += 4; len--; } @@ -278,7 +279,8 @@ smc_pxa_dma_insl(u_long ioaddr, u_long p DCMD(dma) = (DCMD_INCTRGADDR | DCMD_BURST32 | DCMD_WIDTH4 | (DCMD_LENGTH & len)); DCSR(dma) = DCSR_NODESC | DCSR_RUN; - while (!(DCSR(dma) & DCSR_STOPSTATE)); + while (!(DCSR(dma) & DCSR_STOPSTATE)) + cpu_relax(); DCSR(dma) = 0; dma_unmap_single(NULL, dmabuf, len, PCI_DMA_FROMDEVICE); } @@ -302,7 +304,8 @@ smc_pxa_dma_insw(u_long ioaddr, u_long p /* 64 bit alignment is required for memory to memory DMA */ while ((long)buf & 6) { - *((u16 *)buf)++ = SMC_inw(ioaddr, reg); + *((u16 *)buf) = SMC_inw(ioaddr, reg); + buf += 2; len--; } @@ -314,7 +317,8 @@ smc_pxa_dma_insw(u_long ioaddr, u_long p DCMD(dma) = (DCMD_INCTRGADDR | DCMD_BURST32 | DCMD_WIDTH2 | (DCMD_LENGTH & len)); DCSR(dma) = DCSR_NODESC | DCSR_RUN; - while (!(DCSR(dma) & DCSR_STOPSTATE)); + while (!(DCSR(dma) & DCSR_STOPSTATE)) + cpu_relax(); DCSR(dma) = 0; dma_unmap_single(NULL, dmabuf, len, PCI_DMA_FROMDEVICE); } _