net/nfc/nci/spi.c
Source file repositories/reference/linux-study-clean/net/nfc/nci/spi.c
File Facts
- System
- Linux kernel
- Corpus path
net/nfc/nci/spi.c- Extension
.c- Size
- 7371 bytes
- Lines
- 324
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- 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/export.hlinux/spi/spi.hlinux/crc-ccitt.hnet/nfc/nci_core.h
Detected Declarations
function Copyrightfunction nci_spi_sendfunction send_acknowledgefunction nci_spi_check_crcfunction nci_spi_get_ackexport nci_spi_sendexport nci_spi_allocate_spiexport nci_spi_read
Annotated Snippet
msecs_to_jiffies(1000)) == 0) {
ret = -ETIME;
goto done;
}
}
ret = __nci_spi_send(nspi, skb, 0);
if (ret != 0 || nspi->acknowledge_mode == NCI_SPI_CRC_DISABLED)
goto done;
reinit_completion(&nspi->req_completion);
completion_rc = wait_for_completion_interruptible_timeout(
&nspi->req_completion,
NCI_SPI_SEND_TIMEOUT);
if (completion_rc <= 0 || nspi->req_result == ACKNOWLEDGE_NACK)
ret = -EIO;
done:
kfree_skb(skb);
return ret;
}
EXPORT_SYMBOL_GPL(nci_spi_send);
/* ---- Interface to NCI SPI drivers ---- */
/**
* nci_spi_allocate_spi - allocate a new nci spi
*
* @spi: SPI device
* @acknowledge_mode: Acknowledge mode used by the NFC device
* @delay: delay between transactions in us
* @ndev: nci dev to send incoming nci frames to
*/
struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
u8 acknowledge_mode, unsigned int delay,
struct nci_dev *ndev)
{
struct nci_spi *nspi;
nspi = devm_kzalloc(&spi->dev, sizeof(struct nci_spi), GFP_KERNEL);
if (!nspi)
return NULL;
nspi->acknowledge_mode = acknowledge_mode;
nspi->xfer_udelay = delay;
/* Use controller max SPI speed by default */
nspi->xfer_speed_hz = 0;
nspi->spi = spi;
nspi->ndev = ndev;
init_completion(&nspi->req_completion);
return nspi;
}
EXPORT_SYMBOL_GPL(nci_spi_allocate_spi);
static int send_acknowledge(struct nci_spi *nspi, u8 acknowledge)
{
struct sk_buff *skb;
unsigned char *hdr;
u16 crc;
int ret;
skb = nci_skb_alloc(nspi->ndev, 0, GFP_KERNEL);
if (!skb)
return -ENOMEM;
/* add the NCI SPI header to the start of the buffer */
hdr = skb_push(skb, NCI_SPI_HDR_LEN);
hdr[0] = NCI_SPI_DIRECT_WRITE;
hdr[1] = NCI_SPI_CRC_ENABLED;
hdr[2] = acknowledge << NCI_SPI_ACK_SHIFT;
hdr[3] = 0;
crc = crc_ccitt(CRC_INIT, skb->data, skb->len);
skb_put_u8(skb, crc >> 8);
skb_put_u8(skb, crc & 0xFF);
ret = __nci_spi_send(nspi, skb, 0);
kfree_skb(skb);
return ret;
}
static struct sk_buff *__nci_spi_read(struct nci_spi *nspi)
{
struct sk_buff *skb;
struct spi_message m;
Annotation
- Immediate include surface: `linux/module.h`, `linux/export.h`, `linux/spi/spi.h`, `linux/crc-ccitt.h`, `net/nfc/nci_core.h`.
- Detected declarations: `function Copyright`, `function nci_spi_send`, `function send_acknowledge`, `function nci_spi_check_crc`, `function nci_spi_get_ack`, `export nci_spi_send`, `export nci_spi_allocate_spi`, `export nci_spi_read`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.