static void
sysfs_config(struct pci_access *a)
{
- a->method_params[PCI_ACCESS_SYS_BUS_PCI] = PATH_SYS_BUS_PCI;
+ a->method_params[PCI_ACCESS_SYS_BUS_PCI] = PCI_PATH_SYS_BUS_PCI;
}
static inline char *
{
if (access(sysfs_name(a), R_OK))
{
- a->debug("Cannot open %s", sysfs_name(a));
+ a->debug("...cannot open %s", sysfs_name(a));
return 0;
}
a->debug("...using %s", sysfs_name(a));
file = fopen(namebuf, "r");
if (!file)
a->error("Cannot open %s: %s", namebuf, strerror(errno));
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 7; i++)
{
unsigned long long start, end, size;
if (!fgets(buf, sizeof(buf), file))
if (start != (unsigned long long)(pciaddr_t) start ||
end != (unsigned long long)(pciaddr_t) end)
{
- a->warning("Resource %d in %s has a 64-bit address, ignoring", namebuf);
+ a->warning("Resource %d in %s has a 64-bit address, ignoring", i, namebuf);
start = end = 0;
}
if (start)
size = end - start + 1;
else
size = 0;
- if (i < 7)
+ if (i < 6)
{
d->base_addr[i] = start;
d->size[i] = size;
d->bus = bus;
d->dev = dev;
d->func = func;
- d->hdrtype = pci_read_byte(d, PCI_HEADER_TYPE) & 0x7f;
if (!a->buscentric)
{
sysfs_get_resources(d);
+ d->irq = sysfs_get_value(d, "irq");
+ d->known_fields = PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES;
+#if 0
+ /*
+ * We prefer reading these from the config registers, it's faster.
+ * However, it would be possible and maybe even useful to hack the kernel
+ * to believe that some device has a different ID. If you do it, just
+ * enable this piece of code. --mj
+ */
d->vendor_id = sysfs_get_value(d, "vendor");
d->device_id = sysfs_get_value(d, "device");
- d->irq = sysfs_get_value(d, "irq");
- d->known_fields = PCI_FILL_IDENT | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES;
+ d->known_fields |= PCI_FILL_IDENT;
+#endif
}
pci_link_dev(a, d);
}
return 0;
}
else if (res != len)
- {
- d->access->warning("sysfs_read: tried to read %d bytes at %d, but got only %d", len, pos, res);
- return 0;
- }
+ return 0;
return 1;
}
}
else if (res != len)
{
- d->access->warning("sysfs_write: tried to write %d bytes at %d, but got only %d", len, pos, res);
+ d->access->warning("sysfs_write: tried to write %d bytes at %d, but only %d succeeded", len, pos, res);
return 0;
}
return 1;