]> mj.ucw.cz Git - pciutils.git/commitdiff
Added an option for selection of access methods.
authorMartin Mares <mj@ucw.cz>
Tue, 12 Feb 2008 09:19:38 +0000 (10:19 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 12 Feb 2008 09:19:38 +0000 (10:19 +0100)
common.c
pciutils.h

index ed439b4d54868c282a9a110789b199f1c91cbea7..77974f314f5fca7f736d2c356465b40b0d8fc1c2 100644 (file)
--- a/common.c
+++ b/common.c
@@ -44,6 +44,29 @@ xrealloc(void *ptr, unsigned int howmuch)
   return p;
 }
 
+static void
+set_pci_method(struct pci_access *pacc, char *arg)
+{
+  char *name;
+  int i;
+
+  if (!strcmp(arg, "help"))
+    {
+      printf("Known PCI access methods:\n\n");
+      for (i=0; name = pci_get_method_name(i); i++)
+       if (name[0])
+         printf("%s\n", name);
+      exit(0);
+    }
+  else
+    {
+      i = pci_lookup_method(arg);
+      if (i < 0)
+       die("No such PCI access method: %s (see `-A help' for a list)", arg);
+      pacc->method = i;
+    }
+}
+
 static void
 set_pci_option(struct pci_access *pacc, char *arg)
 {
@@ -62,7 +85,7 @@ set_pci_option(struct pci_access *pacc, char *arg)
        die("Invalid PCI access parameter syntax: %s", arg);
       *sep++ = 0;
       if (pci_set_param(pacc, arg, sep) < 0)
-       die("Unrecognized PCI access parameter: %s", arg);
+       die("Unrecognized PCI access parameter: %s (see `-O help' for a list)", arg);
     }
 }
 
@@ -93,6 +116,9 @@ parse_generic_option(int i, struct pci_access *pacc, char *optarg)
       pacc->method = PCI_ACCESS_DUMP;
       break;
 #endif
+    case 'A':
+      set_pci_method(pacc, optarg);
+      break;
     case 'G':
       pacc->debugging++;
       break;
index 02071ac2a39dced465e1abfa6c3f1b83bcff2613..940810200f86b6b93ec57a4dc4aae15e889ce5ac 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     The PCI Utilities -- Declarations
  *
- *     Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
+ *     Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -44,7 +44,8 @@ int parse_generic_option(int i, struct pci_access *pacc, char *optarg);
 #define GENHELP_DUMP
 #endif
 
-#define GENERIC_OPTIONS "GO:" GENOPT_PROC GENOPT_INTEL GENOPT_DUMP
+#define GENERIC_OPTIONS "A:GO:" GENOPT_PROC GENOPT_INTEL GENOPT_DUMP
 #define GENERIC_HELP GENHELP_PROC GENHELP_INTEL GENHELP_DUMP \
+       "-A <method>\tUse the specified PCI access method (see `-A help' for a list)\n" \
        "-G\t\tEnable PCI access debugging\n" \
-       "-O <par>=<val>\tSet PCI access parameter (see `-O help' for the list)\n"
+       "-O <par>=<val>\tSet PCI access parameter (see `-O help' for a list)\n"