Add pci_device_get_bridge_buses, bump API version to 0.5.0.
authorIan Romanick <idr@umwelt.(none)>
Tue, 25 Jul 2006 22:36:52 +0000 (15:36 -0700)
committerIan Romanick <idr@umwelt.(none)>
Tue, 25 Jul 2006 22:36:52 +0000 (15:36 -0700)
configure.ac
include/pciaccess.h
src/Makefile.am
src/common_bridge.c

index a968291..998a4dc 100644 (file)
@@ -41,7 +41,7 @@ dnl refers to ${prefix}.  Thus we have to use `eval' twice.
 
 AC_PREREQ([2.57])
 
-AC_INIT(libpciaccess, 0.5.0, [none yet], libpciaccess)
+AC_INIT(libpciaccess, 0.6.0, [none yet], libpciaccess)
 AM_INIT_AUTOMAKE([dist-bzip2])
 AM_MAINTAINER_MODE
 
index c9f46b6..4078f0f 100644 (file)
@@ -57,6 +57,9 @@ const struct pci_bridge_info * pci_device_get_bridge_info(
 const struct pci_pcmcia_bridge_info * pci_device_get_pcmcia_bridge_info(
     struct pci_device * dev );
 
+int pci_device_get_bridge_buses(struct pci_device * dev, int *primary_bus,
+    int *secondary_bus, int *subordinate_bus);
+
 int pci_system_init( void );
 
 void pci_system_cleanup( void );
index ee4d7d2..6593f4c 100644 (file)
@@ -35,7 +35,7 @@ INCLUDES = -I$(top_srcdir)/include
 
 libpciaccess_la_LIBADD = @PCIACCESS_LIBS@
 
-libpciaccess_la_LDFLAGS = -version-number 0:5:0 -no-undefined
+libpciaccess_la_LDFLAGS = -version-number 0:6:0 -no-undefined
 
 libpciaccessincludedir = $(includedir)
 libpciaccessinclude_HEADERS = \
index 19912d3..305228a 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
+#include <errno.h>
 
 #if defined(HAVE_STRING_H)
 # include <string.h>
@@ -211,3 +212,54 @@ pci_device_get_pcmcia_bridge_info( struct pci_device * dev )
 
     return (priv->header_type == 2) ? priv->bridge.pcmcia : NULL;
 }
+
+
+int
+pci_device_get_bridge_buses(struct pci_device * dev, int *primary_bus,
+                           int *secondary_bus, int *subordinate_bus)
+{
+    struct pci_device_private * priv = (struct pci_device_private *) dev;
+
+    /* If the device isn't a bridge, return an error.
+     */
+    
+    if (((dev->device_class >> 16) & 0x0ff) != 0x06) {
+       return ENODEV;
+    }
+
+    if (priv->bridge.pci == NULL) {
+       read_bridge_info(priv);
+    }
+
+    switch ((dev->device_class >> 8) & 0x0ff) {
+    case 0x00:
+       /* What to do for host bridges?  I'm pretty sure this isn't right.
+        */
+       *primary_bus = dev->bus;
+       *secondary_bus = -1;
+       *subordinate_bus = -1;
+       break;
+
+    case 0x01:
+    case 0x02:
+    case 0x03:
+       *primary_bus = dev->bus;
+       *secondary_bus = -1;
+       *subordinate_bus = -1;
+       break;
+
+    case 0x04:
+       *primary_bus = priv->bridge.pci->primary_bus;
+       *secondary_bus = priv->bridge.pci->secondary_bus;
+       *subordinate_bus = priv->bridge.pci->subordinate_bus;
+       break;
+
+    case 0x07:
+       *primary_bus = priv->bridge.pcmcia->primary_bus;
+       *secondary_bus = priv->bridge.pcmcia->card_bus;
+       *subordinate_bus = priv->bridge.pcmcia->subordinate_bus;
+       break;
+    }
+
+    return 0;
+}