Blame SOURCES/0004-improve-model-and-chassis-retrieval-for-IBM-systems-.patch

99c779
From b45d6c4fb2c340872ed7d61d94f0d9198b68a960 Mon Sep 17 00:00:00 2001
99c779
From: Dan Callaghan <dcallagh@redhat.com>
99c779
Date: Wed, 24 Jun 2015 14:49:26 +1000
99c779
Subject: [PATCH 04/26] improve model and chassis retrieval for IBM systems
99c779
 (#685)
99c779
99c779
---
99c779
 src/core/device-tree.cc | 65 ++++++++++++++++++++++++++++++++++++++++++++++---
99c779
 1 file changed, 61 insertions(+), 4 deletions(-)
99c779
99c779
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
99c779
index 8908fd1..8be5966 100644
99c779
--- a/src/core/device-tree.cc
99c779
+++ b/src/core/device-tree.cc
99c779
@@ -1233,6 +1233,64 @@ static bool get_apple_model(hwNode & n)
99c779
   return false;
99c779
 }
99c779
 
99c779
+struct ibm_model_def {
99c779
+  const char *model;
99c779
+  const char *modelname;
99c779
+  const char *icon;
99c779
+  const char *chassis; // matches DMI chassis types
99c779
+};
99c779
+struct ibm_model_def ibm_model_defs[] =
99c779
+{
99c779
+  {"0200", "BladeCenter QS20", "", "blade"},
99c779
+  {"0792", "BladeCenter QS21", "", "blade"},
99c779
+  {"6778", "BladeCenter JS21", "", "blade"},
99c779
+  {"6779", "BladeCenter JS21", "", "blade"},
99c779
+  {"7047-185", "IntelliStation POWER 185", "towercomputer", "tower"},
99c779
+  {"7988", "BladeCenter JS21", "", "blade"},
99c779
+  {"8202", "Power 720 Express", "", "rackmount"},
99c779
+  {"8205", "Power 740 Express", "", "rackmount"},
99c779
+  {"8231-E1C", "Power 710 Express", "", "rackmount"},
99c779
+  {"8231-E1D", "Power 710 Express", "", "rackmount"},
99c779
+  {"8231-E2C", "Power 730 Express", "", "rackmount"},
99c779
+  {"8231-E2D", "Power 730 Express", "", "rackmount"},
99c779
+  {"8233-E8B", "Power 750 Express", "", "rackmount"},
99c779
+  {"8236-E8C", "Power 755", "", "rackmount"},
99c779
+  {"8286-41A", "Power Systems S814", "", "rackmount"},
99c779
+  {"8286-42A", "Power Systems S824", "", "rackmount"},
99c779
+  {"8406-70Y", "Power PS700", "", "rackmount"},
99c779
+  {"8406-71Y", "BladeCenter PS702", "", "blade"},
99c779
+  {"8842", "BladeCenter JS20", "", "blade"},
99c779
+  {"8844", "BladeCenter JS21", "", "blade"},
99c779
+  {"9111-285", "IntelliStation POWER 285", "towercomputer", "tower"},
99c779
+  {"9112-265", "IntelliStation POWER 265", "towercomputer", "tower"},
99c779
+  {"9114-275", "IntelliStation POWER 275", "towercomputer", "tower"},
99c779
+  {"9123", "eServer OpenPower 710", "", "rackmount"},
99c779
+  {"9124", "eServer OpenPower 720", "", "rackmount"},
99c779
+};
99c779
+
99c779
+static void get_ibm_model(hwNode & n)
99c779
+{
99c779
+  string product = n.getProduct();
99c779
+  if (product.empty())
99c779
+    return;
99c779
+  if (product.compare(0, 4, "IBM,") != 0)
99c779
+    return;
99c779
+
99c779
+  n.setVendor("IBM");
99c779
+  string machinetype = product.substr(4, 4);
99c779
+  string model = product.substr(4);
99c779
+
99c779
+  for (size_t i = 0; i < sizeof(ibm_model_defs) / sizeof(ibm_model_def); i ++)
99c779
+  {
99c779
+    if (ibm_model_defs[i].model == machinetype || ibm_model_defs[i].model == model)
99c779
+    {
99c779
+      n.setProduct(ibm_model_defs[i].modelname);
99c779
+      n.addHint("icon", string(ibm_model_defs[i].icon));
99c779
+      n.setConfig("chassis", ibm_model_defs[i].chassis);
99c779
+      return;
99c779
+    }
99c779
+  }
99c779
+}
99c779
 
99c779
 static void fix_serial_number(hwNode & n)
99c779
 {
99c779
@@ -1265,10 +1323,11 @@ bool scan_device_tree(hwNode & n)
99c779
     n.setSerial(get_string(DEVICETREE "/system-id"));
99c779
   fix_serial_number(n);
99c779
 
99c779
+  n.setVendor(get_string(DEVICETREE "/copyright", n.getVendor()));
99c779
+  get_apple_model(n);
99c779
+  get_ibm_model(n);
99c779
   if (matches(get_string(DEVICETREE "/compatible"), "^ibm,powernv"))
99c779
   {
99c779
-    n.setVendor(get_string(DEVICETREE "/vendor", "IBM"));
99c779
-
99c779
     if (exists(DEVICETREE "/model-name"))
99c779
       n.setProduct(n.getProduct() + " (" +
99c779
 		   hw::strip(get_string(DEVICETREE "/model-name")) + ")");
99c779
@@ -1323,8 +1381,6 @@ bool scan_device_tree(hwNode & n)
99c779
   }
99c779
   else
99c779
   {
99c779
-    n.setVendor(get_string(DEVICETREE "/copyright", n.getVendor()));
99c779
-    get_apple_model(n);
99c779
     if (core)
99c779
     {
99c779
       core->addHint("icon", string("board"));
99c779
-- 
99c779
2.10.2
99c779