int nfc_mei_phy_enable(void *phy_id) { int r; struct nfc_mei_phy *phy = phy_id; pr_info("%s\n", __func__); if (phy->powered == 1) return 0; r = mei_cl_enable_device(phy->device); if (r < 0) { pr_err("Could not enable device\n"); return r; } r = mei_cl_register_event_cb(phy->device, nfc_mei_event_cb, phy); if (r) { pr_err("Event cb registration failed\n"); mei_cl_disable_device(phy->device); phy->powered = 0; return r; } phy->powered = 1; return 0; }
static int pn544_mei_probe(struct mei_cl_device *device, const struct mei_cl_device_id *id) { struct nfc_mei_phy *phy; int r; pr_info("Probing NFC pn544\n"); phy = nfc_mei_phy_alloc(device); if (!phy) { pr_err("Cannot allocate memory for pn544 mei phy.\n"); return -ENOMEM; } r = mei_cl_register_event_cb(device, nfc_mei_event_cb, phy); if (r) { pr_err(PN544_DRIVER_NAME ": event cb registration failed\n"); goto err_out; } r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME, MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD, &phy->hdev); if (r < 0) goto err_out; return 0; err_out: nfc_mei_phy_free(phy); return r; }
static int nfc_mei_phy_enable(void *phy_id) { int r; struct nfc_mei_phy *phy = phy_id; pr_info("%s\n", __func__); if (phy->powered == 1) return 0; r = mei_cl_enable_device(phy->device); if (r < 0) { pr_err("Could not enable device %d\n", r); return r; } r = mei_nfc_if_version(phy); if (r < 0) { pr_err("Could not enable device %d\n", r); goto err; } r = mei_nfc_connect(phy); if (r < 0) { pr_err("Could not connect to device %d\n", r); goto err; } r = mei_cl_register_event_cb(phy->device, nfc_mei_event_cb, phy); if (r) { pr_err("Event cb registration failed %d\n", r); goto err; } phy->powered = 1; return 0; err: phy->powered = 0; mei_cl_disable_device(phy->device); return r; }
static int microread_mei_probe(struct mei_cl_device *device, const struct mei_cl_device_id *id) { struct microread_mei_phy *phy; int r; pr_info("Probing NFC microread\n"); phy = kzalloc(sizeof(struct microread_mei_phy), GFP_KERNEL); if (!phy) { pr_err("Cannot allocate memory for microread mei phy.\n"); return -ENOMEM; } phy->device = device; mei_cl_set_drvdata(device, phy); r = mei_cl_register_event_cb(device, microread_event_cb, phy); if (r) { pr_err(MICROREAD_DRIVER_NAME ": event cb registration failed\n"); goto err_out; } r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME, MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD, &phy->hdev); if (r < 0) goto err_out; return 0; err_out: kfree(phy); return r; }