in st21nfca/core.c [937:1021]
int st21nfca_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
char *llc_name, int phy_headroom, int phy_tailroom,
int phy_payload, struct nfc_hci_dev **hdev,
struct st21nfca_se_status *se_status)
{
struct st21nfca_hci_info *info;
int r = 0;
int dev_num;
u32 protocols;
struct nfc_hci_init_data init_data;
unsigned long quirks = 0;
info = kzalloc(sizeof(struct st21nfca_hci_info), GFP_KERNEL);
if (!info)
return -ENOMEM;
info->phy_ops = phy_ops;
info->phy_id = phy_id;
info->state = ST21NFCA_ST_COLD;
mutex_init(&info->info_lock);
init_data.gate_count = ARRAY_SIZE(st21nfca_gates);
memcpy(init_data.gates, st21nfca_gates, sizeof(st21nfca_gates));
/*
* Session id must include the driver name + i2c bus addr
* persistent info to discriminate 2 identical chips
*/
dev_num = find_first_zero_bit(dev_mask, ST21NFCA_NUM_DEVICES);
if (dev_num >= ST21NFCA_NUM_DEVICES) {
r = -ENODEV;
goto err_alloc_hdev;
}
set_bit(dev_num, dev_mask);
scnprintf(init_data.session_id, sizeof(init_data.session_id), "%s%2x",
"ST21AH", dev_num);
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;
set_bit(NFC_HCI_QUIRK_SHORT_CLEAR, &quirks);
info->hdev =
nfc_hci_allocate_device(&st21nfca_hci_ops, &init_data, quirks,
protocols, llc_name,
phy_headroom + ST21NFCA_CMDS_HEADROOM,
phy_tailroom, phy_payload);
if (!info->hdev) {
pr_err("Cannot allocate nfc hdev.\n");
r = -ENOMEM;
goto err_alloc_hdev;
}
info->se_status = se_status;
nfc_hci_set_clientdata(info->hdev, info);
r = nfc_hci_register_device(info->hdev);
if (r)
goto err_regdev;
*hdev = info->hdev;
st21nfca_dep_init(info->hdev);
st21nfca_se_init(info->hdev);
st21nfca_vendor_cmds_init(info->hdev);
return 0;
err_regdev:
nfc_hci_free_device(info->hdev);
err_alloc_hdev:
kfree(info);
return r;
}