Skip to content

Commit 1788597

Browse files
committed
pci
1 parent 488065b commit 1788597

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

components/drivers/include/drivers/pci.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,7 @@ const struct rt_pci_device_id *rt_pci_match_ids(struct rt_pci_device *pdev,
596596

597597
rt_err_t rt_pci_driver_register(struct rt_pci_driver *pdrv);
598598
rt_err_t rt_pci_device_register(struct rt_pci_device *pdev);
599-
struct rt_pci_bus_resource *rt_pci_find_bar(struct rt_pci_device* pdev,rt_ubase_t flags);
600-
599+
struct rt_pci_bus_resource *rt_pci_find_bar(struct rt_pci_device* pdev,rt_ubase_t flags,int index);
601600
#define RT_PCI_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, pci, BUILIN)
602601

603602
extern struct rt_spinlock rt_pci_lock;

components/drivers/pci/pci.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,12 +712,16 @@ rt_err_t rt_pci_device_alloc_resource(struct rt_pci_host_bridge *host_bridge,
712712
return err;
713713
}
714714

715-
struct rt_pci_bus_resource *rt_pci_find_bar(struct rt_pci_device* pdev,rt_ubase_t flags)
715+
struct rt_pci_bus_resource *rt_pci_find_bar(struct rt_pci_device* pdev,rt_ubase_t flags,int index)
716716
{
717717
for (int i = 0; i < RT_PCI_BAR_NR_MAX; i++)
718718
{
719719
if (pdev->resource[i].flags == flags)
720-
return &pdev->resource[i];
720+
{
721+
index--;
722+
if (index == 0)
723+
return &pdev->resource[i];
724+
}
721725
}
722726
return RT_NULL;
723727
}

0 commit comments

Comments
 (0)