drivers/nfc/st21nfca/core.c
Source file repositories/reference/linux-study-clean/drivers/nfc/st21nfca/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/st21nfca/core.c- Extension
.c- Size
- 27259 bytes
- Lines
- 1038
- Domain
- Driver Families
- Bucket
- drivers/nfc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/nfc.hnet/nfc/hci.hst21nfca.h
Detected Declarations
struct st21nfca_pipe_infofunction st21nfca_hci_load_sessionfunction st21nfca_hci_openfunction st21nfca_hci_closefunction st21nfca_hci_readyfunction st21nfca_hci_xmitfunction st21nfca_hci_start_pollfunction st21nfca_hci_stop_pollfunction st21nfca_get_iso14443_3_atqafunction st21nfca_get_iso14443_3_sakfunction st21nfca_get_iso14443_3_uidfunction st21nfca_get_iso15693_inventoryfunction st21nfca_hci_dep_link_upfunction st21nfca_hci_dep_link_downfunction st21nfca_hci_target_from_gatefunction st21nfca_hci_complete_target_discoveredfunction st21nfca_hci_data_exchange_cbfunction st21nfca_hci_im_transceivefunction st21nfca_hci_tm_sendfunction st21nfca_hci_check_presencefunction st21nfca_hci_cmd_receivedfunction st21nfca_admin_event_receivedfunction st21nfca_hci_event_receivedfunction st21nfca_hci_probefunction st21nfca_hci_removeexport st21nfca_hci_probeexport st21nfca_hci_remove
Annotated Snippet
struct st21nfca_pipe_info {
u8 pipe_state;
u8 src_host_id;
u8 src_gate_id;
u8 dst_host_id;
u8 dst_gate_id;
} __packed;
/* Largest headroom needed for outgoing custom commands */
#define ST21NFCA_CMDS_HEADROOM 7
static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
{
int i, j, r;
struct sk_buff *skb_pipe_list, *skb_pipe_info;
struct st21nfca_pipe_info *info;
u8 pipe_list[] = { ST21NFCA_DM_GETINFO_PIPE_LIST,
NFC_HCI_TERMINAL_HOST_ID
};
u8 pipe_info[] = { ST21NFCA_DM_GETINFO_PIPE_INFO,
NFC_HCI_TERMINAL_HOST_ID, 0
};
/* On ST21NFCA device pipes number are dynamics
* A maximum of 16 pipes can be created at the same time
* If pipes are already created, hci_dev_up will fail.
* Doing a clear all pipe is a bad idea because:
* - It does useless EEPROM cycling
* - It might cause issue for secure elements support
* (such as removing connectivity or APDU reader pipe)
* A better approach on ST21NFCA is to:
* - get a pipe list for each host.
* (eg: NFC_HCI_HOST_CONTROLLER_ID for now).
* (TODO Later on UICC HOST and eSE HOST)
* - get pipe information
* - match retrieved pipe list in st21nfca_gates
* ST21NFCA_DEVICE_MGNT_GATE is a proprietary gate
* with ST21NFCA_DEVICE_MGNT_PIPE.
* Pipe can be closed and need to be open.
*/
r = nfc_hci_connect_gate(hdev, NFC_HCI_HOST_CONTROLLER_ID,
ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_DEVICE_MGNT_PIPE);
if (r < 0)
return r;
/* Get pipe list */
r = nfc_hci_send_cmd(hdev, ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_DM_GETINFO, pipe_list, sizeof(pipe_list),
&skb_pipe_list);
if (r < 0)
return r;
/* Complete the existing gate_pipe table */
for (i = 0; i < skb_pipe_list->len; i++) {
pipe_info[2] = skb_pipe_list->data[i];
r = nfc_hci_send_cmd(hdev, ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_DM_GETINFO, pipe_info,
sizeof(pipe_info), &skb_pipe_info);
if (r)
continue;
/*
* Match pipe ID and gate ID
* Output format from ST21NFC_DM_GETINFO is:
* - pipe state (1byte)
* - source hid (1byte)
* - source gid (1byte)
* - destination hid (1byte)
* - destination gid (1byte)
*/
info = (struct st21nfca_pipe_info *) skb_pipe_info->data;
if (info->dst_gate_id == ST21NFCA_APDU_READER_GATE &&
info->src_host_id == NFC_HCI_UICC_HOST_ID) {
pr_err("Unexpected apdu_reader pipe on host %x\n",
info->src_host_id);
kfree_skb(skb_pipe_info);
continue;
}
for (j = 3; (j < ARRAY_SIZE(st21nfca_gates)) &&
(st21nfca_gates[j].gate != info->dst_gate_id) ; j++)
;
if (j < ARRAY_SIZE(st21nfca_gates) &&
st21nfca_gates[j].gate == info->dst_gate_id &&
ST21NFCA_DM_IS_PIPE_OPEN(info->pipe_state)) {
hdev->init_data.gates[j].pipe = pipe_info[2];
Annotation
- Immediate include surface: `linux/module.h`, `linux/nfc.h`, `net/nfc/hci.h`, `st21nfca.h`.
- Detected declarations: `struct st21nfca_pipe_info`, `function st21nfca_hci_load_session`, `function st21nfca_hci_open`, `function st21nfca_hci_close`, `function st21nfca_hci_ready`, `function st21nfca_hci_xmit`, `function st21nfca_hci_start_poll`, `function st21nfca_hci_stop_poll`, `function st21nfca_get_iso14443_3_atqa`, `function st21nfca_get_iso14443_3_sak`.
- Atlas domain: Driver Families / drivers/nfc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.