/*
- * $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
*
- * 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.
*/
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);
+ addr = op->addr;
if (op->num_values >= 0)
for(i=0; i<op->num_values; i++)
{
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:
- pci_write_word(dev, op->addr, op->values[i]);
+ pci_write_word(dev, addr, op->values[i]);
break;
default:
- pci_write_long(dev, op->addr, op->values[i]);
+ pci_write_long(dev, addr, op->values[i]);
break;
}
+ addr += op->width;
}
else
{
switch (op->width)
{
case 1:
- x = pci_read_byte(dev, op->addr);
+ x = pci_read_byte(dev, addr);
break;
case 2:
- x = pci_read_word(dev, op->addr);
+ x = pci_read_word(dev, addr);
break;
default:
- x = pci_read_long(dev, op->addr);
+ x = pci_read_long(dev, addr);
break;
}
printf(m, x);
usage();
if (c[2])
d = (c[2] == '=') ? c+3 : c+2;
- else if (argc)
+ else if (argc > 1)
{
argc--;
argv++;