drivers/nfc/nfcmrvl/usb.c
Source file repositories/reference/linux-study-clean/drivers/nfc/nfcmrvl/usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/nfcmrvl/usb.c- Extension
.c- Size
- 10806 bytes
- Lines
- 460
- 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.
- 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/module.hlinux/usb.hlinux/nfc.hnet/nfc/nci.hnet/nfc/nci_core.hnfcmrvl.h
Detected Declarations
struct nfcmrvl_usb_drv_datafunction nfcmrvl_inc_txfunction nfcmrvl_bulk_completefunction nfcmrvl_submit_bulk_urbfunction nfcmrvl_tx_completefunction nfcmrvl_usb_nci_openfunction nfcmrvl_usb_stop_trafficfunction nfcmrvl_usb_nci_closefunction nfcmrvl_usb_nci_sendfunction nfcmrvl_wakerfunction nfcmrvl_probefunction nfcmrvl_disconnectfunction nfcmrvl_suspendfunction nfcmrvl_play_deferredfunction nfcmrvl_resume
Annotated Snippet
struct nfcmrvl_usb_drv_data {
struct usb_device *udev;
struct usb_interface *intf;
unsigned long flags;
struct work_struct waker;
struct usb_anchor tx_anchor;
struct usb_anchor bulk_anchor;
struct usb_anchor deferred;
int tx_in_flight;
/* protects tx_in_flight */
spinlock_t txlock;
struct usb_endpoint_descriptor *bulk_tx_ep;
struct usb_endpoint_descriptor *bulk_rx_ep;
int suspend_count;
struct nfcmrvl_private *priv;
};
static int nfcmrvl_inc_tx(struct nfcmrvl_usb_drv_data *drv_data)
{
unsigned long flags;
int rv;
spin_lock_irqsave(&drv_data->txlock, flags);
rv = test_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags);
if (!rv)
drv_data->tx_in_flight++;
spin_unlock_irqrestore(&drv_data->txlock, flags);
return rv;
}
static void nfcmrvl_bulk_complete(struct urb *urb)
{
struct nfcmrvl_usb_drv_data *drv_data = urb->context;
int err;
dev_dbg(&drv_data->udev->dev, "urb %p status %d count %d\n",
urb, urb->status, urb->actual_length);
if (!test_bit(NFCMRVL_NCI_RUNNING, &drv_data->flags))
return;
if (!urb->status) {
struct sk_buff *skb;
skb = nci_skb_alloc(drv_data->priv->ndev, urb->actual_length,
GFP_ATOMIC);
if (!skb) {
nfc_err(&drv_data->udev->dev, "failed to alloc mem\n");
} else {
skb_put_data(skb, urb->transfer_buffer,
urb->actual_length);
if (nfcmrvl_nci_recv_frame(drv_data->priv, skb) < 0)
nfc_err(&drv_data->udev->dev,
"corrupted Rx packet\n");
}
}
if (!test_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags))
return;
usb_anchor_urb(urb, &drv_data->bulk_anchor);
usb_mark_last_busy(drv_data->udev);
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err) {
/* -EPERM: urb is being killed;
* -ENODEV: device got disconnected
*/
if (err != -EPERM && err != -ENODEV)
nfc_err(&drv_data->udev->dev,
"urb %p failed to resubmit (%d)\n", urb, -err);
usb_unanchor_urb(urb);
}
}
static int
nfcmrvl_submit_bulk_urb(struct nfcmrvl_usb_drv_data *drv_data, gfp_t mem_flags)
{
struct urb *urb;
unsigned char *buf;
unsigned int pipe;
int err, size = NFCMRVL_NCI_MAX_EVENT_SIZE;
if (!drv_data->bulk_rx_ep)
return -ENODEV;
urb = usb_alloc_urb(0, mem_flags);
if (!urb)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/module.h`, `linux/usb.h`, `linux/nfc.h`, `net/nfc/nci.h`, `net/nfc/nci_core.h`, `nfcmrvl.h`.
- Detected declarations: `struct nfcmrvl_usb_drv_data`, `function nfcmrvl_inc_tx`, `function nfcmrvl_bulk_complete`, `function nfcmrvl_submit_bulk_urb`, `function nfcmrvl_tx_complete`, `function nfcmrvl_usb_nci_open`, `function nfcmrvl_usb_stop_traffic`, `function nfcmrvl_usb_nci_close`, `function nfcmrvl_usb_nci_send`, `function nfcmrvl_waker`.
- Atlas domain: Driver Families / drivers/nfc.
- Implementation status: source 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.