From 0dff3470926f813cd36d03bc79216972399e65e5 Mon Sep 17 00:00:00 2001
From: Amit Saha <asaha@redhat.com>
Date: Thu, 23 Apr 2015 14:52:02 +1000
Subject: [PATCH] Add a new element "vendor_id" element which preserves the original vendor ID (#405)
Bug: 1212284
---
diff --git a/docs/lshw.xsd b/docs/lshw.xsd
index b46a33e..95d5e38 100644
--- a/docs/lshw.xsd
+++ b/docs/lshw.xsd
@@ -13,6 +13,7 @@
<xs:element name="description" type="xs:string" minOccurs="0" />
<xs:element name="product" type="xs:string" minOccurs="0" />
<xs:element name="vendor" type="xs:string" minOccurs="0" />
+ <xs:element name="vendor_id" type="xs:string" minOccurs="0" />
<xs:element name="physid" type="xs:string" minOccurs="0" />
<xs:element name="version" type="xs:string" minOccurs="0" />
<xs:element name="date" type="xs:string" minOccurs="0" />
diff --git a/src/core/cpuinfo.cc b/src/core/cpuinfo.cc
index ac2ff1b..ee96424 100644
--- a/src/core/cpuinfo.cc
+++ b/src/core/cpuinfo.cc
@@ -454,6 +454,7 @@
cpu->claim(true);
if (id == "vendor_id")
{
+ cpu->setVendorId(value);
if (value == "AuthenticAMD")
value = "Advanced Micro Devices [AMD]";
if (value == "GenuineIntel")
diff --git a/src/core/hw.cc b/src/core/hw.cc
index 44e2bd8..bad65d3 100644
--- a/src/core/hw.cc
+++ b/src/core/hw.cc
@@ -27,7 +27,7 @@
struct hwNode_i
{
hwClass deviceclass;
- string id, vendor, product, version, date, serial, slot, handle, description,
+ string id, vendor, vendor_id, product, version, date, serial, slot, handle, description,
businfo, physid, dev, modalias, subsysvendor, subsysproduct;
bool enabled;
bool claimed;
@@ -394,6 +394,19 @@
if (This)
This->vendor = strip(vendor);
}
+string hwNode::getVendorId() const
+{
+ if (This)
+ return This->vendor_id;
+ else
+ return "";
+}
+
+void hwNode::setVendorId(const string & vendor_id)
+{
+ if (This)
+ This->vendor_id = strip(vendor_id);
+}
string hwNode::getSubsysVendor() const
@@ -1441,6 +1454,15 @@
out << "\"";
}
+ if (getVendorId() != "")
+ {
+ out << "," << endl;
+ out << spaces(2*level+2);
+ out << "\"vendor_id\" : \"";
+ out << escapeJSON(getVendorId());
+ out << "\"";
+ }
+
if (getPhysId() != "")
{
out << "," << endl;
@@ -1749,6 +1771,16 @@
out << endl;
}
+ if (getVendorId() != "")
+ {
+ out << spaces(2*level+1);
+ out << "<vendor_id>";
+ out << escape(getVendorId());
+ out << "</vendor_id>";
+ out << endl;
+ }
+
+
if (getPhysId() != "")
{
out << spaces(2*level+1);
diff --git a/src/core/hw.h b/src/core/hw.h
index d61bb98..2f21cd0 100644
--- a/src/core/hw.h
+++ b/src/core/hw.h
@@ -124,6 +124,9 @@
string getVendor() const;
void setVendor(const string & vendor);
+ string getVendorId() const;
+ void setVendorId(const string & vendor);
+
string getSubsysVendor() const;
void setSubsysVendor(const string & subsysvendor);
diff --git a/src/core/print.cc b/src/core/print.cc
index 5df078e..ec8dfc9 100644
--- a/src/core/print.cc
+++ b/src/core/print.cc
@@ -209,6 +209,20 @@
cout << endl;
}
+ if (node.getVendorId() != "")
+ {
+ tab(level + 1, false);
+ if (html)
+ cout << "<tr><td class=\"first\">";
+ cout << _("vendor_id") << ": ";
+ if (html)
+ cout << "</td><td class=\"second\">";
+ cout << node.getVendorId();
+ if (html)
+ cout << "</td></tr>";
+ cout << endl;
+ }
+
if (node.getPhysId() != "")
{
tab(level + 1, false);