Skip to content

Commit

Permalink
[netdrvr] Use dev_printk() when ethernet interface isn't available
Browse files Browse the repository at this point in the history
For messages prior to register_netdev(), prefer dev_printk() because
that prints out both our driver name and our [PCI | whatever] bus id.

Updates: 8139{cp,too}, b44, bnx2, cassini, {eepro,epic}100, fealnx,
	 hamachi, ne2k-pci, ns83820, pci-skeleton, r8169.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Jeff Garzik committed Jul 5, 2006
1 parent cabb766 commit 2e8a538
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 135 deletions.
38 changes: 22 additions & 16 deletions drivers/net/8139cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1836,9 +1836,11 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)

if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pci_rev < 0x20) {
printk(KERN_ERR PFX "pci dev %s (id %04x:%04x rev %02x) is not an 8139C+ compatible chip\n",
pci_name(pdev), pdev->vendor, pdev->device, pci_rev);
printk(KERN_ERR PFX "Try the \"8139too\" driver instead.\n");
dev_printk(KERN_ERR, &pdev->dev,
"This (id %04x:%04x rev %02x) is not an 8139C+ compatible chip\n",
pdev->vendor, pdev->device, pci_rev);
dev_printk(KERN_ERR, &pdev->dev,
"Try the \"8139too\" driver instead.\n");
return -ENODEV;
}

Expand Down Expand Up @@ -1876,14 +1878,14 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
pciaddr = pci_resource_start(pdev, 1);
if (!pciaddr) {
rc = -EIO;
printk(KERN_ERR PFX "no MMIO resource for pci dev %s\n",
pci_name(pdev));
dev_printk(KERN_ERR, &pdev->dev, "no MMIO resource\n");
goto err_out_res;
}
if (pci_resource_len(pdev, 1) < CP_REGS_SIZE) {
rc = -EIO;
printk(KERN_ERR PFX "MMIO resource (%llx) too small on pci dev %s\n",
(unsigned long long)pci_resource_len(pdev, 1), pci_name(pdev));
dev_printk(KERN_ERR, &pdev->dev,
"MMIO resource (%llx) too small\n",
(unsigned long long)pci_resource_len(pdev, 1));
goto err_out_res;
}

Expand All @@ -1897,14 +1899,15 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)

rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) {
printk(KERN_ERR PFX "No usable DMA configuration, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"No usable DMA configuration, aborting.\n");
goto err_out_res;
}
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
if (rc) {
printk(KERN_ERR PFX "No usable consistent DMA configuration, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"No usable consistent DMA configuration, "
"aborting.\n");
goto err_out_res;
}
}
Expand All @@ -1915,9 +1918,10 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
regs = ioremap(pciaddr, CP_REGS_SIZE);
if (!regs) {
rc = -EIO;
printk(KERN_ERR PFX "Cannot map PCI MMIO (%llx@%llx) on pci dev %s\n",
(unsigned long long)pci_resource_len(pdev, 1),
(unsigned long long)pciaddr, pci_name(pdev));
dev_printk(KERN_ERR, &pdev->dev,
"Cannot map PCI MMIO (%llx@%llx)\n",
(unsigned long long)pci_resource_len(pdev, 1),
(unsigned long long)pciaddr);
goto err_out_res;
}
dev->base_addr = (unsigned long) regs;
Expand Down Expand Up @@ -1986,7 +1990,8 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
/* enable busmastering and memory-write-invalidate */
pci_set_master(pdev);

if (cp->wol_enabled) cp_set_d3_state (cp);
if (cp->wol_enabled)
cp_set_d3_state (cp);

return 0;

