drivers/nfc/pn544/pn544.c
Source file repositories/reference/linux-study-clean/drivers/nfc/pn544/pn544.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/pn544/pn544.c- Extension
.c- Size
- 24144 bytes
- Lines
- 985
- 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/delay.hlinux/slab.hlinux/module.hlinux/nfc.hnet/nfc/hci.hpn544.h
Detected Declarations
struct pn544_hci_infoenum pn544_statefunction pn544_hci_openfunction pn544_hci_closefunction pn544_hci_readyfunction pn544_hci_xmitfunction pn544_hci_start_pollfunction pn544_hci_dep_link_upfunction pn544_hci_dep_link_downfunction pn544_hci_target_from_gatefunction pn544_hci_complete_target_discoveredfunction pn544_hci_data_exchange_cbfunction pn544_hci_im_transceivefunction pn544_hci_tm_sendfunction pn544_hci_check_presencefunction pn544_hci_event_receivedfunction pn544_hci_fw_downloadfunction pn544_hci_discover_sefunction pn544_hci_enable_sefunction pn544_hci_disable_sefunction pn544_hci_probefunction pn544_hci_removeexport pn544_hci_probeexport pn544_hci_remove
Annotated Snippet
struct pn544_hci_info {
const struct nfc_phy_ops *phy_ops;
void *phy_id;
struct nfc_hci_dev *hdev;
enum pn544_state state;
struct mutex info_lock;
int async_cb_type;
data_exchange_cb_t async_cb;
void *async_cb_context;
fw_download_t fw_download;
};
static int pn544_hci_open(struct nfc_hci_dev *hdev)
{
struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
int r = 0;
mutex_lock(&info->info_lock);
if (info->state != PN544_ST_COLD) {
r = -EBUSY;
goto out;
}
r = info->phy_ops->enable(info->phy_id);
if (r == 0)
info->state = PN544_ST_READY;
out:
mutex_unlock(&info->info_lock);
return r;
}
static void pn544_hci_close(struct nfc_hci_dev *hdev)
{
struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
mutex_lock(&info->info_lock);
if (info->state == PN544_ST_COLD)
goto out;
info->phy_ops->disable(info->phy_id);
info->state = PN544_ST_COLD;
out:
mutex_unlock(&info->info_lock);
}
static int pn544_hci_ready(struct nfc_hci_dev *hdev)
{
struct sk_buff *skb;
static struct hw_config {
u8 adr[2];
u8 value;
} hw_config[] = {
{{0x9f, 0x9a}, 0x00},
{{0x98, 0x10}, 0xbc},
{{0x9e, 0x71}, 0x00},
{{0x98, 0x09}, 0x00},
{{0x9e, 0xb4}, 0x00},
{{0x9c, 0x01}, 0x08},
{{0x9e, 0xaa}, 0x01},
{{0x9b, 0xd1}, 0x17},
{{0x9b, 0xd2}, 0x58},
{{0x9b, 0xd3}, 0x10},
{{0x9b, 0xd4}, 0x47},
{{0x9b, 0xd5}, 0x0c},
{{0x9b, 0xd6}, 0x37},
{{0x9b, 0xdd}, 0x33},
{{0x9b, 0x84}, 0x00},
{{0x99, 0x81}, 0x79},
{{0x99, 0x31}, 0x79},
{{0x98, 0x00}, 0x3f},
Annotation
- Immediate include surface: `linux/delay.h`, `linux/slab.h`, `linux/module.h`, `linux/nfc.h`, `net/nfc/hci.h`, `pn544.h`.
- Detected declarations: `struct pn544_hci_info`, `enum pn544_state`, `function pn544_hci_open`, `function pn544_hci_close`, `function pn544_hci_ready`, `function pn544_hci_xmit`, `function pn544_hci_start_poll`, `function pn544_hci_dep_link_up`, `function pn544_hci_dep_link_down`, `function pn544_hci_target_from_gate`.
- 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.