static int nfcwilink_probe(struct platform_device *pdev) { static struct nfcwilink *drv; int rc; __u32 protocols; nfc_dev_dbg(&pdev->dev, "probe entry"); drv = kzalloc(sizeof(struct nfcwilink), GFP_KERNEL); if (!drv) { rc = -ENOMEM; goto exit; } drv->pdev = pdev; protocols = NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK | NFC_PROTO_ISO14443_B_MASK | NFC_PROTO_NFC_DEP_MASK; drv->ndev = nci_allocate_device(&nfcwilink_ops, protocols, NFCWILINK_HDR_LEN, 0); if (!drv->ndev) { nfc_dev_err(&pdev->dev, "nci_allocate_device failed"); rc = -ENOMEM; goto free_exit; } nci_set_parent_dev(drv->ndev, &pdev->dev); nci_set_drvdata(drv->ndev, drv); rc = nci_register_device(drv->ndev); if (rc < 0) { nfc_dev_err(&pdev->dev, "nci_register_device failed %d", rc); goto free_dev_exit; } dev_set_drvdata(&pdev->dev, drv); goto exit; free_dev_exit: nci_free_device(drv->ndev); free_exit: kfree(drv); exit: return rc; }
int st_nci_probe(struct llt_ndlc *ndlc, int phy_headroom, int phy_tailroom, struct st_nci_se_status *se_status) { struct st_nci_info *info; int r; u32 protocols; info = devm_kzalloc(ndlc->dev, sizeof(struct st_nci_info), GFP_KERNEL); if (!info) return -ENOMEM; protocols = NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK | NFC_PROTO_ISO14443_B_MASK | NFC_PROTO_ISO15693_MASK | NFC_PROTO_NFC_DEP_MASK; ndlc->ndev = nci_allocate_device(&st_nci_ops, protocols, phy_headroom, phy_tailroom); if (!ndlc->ndev) { pr_err("Cannot allocate nfc ndev\n"); return -ENOMEM; } info->ndlc = ndlc; nci_set_drvdata(ndlc->ndev, info); r = st_nci_vendor_cmds_init(ndlc->ndev); if (r) { pr_err("Cannot register proprietary vendor cmds\n"); goto err_reg_dev; } r = nci_register_device(ndlc->ndev); if (r) { pr_err("Cannot register nfc device to nci core\n"); goto err_reg_dev; } return st_nci_se_init(ndlc->ndev, se_status); err_reg_dev: nci_free_device(ndlc->ndev); return r; }
struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data, struct nfcmrvl_if_ops *ops, struct device *dev) { struct nfcmrvl_private *priv; int rc; u32 protocols; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return ERR_PTR(-ENOMEM); priv->drv_data = drv_data; priv->if_ops = ops; priv->dev = dev; protocols = NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK | NFC_PROTO_ISO14443_B_MASK | NFC_PROTO_NFC_DEP_MASK; priv->ndev = nci_allocate_device(&nfcmrvl_nci_ops, protocols, 0, 0); if (!priv->ndev) { nfc_err(dev, "nci_allocate_device failed"); rc = -ENOMEM; goto error; } nci_set_drvdata(priv->ndev, priv); rc = nci_register_device(priv->ndev); if (rc) { nfc_err(dev, "nci_register_device failed %d", rc); nci_free_device(priv->ndev); goto error; } nfc_info(dev, "registered with nci successfully\n"); return priv; error: kfree(priv); return ERR_PTR(rc); }
int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom, int phy_tailroom) { struct st21nfcb_nci_info *info; int r; u32 protocols; info = devm_kzalloc(ndlc->dev, sizeof(struct st21nfcb_nci_info), GFP_KERNEL); if (!info) return -ENOMEM; protocols = NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK | NFC_PROTO_ISO14443_B_MASK | NFC_PROTO_NFC_DEP_MASK; ndlc->ndev = nci_allocate_device(&st21nfcb_nci_ops, protocols, phy_headroom, phy_tailroom); if (!ndlc->ndev) { pr_err("Cannot allocate nfc ndev\n"); r = -ENOMEM; goto err_alloc_ndev; } info->ndlc = ndlc; nci_set_drvdata(ndlc->ndev, info); r = nci_register_device(ndlc->ndev); if (r) goto err_regdev; return r; err_regdev: nci_free_device(ndlc->ndev); err_alloc_ndev: kfree(info); return r; }