Expand All @@ -2011,7 +2016,8 @@ static void cp_remove_one (struct pci_dev *pdev)
BUG_ON(!dev);
unregister_netdev(dev);
iounmap(cp->regs);
if (cp->wol_enabled) pci_set_power_state (pdev, PCI_D0);
if (cp->wol_enabled)
pci_set_power_state (pdev, PCI_D0);
pci_release_regions(pdev);
pci_clear_mwi(pdev);
pci_disable_device(pdev);
Expand Down
41 changes: 25 additions & 16 deletions drivers/net/8139too.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
/* dev and priv zeroed in alloc_etherdev */
dev = alloc_etherdev (sizeof (*tp));
if (dev == NULL) {
printk (KERN_ERR PFX "%s: Unable to alloc new net device\n", pci_name(pdev));
dev_printk (KERN_ERR, &pdev->dev,
"Unable to alloc new net device\n");
return -ENOMEM;
}
SET_MODULE_OWNER(dev);
Expand Down Expand Up @@ -800,31 +801,35 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
#ifdef USE_IO_OPS
/* make sure PCI base addr 0 is PIO */
if (!(pio_flags & IORESOURCE_IO)) {
printk (KERN_ERR PFX "%s: region #0 not a PIO resource, aborting\n", pci_name(pdev));
dev_printk (KERN_ERR, &pdev->dev,
"region #0 not a PIO resource, aborting\n");
rc = -ENODEV;
goto err_out;
}
/* check for weird/broken PCI region reporting */
if (pio_len < RTL_MIN_IO_SIZE) {
printk (KERN_ERR PFX "%s: Invalid PCI I/O region size(s), aborting\n", pci_name(pdev));
dev_printk (KERN_ERR, &pdev->dev,
"Invalid PCI I/O region size(s), aborting\n");
rc = -ENODEV;
goto err_out;
}
#else
/* make sure PCI base addr 1 is MMIO */
if (!(mmio_flags & IORESOURCE_MEM)) {
printk (KERN_ERR PFX "%s: region #1 not an MMIO resource, aborting\n", pci_name(pdev));
dev_printk (KERN_ERR, &pdev->dev,
"region #1 not an MMIO resource, aborting\n");
rc = -ENODEV;
goto err_out;
}
if (mmio_len < RTL_MIN_IO_SIZE) {
printk (KERN_ERR PFX "%s: Invalid PCI mem region size(s), aborting\n", pci_name(pdev));
dev_printk (KERN_ERR, &pdev->dev,
"Invalid PCI mem region size(s), aborting\n");
rc = -ENODEV;
goto err_out;
}
#endif

rc = pci_request_regions (pdev, "8139too");
rc = pci_request_regions (pdev, DRV_NAME);
if (rc)
goto err_out;
disable_dev_on_err = 1;
Expand All @@ -835,7 +840,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
#ifdef USE_IO_OPS
ioaddr = ioport_map(pio_start, pio_len);
if (!ioaddr) {
printk (KERN_ERR PFX "%s: cannot map PIO, aborting\n", pci_name(pdev));
dev_printk (KERN_ERR, &pdev->dev, "cannot map PIO, aborting\n");
rc = -EIO;
goto err_out;
}
Expand All @@ -846,7 +851,8 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
/* ioremap MMIO region */
ioaddr = pci_iomap(pdev, 1, 0);
if (ioaddr == NULL) {
printk (KERN_ERR PFX "%s: cannot remap MMIO, aborting\n", pci_name(pdev));
dev_printk (KERN_ERR, &pdev->dev,
"cannot remap MMIO, aborting\n");
rc = -EIO;
goto err_out;
}
Expand All @@ -860,8 +866,8 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,

/* check for missing/broken hardware */
if (RTL_R32 (TxConfig) == 0xFFFFFFFF) {
printk (KERN_ERR PFX "%s: Chip not responding, ignoring board\n",
pci_name(pdev));
dev_printk (KERN_ERR, &pdev->dev,
"Chip not responding, ignoring board\n");
rc = -EIO;
goto err_out;
}
Expand All @@ -875,9 +881,10 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
}

