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

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