]> mj.ucw.cz Git - pciutils.git/blobdiff - setpci.c
pciids, not ids.
[pciutils.git] / setpci.c
index a3bfb63d545a1d441acdfaecf96c8fd409ea858d..497538a5b9d73658f23255001378e812137e613f 100644 (file)
--- a/setpci.c
+++ b/setpci.c
@@ -1,9 +1,9 @@
 /*
 /*
- *     $Id: setpci.c,v 1.9 1999/01/22 21:05:02 mj Exp $
+ *     $Id: setpci.c,v 1.12 2002/03/30 15:39:24 mj Exp $
  *
  *     Linux PCI Utilities -- Manipulate PCI Configuration Registers
  *
  *
  *     Linux PCI Utilities -- Manipulate PCI Configuration Registers
  *
- *     Copyright (c) 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     Copyright (c) 1998 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -56,10 +56,11 @@ exec_op(struct op *op, struct pci_dev *dev)
   char *mm[] = { NULL, "%02x", "%04x", NULL, "%08x" };
   char *m = mm[op->width];
   unsigned int x;
   char *mm[] = { NULL, "%02x", "%04x", NULL, "%08x" };
   char *m = mm[op->width];
   unsigned int x;
-  int i;
+  int i, addr;
 
   if (verbose)
     printf("%02x:%02x.%x:%02x", dev->bus, dev->dev, dev->func, op->addr);
 
   if (verbose)
     printf("%02x:%02x.%x:%02x", dev->bus, dev->dev, dev->func, op->addr);
+  addr = op->addr;
   if (op->num_values >= 0)
     for(i=0; i<op->num_values; i++)
       {
   if (op->num_values >= 0)
     for(i=0; i<op->num_values; i++)
       {
@@ -73,15 +74,16 @@ exec_op(struct op *op, struct pci_dev *dev)
        switch (op->width)
          {
          case 1:
        switch (op->width)
          {
          case 1:
-           pci_write_byte(dev, op->addr, op->values[i]);
+           pci_write_byte(dev, addr, op->values[i]);
            break;
          case 2:
            break;
          case 2:
-           pci_write_word(dev, op->addr, op->values[i]);
+           pci_write_word(dev, addr, op->values[i]);
            break;
          default:
            break;
          default:
-           pci_write_long(dev, op->addr, op->values[i]);
+           pci_write_long(dev, addr, op->values[i]);
            break;
          }
            break;
          }
+       addr += op->width;
       }
   else
     {
       }
   else
     {
@@ -92,13 +94,13 @@ exec_op(struct op *op, struct pci_dev *dev)
          switch (op->width)
            {
            case 1:
          switch (op->width)
            {
            case 1:
-             x = pci_read_byte(dev, op->addr);
+             x = pci_read_byte(dev, addr);
              break;
            case 2:
              break;
            case 2:
-             x = pci_read_word(dev, op->addr);
+             x = pci_read_word(dev, addr);
              break;
            default:
              break;
            default:
-             x = pci_read_long(dev, op->addr);
+             x = pci_read_long(dev, addr);
              break;
            }
          printf(m, x);
              break;
            }
          printf(m, x);
@@ -325,7 +327,7 @@ next:
            usage();
          if (c[2])
            d = (c[2] == '=') ? c+3 : c+2;
            usage();
          if (c[2])
            d = (c[2] == '=') ? c+3 : c+2;
-         else if (argc)
+         else if (argc > 1)
            {
              argc--;
              argv++;
            {
              argc--;
              argv++;