/* if unknown chip, assume array element #0, original RTL-8139 in this case */
printk (KERN_DEBUG PFX "%s: unknown chip version, assuming RTL-8139\n",
pci_name(pdev));
printk (KERN_DEBUG PFX "%s: TxConfig = 0x%lx\n", pci_name(pdev), RTL_R32 (TxConfig));
dev_printk (KERN_DEBUG, &pdev->dev,
"unknown chip version, assuming RTL-8139\n");
dev_printk (KERN_DEBUG, &pdev->dev,
"TxConfig = 0x%lx\n", RTL_R32 (TxConfig));
tp->chipset = 0;

match:
Expand Down Expand Up @@ -954,9 +961,11 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,

if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pci_rev >= 0x20) {
printk(KERN_INFO PFX "pci dev %s (id %04x:%04x rev %02x) is an enhanced 8139C+ chip\n",
pci_name(pdev), pdev->vendor, pdev->device, pci_rev);
printk(KERN_INFO PFX "Use the \"8139cp\" driver for improved performance and stability.\n");
dev_printk(KERN_INFO, &pdev->dev,
"This (id %04x:%04x rev %02x) is an enhanced 8139C+ chip\n",
pdev->vendor, pdev->device, pci_rev);
dev_printk(KERN_INFO, &pdev->dev,
"Use the \"8139cp\" driver for improved performance and stability.\n");
}

