[PATCH] lspci: Print vendor-/system-specific VPD item ids correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <bhutchings@xxxxxxxxxxxxxx>
---
 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)
 	        {

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux