]> mj.ucw.cz Git - pciutils.git/commitdiff
Introduced API for selection of access methods.
authorMartin Mares <mj@ucw.cz>
Tue, 12 Feb 2008 09:19:19 +0000 (10:19 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 12 Feb 2008 09:19:19 +0000 (10:19 +0100)
Access method names were normalized (they so far served only informational
purposes). Each access method gained a help text.

lib/aix-device.c
lib/dump.c
lib/fbsd-device.c
lib/i386-ports.c
lib/init.c
lib/internal.h
lib/nbsd-libpci.c
lib/obsd-device.c
lib/pci.h
lib/proc.c
lib/sysfs.c

index 2febd7973092b9e9e412ea2006d3203186475e9d..cb0a974ec38398d22f51e9bd22c570441808a147 100644 (file)
@@ -259,7 +259,8 @@ aix_write(struct pci_dev *d, int pos, byte *buf, int len)
 }
 
 struct pci_methods pm_aix_device = {
-  "AIX-device",
+  "aix-device",
+  "AIX /dev/pci[0-n]",
   NULL,
   aix_detect,
   aix_init,
index 9bf50af827816c772ad01bf6496be250f487645d..69a99c82ae3a50897eb6557ac03da43d6a3335b2 100644 (file)
@@ -164,6 +164,7 @@ dump_cleanup_dev(struct pci_dev *d)
 
 struct pci_methods pm_dump = {
   "dump",
+  "Reading of register dumps (set the `dump.name' parameter)",
   dump_config,
   dump_detect,
   dump_init,
index 328190627312025341f60b9e96b3b82fde1c5c12..742c6419f54efa1dbdb1b64057c3402e40345624 100644 (file)
@@ -154,7 +154,8 @@ fbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
 }
 
 struct pci_methods pm_fbsd_device = {
-  "FreeBSD-device",
+  "fbsd-device",
+  "FreeBSD /dev/pci device",
   fbsd_config,
   fbsd_detect,
   fbsd_init,
index 4b51c8818f097e67bbbe4e864fc82156c67e461e..041e47fb90fb0427ee0e09bf640febcda99b080f 100644 (file)
@@ -253,7 +253,8 @@ conf2_write(struct pci_dev *d, int pos, byte *buf, int len)
 }
 
 struct pci_methods pm_intel_conf1 = {
-  "Intel-conf1",
+  "intel-conf1",
+  "Raw I/O port access using Intel conf1 interface",
   NULL,                                        /* config */
   conf1_detect,
   conf12_init,
@@ -267,7 +268,8 @@ struct pci_methods pm_intel_conf1 = {
 };
 
 struct pci_methods pm_intel_conf2 = {
-  "Intel-conf2",
+  "intel-conf2",
+  "Raw I/O port access using Intel conf2 interface",
   NULL,                                        /* config */
   conf2_detect,
   conf12_init,
index 59cb706d3580aa8ab6ff5938bc3bf51f16e47e14..be45f81dd5888a99038767bb8e773a59d5503568 100644 (file)
@@ -123,6 +123,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)
 {
index fea3978d468f9c5d36467e8c3c2dd05aa01a1645..a1dc16ffe5eec6922ef4e291b46dd2ccd918e597 100644 (file)
@@ -11,6 +11,7 @@
 
 struct pci_methods {
   char *name;
+  char *help;
   void (*config)(struct pci_access *);
   int (*detect)(struct pci_access *);
   void (*init)(struct pci_access *);
index 7955570dcd24a1cea20443043f632bcd23060ad7..2d24c4cee69d96c92b421c126999adf1bede471b 100644 (file)
@@ -141,7 +141,8 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
 }
 
 struct pci_methods pm_nbsd_libpci = {
-  "NetBSD-libpci",
+  "nbsd-libpci",
+  "NetBSD libpci",
   nbsd_config,
   nbsd_detect,
   nbsd_init,
index 217e7873cf8a3a4a988055d851accb5746b8596c..62395b376f2b5917d84f1797cede1faebfc5eece 100644 (file)
@@ -136,7 +136,8 @@ obsd_write(struct pci_dev *d, int pos, byte *buf, int len)
 }
 
 struct pci_methods pm_obsd_device = {
-  "OpenBSD-device",
+  "obsd-device",
+  "/dev/pci on OpenBSD",
   obsd_config,
   obsd_detect,
   obsd_init,
index ce42deb589e162f887522e4664041ded1a9eeabe..d2c9ab61f33e79199a0169807164dad61944d130 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -81,6 +81,10 @@ void pci_scan_bus(struct pci_access *acc);
 struct pci_dev *pci_get_dev(struct pci_access *acc, int domain, int bus, int dev, int func); /* Raw access to specified device */
 void pci_free_dev(struct pci_dev *);
 
+/* Names of access methods */
+int pci_lookup_method(char *name);     /* Returns -1 if not found */
+char *pci_get_method_name(int index);  /* Returns "" if unavailable, NULL if index out of range */
+
 /*
  *     Named parameters
  */
index 20f57902b4207507559a9739b68dae2cb958064d..1b44b4e80643831fd6a98689c4924d4c6b2a297d 100644 (file)
@@ -187,7 +187,8 @@ proc_cleanup_dev(struct pci_dev *d)
 }
 
 struct pci_methods pm_linux_proc = {
-  "Linux-proc",
+  "linux-proc",
+  "The proc file system on Linux",
   proc_config,
   proc_detect,
   proc_init,
index 581bedbd12938244e8d0b9e722d78b18bcee3e98..ea386fa8fbdfbf4a7dd616ef8469eed2c4bed7a7 100644 (file)
@@ -250,7 +250,8 @@ static void sysfs_cleanup_dev(struct pci_dev *d)
 }
 
 struct pci_methods pm_linux_sysfs = {
-  "Linux-sysfs",
+  "linux-sysfs",
+  "The sys filesystem on Linux",
   sysfs_config,
   sysfs_detect,
   sysfs_init,