drivers/pci/controller/pci-host-common.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pci-host-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pci-host-common.c- Extension
.c- Size
- 2694 bytes
- Lines
- 111
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_pci.hlinux/pci-ecam.hlinux/platform_device.hpci-host-common.h
Detected Declarations
function Copyrightfunction pci_host_common_initfunction pci_host_common_probefunction pci_host_common_removeexport pci_host_common_ecam_createexport pci_host_common_initexport pci_host_common_probeexport pci_host_common_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Common library for PCI host controller drivers
*
* Copyright (C) 2014 ARM Limited
*
* Author: Will Deacon <will.deacon@arm.com>
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_pci.h>
#include <linux/pci-ecam.h>
#include <linux/platform_device.h>
#include "pci-host-common.h"
static void gen_pci_unmap_cfg(void *ptr)
{
pci_ecam_free((struct pci_config_window *)ptr);
}
struct pci_config_window *pci_host_common_ecam_create(struct device *dev,
struct pci_host_bridge *bridge, const struct pci_ecam_ops *ops)
{
int err;
struct resource cfgres;
struct resource_entry *bus;
struct pci_config_window *cfg;
err = of_address_to_resource(dev->of_node, 0, &cfgres);
if (err) {
dev_err(dev, "missing or malformed \"reg\" property\n");
return ERR_PTR(err);
}
bus = resource_list_first_type(&bridge->windows, IORESOURCE_BUS);
if (!bus)
return ERR_PTR(-ENODEV);
cfg = pci_ecam_create(dev, &cfgres, bus->res, ops);
if (IS_ERR(cfg))
return cfg;
err = devm_add_action_or_reset(dev, gen_pci_unmap_cfg, cfg);
if (err)
return ERR_PTR(err);
return cfg;
}
EXPORT_SYMBOL_GPL(pci_host_common_ecam_create);
int pci_host_common_init(struct platform_device *pdev,
struct pci_host_bridge *bridge,
const struct pci_ecam_ops *ops)
{
struct device *dev = &pdev->dev;
struct pci_config_window *cfg;
of_pci_check_probe_only();
platform_set_drvdata(pdev, bridge);
/* Parse and map our Configuration Space windows */
cfg = pci_host_common_ecam_create(dev, bridge, ops);
if (IS_ERR(cfg))
return PTR_ERR(cfg);
bridge->sysdata = cfg;
bridge->ops = (struct pci_ops *)&ops->pci_ops;
bridge->enable_device = ops->enable_device;
bridge->disable_device = ops->disable_device;
bridge->msi_domain = true;
return pci_host_probe(bridge);
}
EXPORT_SYMBOL_GPL(pci_host_common_init);
int pci_host_common_probe(struct platform_device *pdev)
{
const struct pci_ecam_ops *ops;
struct pci_host_bridge *bridge;
ops = of_device_get_match_data(&pdev->dev);
if (!ops)
return -ENODEV;
bridge = devm_pci_alloc_host_bridge(&pdev->dev, 0);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_pci.h`, `linux/pci-ecam.h`, `linux/platform_device.h`, `pci-host-common.h`.
- Detected declarations: `function Copyright`, `function pci_host_common_init`, `function pci_host_common_probe`, `function pci_host_common_remove`, `export pci_host_common_ecam_create`, `export pci_host_common_init`, `export pci_host_common_probe`, `export pci_host_common_remove`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- 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.