static int __devinit chd_dec_pci_probe(struct pci_dev *pdev, const struct pci_device_id *entry) { struct crystalhd_adp *pinfo; int rc; enum BC_STATUS sts = BC_STS_SUCCESS; BCMLOG(BCMLOG_DBG, "PCI_INFO: Vendor:0x%04x Device:0x%04x " "s_vendor:0x%04x s_device: 0x%04x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, pdev->subsystem_device); /* FIXME: jarod: why atomic? */ pinfo = kzalloc(sizeof(struct crystalhd_adp), GFP_ATOMIC); if (!pinfo) { BCMLOG_ERR("Failed to allocate memory\n"); return -ENOMEM; } pinfo->pdev = pdev; rc = pci_enable_device(pdev); if (rc) { BCMLOG_ERR("Failed to enable PCI device\n"); return rc; } snprintf(pinfo->name, 31, "crystalhd_pci_e:%d:%d:%d", pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); rc = chd_pci_reserve_mem(pinfo); if (rc) { BCMLOG_ERR("Failed to setup memory regions.\n"); return -ENOMEM; } pinfo->present = 1; pinfo->drv_data = entry->driver_data; /* Setup adapter level lock.. */ spin_lock_init(&pinfo->lock); /* setup api stuff.. */ chd_dec_init_chdev(pinfo); rc = chd_dec_enable_int(pinfo); if (rc) { BCMLOG_ERR("_enable_int err:%d\n", rc); pci_disable_device(pdev); return -ENODEV; } /* Set dma mask... */ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); pinfo->dmabits = 64; } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); pinfo->dmabits = 32; } else { BCMLOG_ERR("Unabled to setup DMA %d\n", rc); pci_disable_device(pdev); return -ENODEV; } sts = crystalhd_setup_cmd_context(&pinfo->cmds, pinfo); if (sts != BC_STS_SUCCESS) { BCMLOG_ERR("cmd setup :%d\n", sts); pci_disable_device(pdev); return -ENODEV; } pci_set_master(pdev); pci_set_drvdata(pdev, pinfo); g_adp_info = pinfo; return 0; }
static int __init chd_dec_pci_probe(struct pci_dev *pdev, const struct pci_device_id *entry) { struct device *dev = &pdev->dev; struct crystalhd_adp *pinfo; int rc; BC_STATUS sts = BC_STS_SUCCESS; dev_info(dev, "Starting Device:0x%04x\n", pdev->device); pinfo = kzalloc(sizeof(struct crystalhd_adp), GFP_KERNEL); if (!pinfo) { dev_err(dev, "%s: Failed to allocate memory\n", __func__); rc = -ENOMEM; goto out; } pinfo->pdev = pdev; rc = pci_enable_device(pdev); if (rc) { dev_err(dev, "%s: Failed to enable PCI device\n", __func__); goto free_priv; } snprintf(pinfo->name, sizeof(pinfo->name), "crystalhd_pci_e:%d:%d:%d", pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); rc = chd_pci_reserve_mem(pinfo); if (rc) { dev_err(dev, "%s: Failed to set up memory regions.\n", __func__); goto disable_device; } pinfo->present = 1; pinfo->drv_data = entry->driver_data; /* Setup adapter level lock.. */ spin_lock_init(&pinfo->lock); /* setup api stuff.. */ rc = chd_dec_init_chdev(pinfo); if (rc) goto release_mem; rc = chd_dec_enable_int(pinfo); if (rc) { dev_err(dev, "%s: _enable_int err:%d\n", __func__, rc); goto cleanup_chdev; } /* Set dma mask... */ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); pinfo->dmabits = 64; } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); pinfo->dmabits = 32; } else { dev_err(dev, "%s: Unabled to setup DMA %d\n", __func__, rc); rc = -ENODEV; goto cleanup_int; } sts = crystalhd_setup_cmd_context(&pinfo->cmds, pinfo); if (sts != BC_STS_SUCCESS) { dev_err(dev, "%s: cmd setup :%d\n", __func__, sts); rc = -ENODEV; goto cleanup_int; } pci_set_master(pdev); pci_set_drvdata(pdev, pinfo); g_adp_info = pinfo; out: return rc; cleanup_int: chd_dec_disable_int(pinfo); cleanup_chdev: chd_dec_release_chdev(pinfo); release_mem: chd_pci_release_mem(pinfo); disable_device: pci_disable_device(pdev); free_priv: kfree(pdev); goto out; }