X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fnames.c;h=94225f58efeaae308ac526c5c6e3a50cff24560d;hb=596cc4d213c59e0795e542e1017913904d137ca9;hp=a9bb620e6d7da8f32b3284e6797c7af552c54a20;hpb=0c047bbefa7dfe6e5084bbe460c8a859655863fe;p=pciutils.git diff --git a/lib/names.c b/lib/names.c index a9bb620..94225f5 100644 --- a/lib/names.c +++ b/lib/names.c @@ -1,9 +1,9 @@ /* - * $Id: names.c,v 1.4 1999/12/11 22:38:55 mj Exp $ + * $Id: names.c,v 1.9 2002/03/30 15:39:25 mj Exp $ * * The PCI Library -- ID to Name Translation * - * Copyright (c) 1997--1999 Martin Mares + * Copyright (c) 1997--2002 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -98,19 +98,10 @@ parse_name_list(struct pci_access *a) lino++; q = p; while (*p && *p != '\n') - { - if (*p == '#') - { - *p++ = 0; - while (*p && *p != '\n') - p++; - break; - } - p++; - } + p++; if (*p == '\n') *p++ = 0; - if (!*q) + if (!*q || *q == '#') continue; r = p; while (r > q && r[-1] == ' ') @@ -284,13 +275,15 @@ pci_lookup_name(struct pci_access *a, char *buf, int size, int flags, u32 arg1, if (n = nl_lookup(a, num, NL_VENDOR, arg3, 0, 0, 0)) return n->name; else - res = snprintf(buf, size, "%04x", arg1); + res = snprintf(buf, size, "%04x", arg2); break; case PCI_LOOKUP_DEVICE | PCI_LOOKUP_SUBSYSTEM: if (n = nl_lookup(a, num, NL_SUBSYSTEM, arg1, arg2, arg3, arg4)) return n->name; + else if (arg1 == arg3 && arg2 == arg4 && (n = nl_lookup(a, num, NL_DEVICE, arg1, arg2, 0, 0))) + return n->name; else - res = snprintf(buf, size, "%04x", arg2); + res = snprintf(buf, size, "%04x", arg4); break; case PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE | PCI_LOOKUP_SUBSYSTEM: if (!num) @@ -298,6 +291,9 @@ pci_lookup_name(struct pci_access *a, char *buf, int size, int flags, u32 arg1, struct nl_entry *e, *e2; e = nl_lookup(a, 0, NL_VENDOR, arg3, 0, 0, 0); e2 = nl_lookup(a, 0, NL_SUBSYSTEM, arg1, arg2, arg3, arg4); + if (!e2 && arg1 == arg3 && arg2 == arg4) + /* Cheat for vendors blindly setting subsystem ID same as device ID */ + e2 = nl_lookup(a, 0, NL_DEVICE, arg1, arg2, 0, 0); if (!e) res = snprintf(buf, size, "Unknown device %04x:%04x", arg3, arg4); else if (!e2)