i = rtl8139_init_board (pdev, &dev);
Expand Down
28 changes: 15 additions & 13 deletions drivers/net/b44.c
Original file line number Diff line number Diff line change
Expand Up @@ -2120,38 +2120,39 @@ static int __devinit b44_init_one(struct pci_dev *pdev,

err = pci_enable_device(pdev);
if (err) {
printk(KERN_ERR PFX "Cannot enable PCI device, "
dev_printk(KERN_ERR, &pdev->dev, "Cannot enable PCI device, "
"aborting.\n");
return err;
}

if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
printk(KERN_ERR PFX "Cannot find proper PCI device "
dev_printk(KERN_ERR, &pdev->dev,
"Cannot find proper PCI device "
"base address, aborting.\n");
err = -ENODEV;
goto err_out_disable_pdev;
}

err = pci_request_regions(pdev, DRV_MODULE_NAME);
if (err) {
printk(KERN_ERR PFX "Cannot obtain PCI resources, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Cannot obtain PCI resources, aborting.\n");
goto err_out_disable_pdev;
}

pci_set_master(pdev);

err = pci_set_dma_mask(pdev, (u64) B44_DMA_MASK);
if (err) {
printk(KERN_ERR PFX "No usable DMA configuration, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"No usable DMA configuration, aborting.\n");
goto err_out_free_res;
}

err = pci_set_consistent_dma_mask(pdev, (u64) B44_DMA_MASK);
if (err) {
printk(KERN_ERR PFX "No usable DMA configuration, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"No usable DMA configuration, aborting.\n");
goto err_out_free_res;
}

Expand All @@ -2160,7 +2161,8 @@ static int __devinit b44_init_one(struct pci_dev *pdev,

dev = alloc_etherdev(sizeof(*bp));
if (!dev) {
printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Etherdev alloc failed, aborting.\n");
err = -ENOMEM;
goto err_out_free_res;
}
Expand All @@ -2181,7 +2183,7 @@ static int __devinit b44_init_one(struct pci_dev *pdev,

bp->regs = ioremap(b44reg_base, b44reg_len);
if (bp->regs == 0UL) {
printk(KERN_ERR PFX "Cannot map device registers, "
dev_printk(KERN_ERR, &pdev->dev, "Cannot map device registers, "
"aborting.\n");
err = -ENOMEM;
goto err_out_free_dev;
Expand Down Expand Up @@ -2212,8 +2214,8 @@ static int __devinit b44_init_one(struct pci_dev *pdev,

err = b44_get_invariants(bp);
if (err) {
printk(KERN_ERR PFX "Problem fetching invariants of chip, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Problem fetching invariants of chip, aborting.\n");
goto err_out_iounmap;
}

Expand All @@ -2233,7 +2235,7 @@ static int __devinit b44_init_one(struct pci_dev *pdev,

err = register_netdev(dev);
if (err) {
printk(KERN_ERR PFX "Cannot register net device, "
dev_printk(KERN_ERR, &pdev->dev, "Cannot register net device, "
"aborting.\n");
goto err_out_iounmap;
}
Expand Down
37 changes: 22 additions & 15 deletions drivers/net/bnx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -5575,51 +5575,55 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
/* enable device (incl. PCI PM wakeup), and bus-mastering */
rc = pci_enable_device(pdev);
if (rc) {
printk(KERN_ERR PFX "Cannot enable PCI device, aborting.");
dev_printk(KERN_ERR, &pdev->dev,
"Cannot enable PCI device, aborting.");
goto err_out;
}

if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
printk(KERN_ERR PFX "Cannot find PCI device base address, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Cannot find PCI device base address, aborting.\n");
rc = -ENODEV;
goto err_out_disable;
}

rc = pci_request_regions(pdev, DRV_MODULE_NAME);
if (rc) {
printk(KERN_ERR PFX "Cannot obtain PCI resources, aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Cannot obtain PCI resources, aborting.\n");
goto err_out_disable;
}

pci_set_master(pdev);

bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
if (bp->pm_cap == 0) {
printk(KERN_ERR PFX "Cannot find power management capability, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Cannot find power management capability, aborting.\n");
rc = -EIO;
goto err_out_release;
}

bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
if (bp->pcix_cap == 0) {
printk(KERN_ERR PFX "Cannot find PCIX capability, aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Cannot find PCIX capability, aborting.\n");
rc = -EIO;
goto err_out_release;
}

if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
bp->flags |= USING_DAC_FLAG;
if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) {
printk(KERN_ERR PFX "pci_set_consistent_dma_mask "
"failed, aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"pci_set_consistent_dma_mask failed, aborting.\n");
rc = -EIO;
goto err_out_release;
}
}
else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0) {
printk(KERN_ERR PFX "System does not support DMA, aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"System does not support DMA, aborting.\n");
rc = -EIO;
goto err_out_release;
}
Expand All @@ -5639,7 +5643,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
bp->regview = ioremap_nocache(dev->base_addr, mem_len);

if (!bp->regview) {
printk(KERN_ERR PFX "Cannot map register space, aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Cannot map register space, aborting.\n");
rc = -ENOMEM;
goto err_out_release;
}
Expand Down Expand Up @@ -5711,8 +5716,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
else if ((CHIP_ID(bp) == CHIP_ID_5706_A1) &&
!(bp->flags & PCIX_FLAG)) {

printk(KERN_ERR PFX "5706 A1 can only be used in a PCIX bus, "
"aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"5706 A1 can only be used in a PCIX bus, aborting.\n");
goto err_out_unmap;
}

Expand All @@ -5733,7 +5738,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)

if ((reg & BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK) !=
BNX2_DEV_INFO_SIGNATURE_MAGIC) {
printk(KERN_ERR PFX "Firmware not running, aborting.\n");
dev_printk(KERN_ERR, &pdev->dev,
"Firmware not running, aborting.\n");
rc = -ENODEV;
goto err_out_unmap;
}
Expand Down Expand Up @@ -5895,7 +5901,8 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
#endif

if ((rc = register_netdev(dev))) {
printk(KERN_ERR PFX "Cannot register net device\n");
dev_printk(KERN_ERR, &pdev->dev,
"Cannot register net device\n");
if (bp->regview)
iounmap(bp->regview);
pci_release_regions(pdev);
Expand Down
Loading

0 comments on commit 2e8a538

Please sign in to comment.