tools/power/cpupower/utils/helpers/pci.c
Source file repositories/reference/linux-study-clean/tools/power/cpupower/utils/helpers/pci.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/utils/helpers/pci.c- Extension
.c- Size
- 1590 bytes
- Lines
- 64
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
helpers/helpers.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#if defined(__i386__) || defined(__x86_64__)
#include <helpers/helpers.h>
/*
* pci_acc_init
*
* PCI access helper function depending on libpci
*
* **pacc : if a valid pci_dev is returned
* *pacc must be passed to pci_acc_cleanup to free it
*
* domain: domain
* bus: bus
* slot: slot
* func: func
* vendor: vendor
* device: device
* Pass -1 for one of the six above to match any
*
* Returns :
* struct pci_dev which can be used with pci_{read,write}_* functions
* to access the PCI config space of matching pci devices
*/
struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain, int bus,
int slot, int func, int vendor, int dev)
{
struct pci_filter filter_nb_link;
struct pci_dev *device;
*pacc = pci_alloc();
if (*pacc == NULL)
return NULL;
pci_filter_init(*pacc, &filter_nb_link);
filter_nb_link.domain = domain;
filter_nb_link.bus = bus;
filter_nb_link.slot = slot;
filter_nb_link.func = func;
filter_nb_link.vendor = vendor;
filter_nb_link.device = dev;
pci_init(*pacc);
pci_scan_bus(*pacc);
for (device = (*pacc)->devices; device; device = device->next) {
if (pci_filter_match(&filter_nb_link, device))
return device;
}
pci_cleanup(*pacc);
return NULL;
}
/* Typically one wants to get a specific slot(device)/func of the root domain
and bus */
struct pci_dev *pci_slot_func_init(struct pci_access **pacc, int slot,
int func)
{
return pci_acc_init(pacc, 0, 0, slot, func, -1, -1);
}
#endif /* defined(__i386__) || defined(__x86_64__) */
Annotation
- Immediate include surface: `helpers/helpers.h`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.