From patchwork Mon Jun 29 16:41:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 32991 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5TH1tax009189 for ; Mon, 29 Jun 2009 17:01:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753018AbZF2RBu (ORCPT ); Mon, 29 Jun 2009 13:01:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752937AbZF2RBu (ORCPT ); Mon, 29 Jun 2009 13:01:50 -0400 Received: from queue01.mail.zen.net.uk ([212.23.3.234]:41696 "EHLO fizeau.zen.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbZF2RBt (ORCPT ); Mon, 29 Jun 2009 13:01:49 -0400 X-Greylist: delayed 1191 seconds by postgrey-1.27 at vger.kernel.org; Mon, 29 Jun 2009 13:01:49 EDT Received: from [212.23.3.140] (helo=smarthost01.mail.zen.net.uk) by fizeau.zen.co.uk with esmtp (Exim 4.63) (envelope-from ) id 1MLJx2-00056N-Qu for linux-pci@vger.kernel.org; Mon, 29 Jun 2009 16:43:29 +0000 Received: from [82.69.137.158] (helo=opal.uk.level5networks.com) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1MLJva-0004tO-9G; Mon, 29 Jun 2009 16:41:58 +0000 Received: from [10.17.20.50] (achroite.uk.level5networks.com [10.17.20.50]) by opal.uk.level5networks.com (8.12.8/8.12.8) with ESMTP id n5TGfvIJ030129; Mon, 29 Jun 2009 17:41:57 +0100 Subject: [PATCH] lspci: Print vendor-/system-specific VPD item ids correctly From: Ben Hutchings To: Martin Mares Cc: linux-pci@vger.kernel.org Organization: Solarflare Communications Date: Mon, 29 Jun 2009 17:41:56 +0100 Message-Id: <1246293717.2848.6.camel@achroite> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) X-Originating-Smarthost01-IP: [82.69.137.158] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Vendor- and system-specific VPD items are matched only by their first character, so we cannot read the item id from the matching structure. There is a similar issue with unknown VPD items, which is handled by creating a matching structure dynamically. We can handle both cases using the static matching structure and the actual item id, so do that. Signed-off-by: Ben Hutchings --- ls-vpd.c | 20 +++++++------------- 1 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ls-vpd.c b/ls-vpd.c index f50d7a4..a1696ee 100644 --- a/ls-vpd.c +++ b/ls-vpd.c @@ -41,7 +41,7 @@ static const struct vpd_item { { 'Y','A', F_TEXT, "Asset tag" }, { 'V', 0 , F_TEXT, "Vendor specific" }, { 'Y', 0 , F_TEXT, "System specific" }, - { 0, 0 , F_BINARY, NULL } + { 0, 0 , F_BINARY, "Unknown" } }; static void @@ -149,27 +149,21 @@ cap_vpd(struct device *d) { word read_len; const struct vpd_item *item; - struct vpd_item unknown_item; + byte id1, id2; if (!read_vpd(d, res_addr + part_pos, buf, 3, &csum)) break; part_pos += 3; + id1 = buf[0]; + id2 = buf[1]; part_len = buf[2]; if (part_len > res_len - part_pos) break; /* Is this item known? */ - for (item=vpd_items; item->id1 && item->id1 != buf[0] || - item->id2 && item->id2 != buf[1]; item++) + for (item=vpd_items; item->id1 && item->id1 != id1 || + item->id2 && item->id2 != id2; item++) ; - if (!item->id1 && !item->id2) - { - unknown_item.id1 = buf[0]; - unknown_item.id2 = buf[1]; - unknown_item.format = F_BINARY; - unknown_item.name = "Unknown"; - item = &unknown_item; - } /* Only read the first byte of the RV field because the * remaining bytes are not included in the checksum. */ @@ -177,7 +171,7 @@ cap_vpd(struct device *d) if (!read_vpd(d, res_addr + part_pos, buf, read_len, &csum)) break; - printf("\t\t\t[%c%c] %s: ", item->id1, item->id2, item->name); + printf("\t\t\t[%c%c] %s: ", id1, id2, item->name); switch (item->format) {