MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_pci_alloc_device

Function rt_pci_alloc_device

components/drivers/pci/probe.c:73–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73struct rt_pci_device *rt_pci_alloc_device(struct rt_pci_bus *bus)
74{
75 struct rt_pci_device *pdev = rt_calloc(1, sizeof(*pdev));
76
77 if (!pdev)
78 {
79 return RT_NULL;
80 }
81
82 rt_list_init(&pdev->list);
83 pdev->bus = bus;
84
85 if (bus)
86 {
87 spin_lock(&bus->lock);
88 rt_list_insert_before(&bus->devices_nodes, &pdev->list);
89 spin_unlock(&bus->lock);
90 }
91
92 pdev->subsystem_vendor = PCI_ANY_ID;
93 pdev->subsystem_device = PCI_ANY_ID;
94
95 pdev->irq = -1;
96
97 for (int i = 0; i < RT_ARRAY_SIZE(pdev->resource); ++i)
98 {
99 pdev->resource[i].flags = PCI_BUS_REGION_F_NONE;
100 }
101
102#ifdef RT_PCI_MSI
103 rt_list_init(&pdev->msi_desc_nodes);
104 rt_spin_lock_init(&pdev->msi_lock);
105#endif
106
107 return pdev;
108}
109
110struct rt_pci_device *rt_pci_scan_single_device(struct rt_pci_bus *bus, rt_uint32_t devfn)
111{

Callers 1

Calls 6

rt_callocFunction · 0.85
rt_list_initFunction · 0.85
rt_list_insert_beforeFunction · 0.85
spin_lockFunction · 0.70
spin_unlockFunction · 0.70
rt_spin_lock_initFunction · 0.50

Tested by

no test coverage detected