[haiku-commits] haiku: hrev56118 - src/libs/compat/freebsd_network

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 20 May 2022 03:07:46 +0000 (UTC)

hrev56118 adds 1 changeset to branch 'master'
old head: 458c40fb2787fde1b9363cb43d15941591a7b923
new head: f43b88e836b71ac9c5ec77c42dd7bb0717578a6f
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=f43b88e836b7+%5E458c40fb2787

----------------------------------------------------------------------------

f43b88e836b7: freebsd_network: Use Haiku's PCI capability finding functions.
  
  Instead of reimplementing them in here, for which there is no need.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev56118
Commit:      f43b88e836b71ac9c5ec77c42dd7bb0717578a6f
URL:         https://git.haiku-os.org/haiku/commit/?id=f43b88e836b7
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Fri May 20 03:07:01 2022 UTC

----------------------------------------------------------------------------

1 file changed, 16 insertions(+), 35 deletions(-)
src/libs/compat/freebsd_network/pci.cpp | 51 +++++++++--------------------

----------------------------------------------------------------------------

diff --git a/src/libs/compat/freebsd_network/pci.cpp 
b/src/libs/compat/freebsd_network/pci.cpp
index 8726ab03fd..f1badca066 100644
--- a/src/libs/compat/freebsd_network/pci.cpp
+++ b/src/libs/compat/freebsd_network/pci.cpp
@@ -236,47 +236,28 @@ pci_enable_io(device_t dev, int space)
 int
 pci_find_cap(device_t dev, int capability, int *capreg)
 {
-       return pci_find_extcap(dev, capability, capreg);
+       pci_info* info = get_device_pci_info(dev);
+       uint8 offset;
+       status_t status;
+
+       status = gPci->find_pci_capability(info->bus, info->device, 
info->function,
+               capability, &offset);
+       *capreg = offset;
+       return status;
 }
 
 
 int
-pci_find_extcap(device_t child, int capability, int *_capabilityRegister)
+pci_find_extcap(device_t dev, int capability, int *capreg)
 {
-       uint8 capabilityPointer;
-       uint8 headerType;
-       uint16 status;
-
-       status = pci_read_config(child, PCIR_STATUS, 2);
-       if ((status & PCIM_STATUS_CAPPRESENT) == 0)
-               return ENXIO;
-
-       headerType = pci_read_config(child, PCI_header_type, 1);
-       switch (headerType & PCIM_HDRTYPE) {
-               case 0:
-               case 1:
-                       capabilityPointer = PCIR_CAP_PTR;
-                       break;
-               case 2:
-                       capabilityPointer = PCIR_CAP_PTR_2;
-                       break;
-               default:
-                       return ENXIO;
-       }
-       capabilityPointer = pci_read_config(child, capabilityPointer, 1);
-
-       while (capabilityPointer != 0) {
-               if (pci_read_config(child, capabilityPointer + PCICAP_ID, 1)
-                               == capability) {
-                       if (_capabilityRegister != NULL)
-                               *_capabilityRegister = capabilityPointer;
-                       return 0;
-               }
-               capabilityPointer = pci_read_config(child,
-                       capabilityPointer + PCICAP_NEXTPTR, 1);
-       }
+       pci_info* info = get_device_pci_info(dev);
+       uint16 offset;
+       status_t status;
 
-       return ENOENT;
+       status = gPci->find_pci_extended_capability(info->bus, info->device, 
info->function,
+               capability, &offset);
+       *capreg = offset;
+       return status;
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev56118 - src/libs/compat/freebsd_network - waddlesplash