]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/init.c
NUMA node scanning is now done in an ABI-compatible way
[pciutils.git] / lib / init.c
index 59cb706d3580aa8ab6ff5938bc3bf51f16e47e14..064c9324a4e3f49cdfbc7cb3ba202f61912a6d68 100644 (file)
@@ -57,6 +57,11 @@ static struct pci_methods *pci_methods[PCI_ACCESS_MAX] = {
 #else
   NULL,
 #endif
+#ifdef PCI_HAVE_PM_DARWIN_DEVICE
+  &pm_darwin,
+#else
+  NULL,
+#endif
 };
 
 void *
@@ -77,7 +82,7 @@ pci_mfree(void *x)
 }
 
 char *
-pci_strdup(struct pci_access *a, char *s)
+pci_strdup(struct pci_access *a, const char *s)
 {
   int len = strlen(s) + 1;
   char *t = pci_malloc(a, len);
@@ -123,6 +128,28 @@ pci_null_debug(char *msg UNUSED, ...)
 {
 }
 
+int
+pci_lookup_method(char *name)
+{
+  int i;
+
+  for (i=0; i<PCI_ACCESS_MAX; i++)
+    if (pci_methods[i] && !strcmp(pci_methods[i]->name, name))
+      return i;
+  return -1;
+}
+
+char *
+pci_get_method_name(int index)
+{
+  if (index < 0 || index >= PCI_ACCESS_MAX)
+    return NULL;
+  else if (!pci_methods[index])
+    return "";
+  else
+    return pci_methods[index]->name;
+}
+
 struct pci_access *
 pci_alloc(void)
 {
@@ -136,7 +163,10 @@ pci_alloc(void)
   pci_define_param(a, "net.cache_name", "~/.pciids-cache", "Name of the ID cache file");
   a->id_lookup_mode = PCI_LOOKUP_CACHE;
 #endif
-  for(i=0; i<PCI_ACCESS_MAX; i++)
+#ifdef PCI_HAVE_HWDB
+  pci_define_param(a, "hwdb.disable", "0", "Do not look up names in UDEV's HWDB if non-zero");
+#endif
+  for (i=0; i<PCI_ACCESS_MAX; i++)
     if (pci_methods[i] && pci_methods[i]->config)
       pci_methods[i]->config(a);
   return a;
@@ -163,7 +193,7 @@ pci_init(struct pci_access *a)
   else
     {
       unsigned int i;
-      for(i=0; i<PCI_ACCESS_MAX; i++)
+      for (i=0; i<PCI_ACCESS_MAX; i++)
        if (pci_methods[i])
          {
            a->debug("Trying method %d...", i);
@@ -188,7 +218,7 @@ pci_cleanup(struct pci_access *a)
 {
   struct pci_dev *d, *e;
 
-  for(d=a->devices; d; d=e)
+  for (d=a->devices; d; d=e)
     {
       e = d->next;
       pci_free_dev(d);