drivers/nfc/pn533/usb.c
Source file repositories/reference/linux-study-clean/drivers/nfc/pn533/usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/pn533/usb.c- Extension
.c- Size
- 15130 bytes
- Lines
- 637
- Domain
- Driver Families
- Bucket
- drivers/nfc
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/device.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/usb.hlinux/nfc.hlinux/netdevice.hnet/nfc/nfc.hpn533.h
Detected Declarations
struct pn533_usb_phystruct pn533_out_argstruct pn533_acr122_ccid_hdrstruct pn533_acr122_apdu_hdrstruct pn533_acr122_tx_framestruct pn533_acr122_rx_framestruct pn533_acr122_poweron_rdr_argfunction pn533_recv_responsefunction pn533_submit_urb_for_responsefunction pn533_recv_ackfunction pn533_submit_urb_for_ackfunction pn533_usb_send_ackfunction pn533_usb_send_framefunction pn533_usb_abort_cmdfunction pn533_acr122_tx_frame_initfunction pn533_acr122_tx_frame_finishfunction pn533_acr122_tx_update_payload_lenfunction pn533_acr122_is_rx_frame_validfunction pn533_acr122_rx_frame_sizefunction pn533_acr122_get_cmd_codefunction pn533_acr122_poweron_rdr_respfunction pn533_acr122_poweron_rdrfunction pn533_out_completefunction pn533_ack_completefunction pn533_usb_probefunction pn533_usb_disconnect
Annotated Snippet
struct pn533_usb_phy {
struct usb_device *udev;
struct usb_interface *interface;
struct urb *out_urb;
struct urb *in_urb;
struct urb *ack_urb;
u8 *ack_buffer;
struct pn533 *priv;
};
static void pn533_recv_response(struct urb *urb)
{
struct pn533_usb_phy *phy = urb->context;
struct sk_buff *skb = NULL;
if (!urb->status) {
skb = alloc_skb(urb->actual_length, GFP_ATOMIC);
if (!skb) {
nfc_err(&phy->udev->dev, "failed to alloc memory\n");
} else {
skb_put_data(skb, urb->transfer_buffer,
urb->actual_length);
}
}
pn533_recv_frame(phy->priv, skb, urb->status);
}
static int pn533_submit_urb_for_response(struct pn533_usb_phy *phy, gfp_t flags)
{
phy->in_urb->complete = pn533_recv_response;
return usb_submit_urb(phy->in_urb, flags);
}
static void pn533_recv_ack(struct urb *urb)
{
struct pn533_usb_phy *phy = urb->context;
struct pn533 *priv = phy->priv;
struct pn533_cmd *cmd = priv->cmd;
struct pn533_std_frame *in_frame;
int rc;
cmd->status = urb->status;
switch (urb->status) {
case 0:
break; /* success */
case -ECONNRESET:
case -ENOENT:
dev_dbg(&phy->udev->dev,
"The urb has been stopped (status %d)\n",
urb->status);
goto sched_wq;
case -ESHUTDOWN:
default:
nfc_err(&phy->udev->dev,
"Urb failure (status %d)\n", urb->status);
goto sched_wq;
}
in_frame = phy->in_urb->transfer_buffer;
if (!pn533_rx_frame_is_ack(in_frame)) {
nfc_err(&phy->udev->dev, "Received an invalid ack\n");
cmd->status = -EIO;
goto sched_wq;
}
rc = pn533_submit_urb_for_response(phy, GFP_ATOMIC);
if (rc) {
nfc_err(&phy->udev->dev,
"usb_submit_urb failed with result %d\n", rc);
cmd->status = rc;
goto sched_wq;
}
return;
sched_wq:
queue_work(priv->wq, &priv->cmd_complete_work);
}
static int pn533_submit_urb_for_ack(struct pn533_usb_phy *phy, gfp_t flags)
{
phy->in_urb->complete = pn533_recv_ack;
Annotation
- Immediate include surface: `linux/device.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/usb.h`, `linux/nfc.h`, `linux/netdevice.h`, `net/nfc/nfc.h`.
- Detected declarations: `struct pn533_usb_phy`, `struct pn533_out_arg`, `struct pn533_acr122_ccid_hdr`, `struct pn533_acr122_apdu_hdr`, `struct pn533_acr122_tx_frame`, `struct pn533_acr122_rx_frame`, `struct pn533_acr122_poweron_rdr_arg`, `function pn533_recv_response`, `function pn533_submit_urb_for_response`, `function pn533_recv_ack`.
- Atlas domain: Driver Families / drivers/nfc.
- Implementation status: source 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.