aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-11-23 21:49:27 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:04:03 -0500
commit092427be8cef341c957a93ec2469890501a09bff (patch)
treed4f9e7c9860212bdd76f844d681055d5303b6bff /drivers
parent4790654c71b250018ecc234f6b9f1ed96a55572d (diff)
drivers/net/r6040: fix obvious problems (but more remain)
- checkpatch fixes - fix bogus and uninitialized return codes in r6040_start_xmit() - netdev_get_settings() fix obvious locking bug flagged by compiler warning - set DMA consistent mask - remove unnecessary setting of dev->base_addr Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/r6040.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index edce5a4c7f20..1d7efa2b6cbc 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -42,12 +42,12 @@
42#include <linux/ethtool.h> 42#include <linux/ethtool.h>
43#include <linux/crc32.h> 43#include <linux/crc32.h>
44#include <linux/spinlock.h> 44#include <linux/spinlock.h>
45#include <linux/bitops.h>
46#include <linux/io.h>
47#include <linux/irq.h>
48#include <linux/uaccess.h>
45 49
46#include <asm/processor.h> 50#include <asm/processor.h>
47#include <asm/bitops.h>
48#include <asm/io.h>
49#include <asm/irq.h>
50#include <asm/uaccess.h>
51 51
52#define DRV_NAME "r6040" 52#define DRV_NAME "r6040"
53#define DRV_VERSION "0.16" 53#define DRV_VERSION "0.16"
@@ -181,7 +181,7 @@ static char version[] __devinitdata = KERN_INFO DRV_NAME
181 ": RDC R6040 NAPI net driver," 181 ": RDC R6040 NAPI net driver,"
182 "version "DRV_VERSION " (" DRV_RELDATE ")\n"; 182 "version "DRV_VERSION " (" DRV_RELDATE ")\n";
183 183
184static int phy_table[] = { PHY1_ADDR, PHY2_ADDR}; 184static int phy_table[] = { PHY1_ADDR, PHY2_ADDR };
185 185
186/* Read a word data from PHY Chip */ 186/* Read a word data from PHY Chip */
187static int phy_read(void __iomem *ioaddr, int phy_addr, int reg) 187static int phy_read(void __iomem *ioaddr, int phy_addr, int reg)
@@ -771,15 +771,7 @@ r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
771 struct r6040_descriptor *descptr; 771 struct r6040_descriptor *descptr;
772 void __iomem *ioaddr = lp->base; 772 void __iomem *ioaddr = lp->base;
773 unsigned long flags; 773 unsigned long flags;
774 int ret; 774 int ret = NETDEV_TX_OK;
775
776 if (!skb) /* NULL skb directly return */
777 return ret;
778
779 if (skb->len >= MAX_BUF_SIZE) { /* Packet too long, drop it */
780 dev_kfree_skb(skb);
781 return ret;
782 }
783 775
784 /* Critical Section */ 776 /* Critical Section */
785 spin_lock_irqsave(&lp->lock, flags); 777 spin_lock_irqsave(&lp->lock, flags);
@@ -787,8 +779,9 @@ r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
787 /* TX resource check */ 779 /* TX resource check */
788 if (!lp->tx_free_desc) { 780 if (!lp->tx_free_desc) {
789 spin_unlock_irqrestore(&lp->lock, flags); 781 spin_unlock_irqrestore(&lp->lock, flags);
782 netif_stop_queue(dev);
790 printk(KERN_ERR DRV_NAME ": no tx descriptor\n"); 783 printk(KERN_ERR DRV_NAME ": no tx descriptor\n");
791 ret = 1; 784 ret = NETDEV_TX_BUSY;
792 return ret; 785 return ret;
793 } 786 }
794 787
@@ -916,7 +909,7 @@ static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
916 909
917 spin_lock_irq(&rp->lock); 910 spin_lock_irq(&rp->lock);
918 rc = mii_ethtool_gset(&rp->mii_if, cmd); 911 rc = mii_ethtool_gset(&rp->mii_if, cmd);
919 spin_unlock_irq(&rp->mii_if); 912 spin_unlock_irq(&rp->lock);
920 913
921 return rc; 914 return rc;
922} 915}
@@ -973,6 +966,11 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
973 "not supported by the card\n"); 966 "not supported by the card\n");
974 return -ENODEV; 967 return -ENODEV;
975 } 968 }
969 if (pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
970 printk(KERN_ERR DRV_NAME "32-bit PCI DMA addresses"
971 "not supported by the card\n");
972 return -ENODEV;
973 }
976 974
977 /* IO Size check */ 975 /* IO Size check */
978 if (pci_resource_len(pdev, 0) < io_size) { 976 if (pci_resource_len(pdev, 0) < io_size) {
@@ -1006,7 +1004,6 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1006 } 1004 }
1007 1005
1008 /* Init system & device */ 1006 /* Init system & device */
1009 dev->base_addr = (unsigned long)ioaddr;
1010 lp->base = ioaddr; 1007 lp->base = ioaddr;
1011 dev->irq = pdev->irq; 1008 dev->irq = pdev->irq;
1012 1009