static int orinoco_tmd_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { int err; struct orinoco_private *priv; struct orinoco_pci_card *card; void __iomem *hermes_io, *bridge_io; err = pci_enable_device(pdev); if (err) { ; return err; } err = pci_request_regions(pdev, DRIVER_NAME); if (err) { ; goto fail_resources; } bridge_io = pci_iomap(pdev, 1, 0); if (!bridge_io) { ; err = -EIO; goto fail_map_bridge; } hermes_io = pci_iomap(pdev, 2, 0); if (!hermes_io) { ; err = -EIO; goto fail_map_hermes; } /* Allocate network device */ priv = alloc_orinocodev(sizeof(*card), &pdev->dev, orinoco_tmd_cor_reset, NULL); if (!priv) { ; err = -ENOMEM; goto fail_alloc; } card = priv->card; card->bridge_io = bridge_io; hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, DRIVER_NAME, priv); if (err) { ; err = -EBUSY; goto fail_irq; } err = orinoco_tmd_cor_reset(priv); if (err) { ; goto fail; } err = orinoco_init(priv); if (err) { ; goto fail; } err = orinoco_if_add(priv, 0, 0, NULL); if (err) { ; goto fail; } pci_set_drvdata(pdev, priv); return 0; fail: free_irq(pdev->irq, priv); fail_irq: pci_set_drvdata(pdev, NULL); free_orinocodev(priv); fail_alloc: pci_iounmap(pdev, hermes_io); fail_map_hermes: pci_iounmap(pdev, bridge_io); fail_map_bridge: pci_release_regions(pdev); fail_resources: pci_disable_device(pdev); return err; }
static int orinoco_tmd_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0; struct orinoco_private *priv = NULL; struct orinoco_tmd_card *card; struct net_device *dev = NULL; void __iomem *mem; err = pci_enable_device(pdev); if (err) { printk(KERN_ERR PFX "Cannot enable PCI device\n"); return err; } err = pci_request_regions(pdev, DRIVER_NAME); if (err != 0) { printk(KERN_ERR PFX "Cannot obtain PCI resources\n"); goto fail_resources; } mem = pci_iomap(pdev, 2, 0); if (! mem) { err = -ENOMEM; goto fail_iomap; } /* Allocate network device */ dev = alloc_orinocodev(sizeof(*card), orinoco_tmd_cor_reset); if (! dev) { printk(KERN_ERR PFX "Cannot allocate network device\n"); err = -ENOMEM; goto fail_alloc; } priv = netdev_priv(dev); card = priv->card; card->tmd_io = pci_resource_start(pdev, 1); dev->base_addr = pci_resource_start(pdev, 2); SET_MODULE_OWNER(dev); SET_NETDEV_DEV(dev, &pdev->dev); hermes_struct_init(&priv->hw, mem, HERMES_16BIT_REGSPACING); printk(KERN_DEBUG PFX "Detected Orinoco/Prism2 TMD device " "at %s irq:%d, io addr:0x%lx\n", pci_name(pdev), pdev->irq, dev->base_addr); err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, dev->name, dev); if (err) { printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); err = -EBUSY; goto fail_irq; } dev->irq = pdev->irq; err = orinoco_tmd_cor_reset(priv); if (err) { printk(KERN_ERR PFX "Initial reset failed\n"); goto fail; } err = register_netdev(dev); if (err) { printk(KERN_ERR PFX "Cannot register network device\n"); goto fail; } pci_set_drvdata(pdev, dev); return 0; fail: free_irq(pdev->irq, dev); fail_irq: pci_set_drvdata(pdev, NULL); free_orinocodev(dev); fail_alloc: pci_iounmap(pdev, mem); fail_iomap: pci_release_regions(pdev); fail_resources: pci_disable_device(pdev); return err; }