static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb) { struct pci_dev *pdev = ntb->pdev; struct perf_ctx *perf; int node; int rc = 0; if (ntb_spad_count(ntb) < MAX_SPAD) { dev_err(&ntb->dev, "Not enough scratch pad registers for %s", DRIVER_NAME); return -EIO; } node = dev_to_node(&pdev->dev); perf = kzalloc_node(sizeof(*perf), GFP_KERNEL, node); if (!perf) { rc = -ENOMEM; goto err_perf; } perf->ntb = ntb; perf->perf_threads = 1; atomic_set(&perf->tsync, 0); mutex_init(&perf->run_mutex); spin_lock_init(&perf->db_lock); perf_setup_mw(ntb, perf); init_waitqueue_head(&perf->link_wq); INIT_DELAYED_WORK(&perf->link_work, perf_link_work); rc = ntb_set_ctx(ntb, perf, &perf_ops); if (rc) goto err_ctx; perf->link_is_up = false; ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO); ntb_link_event(ntb); rc = perf_debugfs_setup(perf); if (rc) goto err_ctx; perf_clear_thread_status(perf); return 0; err_ctx: cancel_delayed_work_sync(&perf->link_work); kfree(perf); err_perf: return rc; }
static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb) { struct pci_dev *pdev = ntb->pdev; struct perf_ctx *perf; int node; int rc = 0; node = dev_to_node(&pdev->dev); perf = kzalloc_node(sizeof(*perf), GFP_KERNEL, node); if (!perf) { rc = -ENOMEM; goto err_perf; } perf->ntb = ntb; perf->perf_threads = 1; atomic_set(&perf->tsync, 0); perf->run = false; spin_lock_init(&perf->db_lock); perf_setup_mw(ntb, perf); INIT_DELAYED_WORK(&perf->link_work, perf_link_work); INIT_WORK(&perf->link_cleanup, perf_link_cleanup); rc = ntb_set_ctx(ntb, perf, &perf_ops); if (rc) goto err_ctx; perf->link_is_up = false; ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO); ntb_link_event(ntb); rc = perf_debugfs_setup(perf); if (rc) goto err_ctx; return 0; err_ctx: cancel_delayed_work_sync(&perf->link_work); cancel_work_sync(&perf->link_cleanup); kfree(perf); err_perf: return rc; }