Commit b02a9258 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Jeff Garzik

sky2: use dev_err for error reports

Use the standard dev_xxx functions instead of printk directly for
error reports. Fix a bug where the initialization would return 0
if allocation of network device failed.
Signed-off-by: default avatarStephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent e3173832
...@@ -2266,8 +2266,8 @@ static void sky2_hw_intr(struct sky2_hw *hw) ...@@ -2266,8 +2266,8 @@ static void sky2_hw_intr(struct sky2_hw *hw)
pci_err = sky2_pci_read16(hw, PCI_STATUS); pci_err = sky2_pci_read16(hw, PCI_STATUS);
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n", dev_err(&hw->pdev->dev, "PCI hardware error (0x%x)\n",
pci_name(hw->pdev), pci_err); pci_err);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
sky2_pci_write16(hw, PCI_STATUS, sky2_pci_write16(hw, PCI_STATUS,
...@@ -2282,8 +2282,8 @@ static void sky2_hw_intr(struct sky2_hw *hw) ...@@ -2282,8 +2282,8 @@ static void sky2_hw_intr(struct sky2_hw *hw)
pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT); pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT);
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", dev_err(&hw->pdev->dev, "PCI Express error (0x%x)\n",
pci_name(hw->pdev), pex_err); pex_err);
/* clear the interrupt */ /* clear the interrupt */
sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
...@@ -2479,8 +2479,8 @@ static int __devinit sky2_init(struct sky2_hw *hw) ...@@ -2479,8 +2479,8 @@ static int __devinit sky2_init(struct sky2_hw *hw)
hw->chip_id = sky2_read8(hw, B2_CHIP_ID); hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) { if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) {
printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n", dev_err(&hw->pdev->dev, "unsupported chip type 0x%x\n",
pci_name(hw->pdev), hw->chip_id); hw->chip_id);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -2488,9 +2488,9 @@ static int __devinit sky2_init(struct sky2_hw *hw) ...@@ -2488,9 +2488,9 @@ static int __devinit sky2_init(struct sky2_hw *hw)
/* This rev is really old, and requires untested workarounds */ /* This rev is really old, and requires untested workarounds */
if (hw->chip_id == CHIP_ID_YUKON_EC && hw->chip_rev == CHIP_REV_YU_EC_A1) { if (hw->chip_id == CHIP_ID_YUKON_EC && hw->chip_rev == CHIP_REV_YU_EC_A1) {
printk(KERN_ERR PFX "%s: unsupported revision Yukon-%s (0x%x) rev %d\n", dev_err(&hw->pdev->dev, "unsupported revision Yukon-%s (0x%x) rev %d\n",
pci_name(hw->pdev), yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL],
hw->chip_id, hw->chip_rev); hw->chip_id, hw->chip_rev);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -3298,7 +3298,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, ...@@ -3298,7 +3298,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
struct net_device *dev = alloc_etherdev(sizeof(*sky2)); struct net_device *dev = alloc_etherdev(sizeof(*sky2));
if (!dev) { if (!dev) {
printk(KERN_ERR "sky2 etherdev alloc failed"); dev_err(&hw->pdev->dev, "etherdev alloc failed");
return NULL; return NULL;
} }
...@@ -3415,8 +3415,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw) ...@@ -3415,8 +3415,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
err = request_irq(pdev->irq, sky2_test_intr, 0, DRV_NAME, hw); err = request_irq(pdev->irq, sky2_test_intr, 0, DRV_NAME, hw);
if (err) { if (err) {
printk(KERN_ERR PFX "%s: cannot assign irq %d\n", dev_err(&pdev->dev, "cannot assign irq %d\n", pdev->irq);
pci_name(pdev), pdev->irq);
return err; return err;
} }
...@@ -3427,9 +3426,8 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw) ...@@ -3427,9 +3426,8 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
if (!hw->msi) { if (!hw->msi) {
/* MSI test failed, go back to INTx mode */ /* MSI test failed, go back to INTx mode */
printk(KERN_INFO PFX "%s: No interrupt generated using MSI, " dev_info(&pdev->dev, "No interrupt generated using MSI, "
"switching to INTx mode.\n", "switching to INTx mode.\n");
pci_name(pdev));
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ); sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
...@@ -3464,15 +3462,13 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -3464,15 +3462,13 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
err = pci_enable_device(pdev); err = pci_enable_device(pdev);
if (err) { if (err) {
printk(KERN_ERR PFX "%s cannot enable PCI device\n", dev_err(&pdev->dev, "cannot enable PCI device\n");
pci_name(pdev));
goto err_out; goto err_out;
} }
err = pci_request_regions(pdev, DRV_NAME); err = pci_request_regions(pdev, DRV_NAME);
if (err) { if (err) {
printk(KERN_ERR PFX "%s cannot obtain PCI resources\n", dev_err(&pdev->dev, "cannot obtain PCI resources\n");
pci_name(pdev));
goto err_out; goto err_out;
} }
...@@ -3483,16 +3479,14 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -3483,16 +3479,14 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
using_dac = 1; using_dac = 1;
err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
if (err < 0) { if (err < 0) {
printk(KERN_ERR PFX "%s unable to obtain 64 bit DMA " dev_err(&pdev->dev, "unable to obtain 64 bit DMA "
"for consistent allocations\n", pci_name(pdev)); "for consistent allocations\n");
goto err_out_free_regions; goto err_out_free_regions;
} }
} else { } else {
err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
if (err) { if (err) {
printk(KERN_ERR PFX "%s no usable DMA configuration\n", dev_err(&pdev->dev, "no usable DMA configuration\n");
pci_name(pdev));
goto err_out_free_regions; goto err_out_free_regions;
} }
} }
...@@ -3502,8 +3496,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -3502,8 +3496,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
err = -ENOMEM; err = -ENOMEM;
hw = kzalloc(sizeof(*hw), GFP_KERNEL); hw = kzalloc(sizeof(*hw), GFP_KERNEL);
if (!hw) { if (!hw) {
printk(KERN_ERR PFX "%s: cannot allocate hardware struct\n", dev_err(&pdev->dev, "cannot allocate hardware struct\n");
pci_name(pdev));
goto err_out_free_regions; goto err_out_free_regions;
} }
...@@ -3511,8 +3504,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -3511,8 +3504,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
if (!hw->regs) { if (!hw->regs) {
printk(KERN_ERR PFX "%s: cannot map device registers\n", dev_err(&pdev->dev, "cannot map device registers\n");
pci_name(pdev));
goto err_out_free_hw; goto err_out_free_hw;
} }
...@@ -3538,7 +3530,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -3538,7 +3530,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
if (err) if (err)
goto err_out_iounmap; goto err_out_iounmap;
printk(KERN_INFO PFX "v%s addr 0x%llx irq %d Yukon-%s (0x%x) rev %d\n", dev_info(&pdev->dev, "v%s addr 0x%llx irq %d Yukon-%s (0x%x) rev %d\n",
DRV_VERSION, (unsigned long long)pci_resource_start(pdev, 0), DRV_VERSION, (unsigned long long)pci_resource_start(pdev, 0),
pdev->irq, yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], pdev->irq, yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL],
hw->chip_id, hw->chip_rev); hw->chip_id, hw->chip_rev);
...@@ -3561,16 +3553,14 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -3561,16 +3553,14 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
err = register_netdev(dev); err = register_netdev(dev);
if (err) { if (err) {
printk(KERN_ERR PFX "%s: cannot register net device\n", dev_err(&pdev->dev, "cannot register net device\n");
pci_name(pdev));
goto err_out_free_netdev; goto err_out_free_netdev;
} }
err = request_irq(pdev->irq, sky2_intr, hw->msi ? 0 : IRQF_SHARED, err = request_irq(pdev->irq, sky2_intr, hw->msi ? 0 : IRQF_SHARED,
dev->name, hw); dev->name, hw);
if (err) { if (err) {
printk(KERN_ERR PFX "%s: cannot assign irq %d\n", dev_err(&pdev->dev, "cannot assign irq %d\n", pdev->irq);
pci_name(pdev), pdev->irq);
goto err_out_unregister; goto err_out_unregister;
} }
sky2_write32(hw, B0_IMSK, Y2_IS_BASE); sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
...@@ -3581,18 +3571,15 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -3581,18 +3571,15 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
struct net_device *dev1; struct net_device *dev1;
dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default); dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default);
if (!dev1) { if (!dev1)
printk(KERN_WARNING PFX dev_warn(&pdev->dev, "allocation for second device failed\n");
"allocation of second port failed\n"); else if ((err = register_netdev(dev1))) {
} dev_warn(&pdev->dev,
else if (!(err = register_netdev(dev1))) "register of second port failed (%d)\n", err);
sky2_show_addr(dev1);
else {
printk(KERN_WARNING PFX
"register of second port failed (%d)\n", err);
hw->dev[1] = NULL; hw->dev[1] = NULL;
free_netdev(dev1); free_netdev(dev1);
} } else
sky2_show_addr(dev1);
} }
setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw); setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw);
...@@ -3730,7 +3717,7 @@ static int sky2_resume(struct pci_dev *pdev) ...@@ -3730,7 +3717,7 @@ static int sky2_resume(struct pci_dev *pdev)
sky2_idle_start(hw); sky2_idle_start(hw);
return 0; return 0;
out: out:
printk(KERN_ERR PFX "%s: resume failed (%d)\n", pci_name(pdev), err); dev_err(&pdev->dev, "resume failed (%d)\n", err);
pci_disable_device(pdev); pci_disable_device(pdev);
return err; return err;
} }
......
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