| 71 | } |
| 72 | |
| 73 | struct 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 | |
| 110 | struct rt_pci_device *rt_pci_scan_single_device(struct rt_pci_bus *bus, rt_uint32_t devfn) |
| 111 | { |
no test coverage detected