Commit 63097b3a authored by Don Fry's avatar Don Fry Committed by David S. Miller

pcnet32: VLB support fixes

VLB support has been broken since at least 2004-2005 period as some
changes introduced back then assumed that ->pci_dev is always valid,
lets try to fix it:

- remove duplicated SET_NETDEV_DEV() call

- call SET_NETDEV_DEV() only for PCI devices

- check for ->pci_dev validity in pcnet32_open()

[ Alternatively we may consider removing VLB support but there would not
  be much gain in it since an extra driver code needed for VLB support is
  minimal and quite simple. ]

This takes care of the following entry from Dan's list:

drivers/net/pcnet32.c +1889 pcnet32_probe1(298) warning: variable derefenced before check 'pdev'
Reported-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: default avatarDon Fry <pcnet32@verizon.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent df4e7f72
...@@ -1722,7 +1722,9 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) ...@@ -1722,7 +1722,9 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
ret = -ENOMEM; ret = -ENOMEM;
goto err_release_region; goto err_release_region;
} }
SET_NETDEV_DEV(dev, &pdev->dev);
if (pdev)
SET_NETDEV_DEV(dev, &pdev->dev);
if (pcnet32_debug & NETIF_MSG_PROBE) if (pcnet32_debug & NETIF_MSG_PROBE)
printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr); printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr);
...@@ -1821,7 +1823,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) ...@@ -1821,7 +1823,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
spin_lock_init(&lp->lock); spin_lock_init(&lp->lock);
SET_NETDEV_DEV(dev, &pdev->dev);
lp->name = chipname; lp->name = chipname;
lp->shared_irq = shared; lp->shared_irq = shared;
lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */ lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */
...@@ -2085,6 +2086,7 @@ static void pcnet32_free_ring(struct net_device *dev) ...@@ -2085,6 +2086,7 @@ static void pcnet32_free_ring(struct net_device *dev)
static int pcnet32_open(struct net_device *dev) static int pcnet32_open(struct net_device *dev)
{ {
struct pcnet32_private *lp = netdev_priv(dev); struct pcnet32_private *lp = netdev_priv(dev);
struct pci_dev *pdev = lp->pci_dev;
unsigned long ioaddr = dev->base_addr; unsigned long ioaddr = dev->base_addr;
u16 val; u16 val;
int i; int i;
...@@ -2145,9 +2147,9 @@ static int pcnet32_open(struct net_device *dev) ...@@ -2145,9 +2147,9 @@ static int pcnet32_open(struct net_device *dev)
lp->a.write_csr(ioaddr, 124, val); lp->a.write_csr(ioaddr, 124, val);
/* Allied Telesyn AT 2700/2701 FX are 100Mbit only and do not negotiate */ /* Allied Telesyn AT 2700/2701 FX are 100Mbit only and do not negotiate */
if (lp->pci_dev->subsystem_vendor == PCI_VENDOR_ID_AT && if (pdev && pdev->subsystem_vendor == PCI_VENDOR_ID_AT &&
(lp->pci_dev->subsystem_device == PCI_SUBDEVICE_ID_AT_2700FX || (pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2700FX ||
lp->pci_dev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) { pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) {
if (lp->options & PCNET32_PORT_ASEL) { if (lp->options & PCNET32_PORT_ASEL) {
lp->options = PCNET32_PORT_FD | PCNET32_PORT_100; lp->options = PCNET32_PORT_FD | PCNET32_PORT_100;
if (netif_msg_link(lp)) if (netif_msg_link(lp))
......
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