X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ls-caps-vendor.c;h=62ee586dcd6de978162cb8e5c7b813fe7fe4df96;hb=ba06b2f5bdd764a2534e1194acaf7dc3cf696c02;hp=4cdfe227b4f8fdfc7ac2a813cc8ce519a0cf5109;hpb=7ff8a323e7addf64507c5101356e664456112b09;p=pciutils.git diff --git a/ls-caps-vendor.c b/ls-caps-vendor.c index 4cdfe22..62ee586 100644 --- a/ls-caps-vendor.c +++ b/ls-caps-vendor.c @@ -3,7 +3,9 @@ * * Copyright (c) 2014 Gerd Hoffmann * - * 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 v2+. + * + * SPDX-License-Identifier: GPL-2.0-or-later */ #include @@ -11,7 +13,7 @@ #include "lspci.h" -static void +static int show_vendor_caps_virtio(struct device *d, int where, int cap) { int length = BITS(cap, 0, 8); @@ -19,9 +21,9 @@ show_vendor_caps_virtio(struct device *d, int where, int cap) char *tname; if (length < 16) - return; + return 0; if (!config_fetch(d, where, length)) - return; + return 0; switch (type) { @@ -45,32 +47,38 @@ show_vendor_caps_virtio(struct device *d, int where, int cap) printf("VirtIO: %s\n", tname); if (verbose < 2) - return; + return 1; - printf("\t\tBAR=%d offset=%08x size=%08x\n", + printf("\t\tBAR=%d offset=%08x size=%08x", get_conf_byte(d, where + 4), get_conf_long(d, where + 8), get_conf_long(d, where + 12)); - if (type != 2 || length < 20) - return; + if (type == 2 && length >= 20) + printf(" multiplier=%08x", get_conf_long(d, where+16)); - printf("\t\tmultiplier=%08x\n", - get_conf_long(d, where+16)); + printf("\n"); + return 1; } -void -show_vendor_caps(struct device *d, int where, int cap) +static int +do_show_vendor_caps(struct device *d, int where, int cap) { - switch (get_conf_word(d, PCI_VENDOR_ID)) + switch (d->dev->vendor_id) { case 0x1af4: /* Red Hat */ - if (get_conf_word(d, PCI_DEVICE_ID) >= 0x1000 && - get_conf_word(d, PCI_DEVICE_ID) <= 0x107f) - show_vendor_caps_virtio(d, where, cap); - break; - default: - printf("Vendor Specific Information: Len=%02x \n", BITS(cap, 0, 8)); + if (d->dev->device_id >= 0x1000 && + d->dev->device_id <= 0x107f) + return show_vendor_caps_virtio(d, where, cap); break; } + return 0; +} + +void +show_vendor_caps(struct device *d, int where, int cap) +{ + printf("Vendor Specific Information: "); + if (!do_show_vendor_caps(d, where, cap)) + printf("Len=%02x \n", BITS(cap, 0, 8)); }