drivers/nfc/nfcmrvl/main.c
Source file repositories/reference/linux-study-clean/drivers/nfc/nfcmrvl/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/nfcmrvl/main.c- Extension
.c- Size
- 5914 bytes
- Lines
- 258
- 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.
- 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/gpio/consumer.hlinux/delay.hlinux/of.hlinux/nfc.hnet/nfc/nci.hnet/nfc/nci_core.hnfcmrvl.h
Detected Declarations
function Copyrightfunction nfcmrvl_nci_closefunction nfcmrvl_nci_sendfunction nfcmrvl_nci_setupfunction nfcmrvl_nci_fw_downloadfunction nfcmrvl_nci_unregister_devfunction nfcmrvl_nci_recv_framefunction nfcmrvl_chip_resetfunction nfcmrvl_chip_haltfunction nfcmrvl_parse_dtexport nfcmrvl_nci_register_devexport nfcmrvl_nci_unregister_devexport nfcmrvl_nci_recv_frameexport nfcmrvl_parse_dt
Annotated Snippet
if (IS_ERR(priv->config.reset_gpio)) {
priv->config.reset_gpio = NULL;
nfc_err(dev, "failed to get reset gpio\n");
}
}
if (phy == NFCMRVL_PHY_SPI) {
headroom = NCI_SPI_HDR_LEN;
tailroom = 1;
} else
headroom = tailroom = 0;
if (priv->config.hci_muxed)
headroom += NFCMRVL_HCI_EVENT_HEADER_SIZE;
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;
priv->ndev = nci_allocate_device(&nfcmrvl_nci_ops, protocols,
headroom, tailroom);
if (!priv->ndev) {
nfc_err(dev, "nci_allocate_device failed\n");
rc = -ENOMEM;
goto error_free;
}
rc = nfcmrvl_fw_dnld_init(priv);
if (rc) {
nfc_err(dev, "failed to initialize FW download %d\n", rc);
goto error_free_dev;
}
nci_set_drvdata(priv->ndev, priv);
rc = nci_register_device(priv->ndev);
if (rc) {
nfc_err(dev, "nci_register_device failed %d\n", rc);
goto error_fw_dnld_deinit;
}
/* Ensure that controller is powered off */
nfcmrvl_chip_halt(priv);
nfc_info(dev, "registered with nci successfully\n");
return priv;
error_fw_dnld_deinit:
nfcmrvl_fw_dnld_deinit(priv);
error_free_dev:
nci_free_device(priv->ndev);
error_free:
kfree(priv);
return ERR_PTR(rc);
}
EXPORT_SYMBOL_GPL(nfcmrvl_nci_register_dev);
void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv)
{
struct nci_dev *ndev = priv->ndev;
nci_unregister_device(ndev);
if (priv->ndev->nfc_dev->fw_download_in_progress)
nfcmrvl_fw_dnld_abort(priv);
nfcmrvl_fw_dnld_deinit(priv);
nci_free_device(ndev);
kfree(priv);
}
EXPORT_SYMBOL_GPL(nfcmrvl_nci_unregister_dev);
int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb)
{
if (priv->config.hci_muxed) {
if (skb->data[0] == NFCMRVL_HCI_EVENT_CODE &&
skb->data[1] == NFCMRVL_HCI_NFC_EVENT_CODE) {
/* Data packet, let's extract NCI payload */
skb_pull(skb, NFCMRVL_HCI_EVENT_HEADER_SIZE);
} else {
/* Skip this packet */
kfree_skb(skb);
return 0;
}
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/gpio/consumer.h`, `linux/delay.h`, `linux/of.h`, `linux/nfc.h`, `net/nfc/nci.h`, `net/nfc/nci_core.h`, `nfcmrvl.h`.
- Detected declarations: `function Copyright`, `function nfcmrvl_nci_close`, `function nfcmrvl_nci_send`, `function nfcmrvl_nci_setup`, `function nfcmrvl_nci_fw_download`, `function nfcmrvl_nci_unregister_dev`, `function nfcmrvl_nci_recv_frame`, `function nfcmrvl_chip_reset`, `function nfcmrvl_chip_halt`, `function nfcmrvl_parse_dt`.
- Atlas domain: Driver Families / drivers/nfc.
- Implementation status: integration implementation candidate.
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.