drivers/net/ethernet/intel/ice/ice_adapter.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_adapter.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ice/ice_adapter.c- Extension
.c- Size
- 4212 bytes
- Lines
- 152
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/cleanup.hlinux/mutex.hlinux/pci.hlinux/slab.hlinux/spinlock.hlinux/xarray.hice_adapter.hice.h
Detected Declarations
function ice_adapter_indexfunction ice_adapter_xa_indexfunction ice_adapter_freefunction ERR_PTRfunction ice_adapter_put
Annotated Snippet
if (adapter) {
refcount_inc(&adapter->refcount);
WARN_ON_ONCE(adapter->index != ice_adapter_index(pdev));
return adapter;
}
err = xa_reserve(&ice_adapters, index, GFP_KERNEL);
if (err)
return ERR_PTR(err);
adapter = ice_adapter_new(pdev);
if (!adapter) {
xa_release(&ice_adapters, index);
return ERR_PTR(-ENOMEM);
}
xa_store(&ice_adapters, index, adapter, GFP_KERNEL);
}
return adapter;
}
/**
* ice_adapter_put - Release a reference to the shared ice_adapter structure.
* @pdev: Pointer to the pci_dev whose driver is releasing the ice_adapter.
*
* Releases the reference to ice_adapter previously obtained with
* ice_adapter_get.
*
* Context: Process, may sleep.
*/
void ice_adapter_put(struct pci_dev *pdev)
{
struct ice_adapter *adapter;
unsigned long index;
index = ice_adapter_xa_index(pdev);
scoped_guard(mutex, &ice_adapters_mutex) {
adapter = xa_load(&ice_adapters, index);
if (WARN_ON(!adapter))
return;
if (!refcount_dec_and_test(&adapter->refcount))
return;
WARN_ON(xa_erase(&ice_adapters, index) != adapter);
}
ice_adapter_free(adapter);
}
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/mutex.h`, `linux/pci.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/xarray.h`, `ice_adapter.h`, `ice.h`.
- Detected declarations: `function ice_adapter_index`, `function ice_adapter_xa_index`, `function ice_adapter_free`, `function ERR_PTR`, `function ice_adapter_put`.
- Atlas domain: Driver Families / drivers/net.
- 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.