drivers/pci/remove.c
Source file repositories/reference/linux-study-clean/drivers/pci/remove.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/remove.c- Extension
.c- Size
- 4414 bytes
- Lines
- 190
- 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/pci.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hpci.h
Detected Declarations
function pci_free_resourcesfunction pci_dev_for_each_resourcefunction pci_stop_devfunction pci_destroy_devfunction pci_remove_busfunction pci_stop_bus_devicefunction pci_remove_bus_devicefunction pci_stop_and_remove_bus_devicefunction pci_stop_and_remove_bus_device_lockedfunction pci_stop_root_busfunction pci_remove_root_busexport pci_remove_busexport pci_stop_and_remove_bus_deviceexport pci_stop_and_remove_bus_device_lockedexport pci_stop_root_busexport pci_remove_root_bus
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include "pci.h"
static void pci_free_resources(struct pci_dev *dev)
{
struct resource *res;
pci_dev_for_each_resource(dev, res) {
if (res->parent)
release_resource(res);
}
}
static void pci_stop_dev(struct pci_dev *dev)
{
pci_pme_active(dev, false);
if (!pci_dev_test_and_clear_added(dev))
return;
device_release_driver(&dev->dev);
pci_proc_detach_device(dev);
pci_remove_sysfs_dev_files(dev);
of_pci_remove_node(dev);
}
static void pci_destroy_dev(struct pci_dev *dev)
{
if (pci_dev_test_and_set_removed(dev))
return;
pci_doe_sysfs_teardown(dev);
pci_npem_remove(dev);
/*
* While device is in D0 drop the device from TSM link operations
* including unbind and disconnect (IDE + SPDM teardown).
*/
pci_tsm_destroy(dev);
device_del(&dev->dev);
down_write(&pci_bus_sem);
list_del(&dev->bus_list);
up_write(&pci_bus_sem);
pci_doe_destroy(dev);
pci_ide_destroy(dev);
pcie_aspm_exit_link_state(dev);
pci_bridge_d3_update(dev);
pci_free_resources(dev);
put_device(&dev->dev);
}
void pci_remove_bus(struct pci_bus *bus)
{
pci_proc_detach_bus(bus);
down_write(&pci_bus_sem);
list_del(&bus->node);
pci_bus_release_busn_res(bus);
up_write(&pci_bus_sem);
pci_remove_legacy_files(bus);
if (bus->ops->remove_bus)
bus->ops->remove_bus(bus);
pcibios_remove_bus(bus);
device_unregister(&bus->dev);
}
EXPORT_SYMBOL(pci_remove_bus);
static void pci_stop_bus_device(struct pci_dev *dev)
{
struct pci_bus *bus = dev->subordinate;
struct pci_dev *child, *tmp;
/*
* Stopping an SR-IOV PF device removes all the associated VFs,
* which will update the bus->devices list and confuse the
* iterator. Therefore, iterate in reverse so we remove the VFs
* first, then the PF.
*/
if (bus) {
Annotation
- Immediate include surface: `linux/pci.h`, `linux/module.h`, `linux/of.h`, `linux/of_platform.h`, `linux/platform_device.h`, `pci.h`.
- Detected declarations: `function pci_free_resources`, `function pci_dev_for_each_resource`, `function pci_stop_dev`, `function pci_destroy_dev`, `function pci_remove_bus`, `function pci_stop_bus_device`, `function pci_remove_bus_device`, `function pci_stop_and_remove_bus_device`, `function pci_stop_and_remove_bus_device_locked`, `function pci_stop_root_bus`.
- 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.