drivers/nfc/st-nci/core.c
Source file repositories/reference/linux-study-clean/drivers/nfc/st-nci/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/st-nci/core.c- Extension
.c- Size
- 3858 bytes
- Lines
- 176
- 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/nfc.hnet/nfc/nci.hnet/nfc/nci_core.hst-nci.h
Detected Declarations
function Copyrightfunction st_nci_openfunction st_nci_closefunction st_nci_sendfunction st_nci_get_rfprotocolfunction st_nci_prop_rsp_packetfunction st_nci_probefunction st_nci_removeexport st_nci_probeexport st_nci_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* NCI based Driver for STMicroelectronics NFC Chip
*
* Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
*/
#include <linux/module.h>
#include <linux/nfc.h>
#include <net/nfc/nci.h>
#include <net/nfc/nci_core.h>
#include "st-nci.h"
#define DRIVER_DESC "NCI NFC driver for ST_NCI"
#define ST_NCI1_X_PROPRIETARY_ISO15693 0x83
static int st_nci_init(struct nci_dev *ndev)
{
struct nci_mode_set_cmd cmd;
cmd.cmd_type = ST_NCI_SET_NFC_MODE;
cmd.mode = 1;
return nci_prop_cmd(ndev, ST_NCI_CORE_PROP,
sizeof(struct nci_mode_set_cmd), (__u8 *)&cmd);
}
static int st_nci_open(struct nci_dev *ndev)
{
struct st_nci_info *info = nci_get_drvdata(ndev);
int r;
if (test_and_set_bit(ST_NCI_RUNNING, &info->flags))
return 0;
r = ndlc_open(info->ndlc);
if (r)
clear_bit(ST_NCI_RUNNING, &info->flags);
return r;
}
static int st_nci_close(struct nci_dev *ndev)
{
struct st_nci_info *info = nci_get_drvdata(ndev);
if (!test_bit(ST_NCI_RUNNING, &info->flags))
return 0;
ndlc_close(info->ndlc);
clear_bit(ST_NCI_RUNNING, &info->flags);
return 0;
}
static int st_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
{
struct st_nci_info *info = nci_get_drvdata(ndev);
skb->dev = (void *)ndev;
if (!test_bit(ST_NCI_RUNNING, &info->flags))
return -EBUSY;
return ndlc_send(info->ndlc, skb);
}
static __u32 st_nci_get_rfprotocol(struct nci_dev *ndev,
__u8 rf_protocol)
{
return rf_protocol == ST_NCI1_X_PROPRIETARY_ISO15693 ?
NFC_PROTO_ISO15693_MASK : 0;
}
static int st_nci_prop_rsp_packet(struct nci_dev *ndev,
struct sk_buff *skb)
{
__u8 status = skb->data[0];
nci_req_complete(ndev, status);
return 0;
}
static const struct nci_driver_ops st_nci_prop_ops[] = {
{
.opcode = nci_opcode_pack(NCI_GID_PROPRIETARY,
ST_NCI_CORE_PROP),
Annotation
- Immediate include surface: `linux/module.h`, `linux/nfc.h`, `net/nfc/nci.h`, `net/nfc/nci_core.h`, `st-nci.h`.
- Detected declarations: `function Copyright`, `function st_nci_open`, `function st_nci_close`, `function st_nci_send`, `function st_nci_get_rfprotocol`, `function st_nci_prop_rsp_packet`, `function st_nci_probe`, `function st_nci_remove`, `export st_nci_probe`, `export st_nci_remove`.
- 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.