diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-02-06 13:45:40 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-07 18:50:40 -0500 |
commit | b02a92586dca362b0b76ad527b91bd44ce58ece5 (patch) | |
tree | 4c41505159c75398c7db2d7c2aced191a9190f2f /drivers/net | |
parent | e3173832d7be8f62a181a1888a65f0a3dc58c2e0 (diff) |
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: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/sky2.c | 75 |
1 files changed, 31 insertions, 44 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index f4c0bc19b005..5abcf853e98b 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -2266,8 +2266,8 @@ static void sky2_hw_intr(struct sky2_hw *hw) | |||
2266 | 2266 | ||
2267 | pci_err = sky2_pci_read16(hw, PCI_STATUS); | 2267 | pci_err = sky2_pci_read16(hw, PCI_STATUS); |
2268 | if (net_ratelimit()) | 2268 | if (net_ratelimit()) |
2269 | printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n", | 2269 | dev_err(&hw->pdev->dev, "PCI hardware error (0x%x)\n", |
2270 | pci_name(hw->pdev), pci_err); | 2270 | pci_err); |
2271 | 2271 | ||
2272 | sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); | 2272 | sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); |
2273 | sky2_pci_write16(hw, PCI_STATUS, | 2273 | sky2_pci_write16(hw, PCI_STATUS, |
@@ -2282,8 +2282,8 @@ static void sky2_hw_intr(struct sky2_hw *hw) | |||
2282 | pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT); | 2282 | pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT); |
2283 | 2283 | ||
2284 | if (net_ratelimit()) | 2284 | if (net_ratelimit()) |
2285 | printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", | 2285 | dev_err(&hw->pdev->dev, "PCI Express error (0x%x)\n", |
2286 | pci_name(hw->pdev), pex_err); | 2286 | pex_err); |
2287 | 2287 | ||
2288 | /* clear the interrupt */ | 2288 | /* clear the interrupt */ |
2289 | sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); | 2289 | sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); |
@@ -2479,8 +2479,8 @@ static int __devinit sky2_init(struct sky2_hw *hw) | |||
2479 | 2479 | ||
2480 | hw->chip_id = sky2_read8(hw, B2_CHIP_ID); | 2480 | hw->chip_id = sky2_read8(hw, B2_CHIP_ID); |
2481 | if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) { | 2481 | if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) { |
2482 | printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n", | 2482 | dev_err(&hw->pdev->dev, "unsupported chip type 0x%x\n", |
2483 | pci_name(hw->pdev), hw->chip_id); | 2483 | hw->chip_id); |
2484 | return -EOPNOTSUPP; | 2484 | return -EOPNOTSUPP; |
2485 | } | 2485 | } |
2486 | 2486 | ||
@@ -2488,9 +2488,9 @@ static int __devinit sky2_init(struct sky2_hw *hw) | |||
2488 | 2488 | ||
2489 | /* This rev is really old, and requires untested workarounds */ | 2489 | /* This rev is really old, and requires untested workarounds */ |
2490 | if (hw->chip_id == CHIP_ID_YUKON_EC && hw->chip_rev == CHIP_REV_YU_EC_A1) { | 2490 | if (hw->chip_id == CHIP_ID_YUKON_EC && hw->chip_rev == CHIP_REV_YU_EC_A1) { |
2491 | printk(KERN_ERR PFX "%s: unsupported revision Yukon-%s (0x%x) rev %d\n", | 2491 | dev_err(&hw->pdev->dev, "unsupported revision Yukon-%s (0x%x) rev %d\n", |
2492 | pci_name(hw->pdev), yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], | 2492 | yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], |
2493 | hw->chip_id, hw->chip_rev); | 2493 | hw->chip_id, hw->chip_rev); |
2494 | return -EOPNOTSUPP; | 2494 | return -EOPNOTSUPP; |
2495 | } | 2495 | } |
2496 | 2496 | ||
@@ -3298,7 +3298,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, | |||
3298 | struct net_device *dev = alloc_etherdev(sizeof(*sky2)); | 3298 | struct net_device *dev = alloc_etherdev(sizeof(*sky2)); |
3299 | 3299 | ||
3300 | if (!dev) { | 3300 | if (!dev) { |
3301 | printk(KERN_ERR "sky2 etherdev alloc failed"); | 3301 | dev_err(&hw->pdev->dev, "etherdev alloc failed"); |
3302 | return NULL; | 3302 | return NULL; |
3303 | } | 3303 | } |
3304 | 3304 | ||
@@ -3415,8 +3415,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw) | |||
3415 | 3415 | ||
3416 | err = request_irq(pdev->irq, sky2_test_intr, 0, DRV_NAME, hw); | 3416 | err = request_irq(pdev->irq, sky2_test_intr, 0, DRV_NAME, hw); |
3417 | if (err) { | 3417 | if (err) { |
3418 | printk(KERN_ERR PFX "%s: cannot assign irq %d\n", | 3418 | dev_err(&pdev->dev, "cannot assign irq %d\n", pdev->irq); |
3419 | pci_name(pdev), pdev->irq); | ||
3420 | return err; | 3419 | return err; |
3421 | } | 3420 | } |
3422 | 3421 | ||
@@ -3427,9 +3426,8 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw) | |||
3427 | 3426 | ||
3428 | if (!hw->msi) { | 3427 | if (!hw->msi) { |
3429 | /* MSI test failed, go back to INTx mode */ | 3428 | /* MSI test failed, go back to INTx mode */ |
3430 | printk(KERN_INFO PFX "%s: No interrupt generated using MSI, " | 3429 | dev_info(&pdev->dev, "No interrupt generated using MSI, " |
3431 | "switching to INTx mode.\n", | 3430 | "switching to INTx mode.\n"); |
3432 | pci_name(pdev)); | ||
3433 | 3431 | ||
3434 | err = -EOPNOTSUPP; | 3432 | err = -EOPNOTSUPP; |
3435 | sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ); | 3433 | sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ); |
@@ -3464,15 +3462,13 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3464 | 3462 | ||
3465 | err = pci_enable_device(pdev); | 3463 | err = pci_enable_device(pdev); |
3466 | if (err) { | 3464 | if (err) { |
3467 | printk(KERN_ERR PFX "%s cannot enable PCI device\n", | 3465 | dev_err(&pdev->dev, "cannot enable PCI device\n"); |
3468 | pci_name(pdev)); | ||
3469 | goto err_out; | 3466 | goto err_out; |
3470 | } | 3467 | } |
3471 | 3468 | ||
3472 | err = pci_request_regions(pdev, DRV_NAME); | 3469 | err = pci_request_regions(pdev, DRV_NAME); |
3473 | if (err) { | 3470 | if (err) { |
3474 | printk(KERN_ERR PFX "%s cannot obtain PCI resources\n", | 3471 | dev_err(&pdev->dev, "cannot obtain PCI resources\n"); |
3475 | pci_name(pdev)); | ||
3476 | goto err_out; | 3472 | goto err_out; |
3477 | } | 3473 | } |
3478 | 3474 | ||
@@ -3483,16 +3479,14 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3483 | using_dac = 1; | 3479 | using_dac = 1; |
3484 | err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); | 3480 | err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); |
3485 | if (err < 0) { | 3481 | if (err < 0) { |
3486 | printk(KERN_ERR PFX "%s unable to obtain 64 bit DMA " | 3482 | dev_err(&pdev->dev, "unable to obtain 64 bit DMA " |
3487 | "for consistent allocations\n", pci_name(pdev)); | 3483 | "for consistent allocations\n"); |
3488 | goto err_out_free_regions; | 3484 | goto err_out_free_regions; |
3489 | } | 3485 | } |
3490 | |||
3491 | } else { | 3486 | } else { |
3492 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 3487 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
3493 | if (err) { | 3488 | if (err) { |
3494 | printk(KERN_ERR PFX "%s no usable DMA configuration\n", | 3489 | dev_err(&pdev->dev, "no usable DMA configuration\n"); |
3495 | pci_name(pdev)); | ||
3496 | goto err_out_free_regions; | 3490 | goto err_out_free_regions; |
3497 | } | 3491 | } |
3498 | } | 3492 | } |
@@ -3502,8 +3496,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3502 | err = -ENOMEM; | 3496 | err = -ENOMEM; |
3503 | hw = kzalloc(sizeof(*hw), GFP_KERNEL); | 3497 | hw = kzalloc(sizeof(*hw), GFP_KERNEL); |
3504 | if (!hw) { | 3498 | if (!hw) { |
3505 | printk(KERN_ERR PFX "%s: cannot allocate hardware struct\n", | 3499 | dev_err(&pdev->dev, "cannot allocate hardware struct\n"); |
3506 | pci_name(pdev)); | ||
3507 | goto err_out_free_regions; | 3500 | goto err_out_free_regions; |
3508 | } | 3501 | } |
3509 | 3502 | ||
@@ -3511,8 +3504,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3511 | 3504 | ||
3512 | hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); | 3505 | hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); |
3513 | if (!hw->regs) { | 3506 | if (!hw->regs) { |
3514 | printk(KERN_ERR PFX "%s: cannot map device registers\n", | 3507 | dev_err(&pdev->dev, "cannot map device registers\n"); |
3515 | pci_name(pdev)); | ||
3516 | goto err_out_free_hw; | 3508 | goto err_out_free_hw; |
3517 | } | 3509 | } |
3518 | 3510 | ||
@@ -3538,7 +3530,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3538 | if (err) | 3530 | if (err) |
3539 | goto err_out_iounmap; | 3531 | goto err_out_iounmap; |
3540 | 3532 | ||
3541 | printk(KERN_INFO PFX "v%s addr 0x%llx irq %d Yukon-%s (0x%x) rev %d\n", | 3533 | dev_info(&pdev->dev, "v%s addr 0x%llx irq %d Yukon-%s (0x%x) rev %d\n", |
3542 | DRV_VERSION, (unsigned long long)pci_resource_start(pdev, 0), | 3534 | DRV_VERSION, (unsigned long long)pci_resource_start(pdev, 0), |
3543 | pdev->irq, yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], | 3535 | pdev->irq, yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], |
3544 | hw->chip_id, hw->chip_rev); | 3536 | hw->chip_id, hw->chip_rev); |
@@ -3561,16 +3553,14 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3561 | 3553 | ||
3562 | err = register_netdev(dev); | 3554 | err = register_netdev(dev); |
3563 | if (err) { | 3555 | if (err) { |
3564 | printk(KERN_ERR PFX "%s: cannot register net device\n", | 3556 | dev_err(&pdev->dev, "cannot register net device\n"); |
3565 | pci_name(pdev)); | ||
3566 | goto err_out_free_netdev; | 3557 | goto err_out_free_netdev; |
3567 | } | 3558 | } |
3568 | 3559 | ||
3569 | err = request_irq(pdev->irq, sky2_intr, hw->msi ? 0 : IRQF_SHARED, | 3560 | err = request_irq(pdev->irq, sky2_intr, hw->msi ? 0 : IRQF_SHARED, |
3570 | dev->name, hw); | 3561 | dev->name, hw); |
3571 | if (err) { | 3562 | if (err) { |
3572 | printk(KERN_ERR PFX "%s: cannot assign irq %d\n", | 3563 | dev_err(&pdev->dev, "cannot assign irq %d\n", pdev->irq); |
3573 | pci_name(pdev), pdev->irq); | ||
3574 | goto err_out_unregister; | 3564 | goto err_out_unregister; |
3575 | } | 3565 | } |
3576 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); | 3566 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); |
@@ -3581,18 +3571,15 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3581 | struct net_device *dev1; | 3571 | struct net_device *dev1; |
3582 | 3572 | ||
3583 | dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default); | 3573 | dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default); |
3584 | if (!dev1) { | 3574 | if (!dev1) |
3585 | printk(KERN_WARNING PFX | 3575 | dev_warn(&pdev->dev, "allocation for second device failed\n"); |
3586 | "allocation of second port failed\n"); | 3576 | else if ((err = register_netdev(dev1))) { |
3587 | } | 3577 | dev_warn(&pdev->dev, |
3588 | else if (!(err = register_netdev(dev1))) | 3578 | "register of second port failed (%d)\n", err); |
3589 | sky2_show_addr(dev1); | ||
3590 | else { | ||
3591 | printk(KERN_WARNING PFX | ||
3592 | "register of second port failed (%d)\n", err); | ||
3593 | hw->dev[1] = NULL; | 3579 | hw->dev[1] = NULL; |
3594 | free_netdev(dev1); | 3580 | free_netdev(dev1); |
3595 | } | 3581 | } else |
3582 | sky2_show_addr(dev1); | ||
3596 | } | 3583 | } |
3597 | 3584 | ||
3598 | setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw); | 3585 | setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw); |
@@ -3730,7 +3717,7 @@ static int sky2_resume(struct pci_dev *pdev) | |||
3730 | sky2_idle_start(hw); | 3717 | sky2_idle_start(hw); |
3731 | return 0; | 3718 | return 0; |
3732 | out: | 3719 | out: |
3733 | printk(KERN_ERR PFX "%s: resume failed (%d)\n", pci_name(pdev), err); | 3720 | dev_err(&pdev->dev, "resume failed (%d)\n", err); |
3734 | pci_disable_device(pdev); | 3721 | pci_disable_device(pdev); |
3735 | return err; | 3722 | return err; |
3736 | } | 3723 | } |