[PATCH v2 2/3] devicetree/dt_sysinfo: fix reference platform compatible vs. model check
Jeremy Kerr
jk at ozlabs.org
Thu Jun 30 07:17:40 UTC 2016
The logic in machine_matches_reference_model is slightly incorrect; if
we're *not* running on a reference platform, then we don't want to fail.
The check should only fail if the compatible string reports a reference
platform, but the model number does not.
This change reworks the logic in machine_matches_reference model to
reflect this, allowing us to simplify it a little.
Reported-by: Stewart Smith <stewart at linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
---
src/devicetree/dt_sysinfo/dt_sysinfo.c | 56 +++++++++++++++++++---------------
1 file changed, 32 insertions(+), 24 deletions(-)
diff --git a/src/devicetree/dt_sysinfo/dt_sysinfo.c b/src/devicetree/dt_sysinfo/dt_sysinfo.c
index d08cf5c..07cbbe0 100644
--- a/src/devicetree/dt_sysinfo/dt_sysinfo.c
+++ b/src/devicetree/dt_sysinfo/dt_sysinfo.c
@@ -171,34 +171,42 @@ static bool machine_matches_reference_model(fwts_framework *fw,
int compat_len,
const char *model)
{
- int i, j;
- bool found = false;
-
- for (i = 0;
- i < (int)FWTS_ARRAY_LEN(openpower_reference_platforms);
- i++) {
- struct reference_platform *plat =
- &openpower_reference_platforms[i];
+ bool compatible_is_reference = false, model_is_reference = false;
+ struct reference_platform *plat;
+ int i;
+
+ for (i = 0; i < (int)FWTS_ARRAY_LEN(openpower_reference_platforms);
+ i++) {
+ plat = &openpower_reference_platforms[i];
if (dt_fdt_stringlist_contains_last(compatible,
- compat_len, plat->compatible)) {
- for (j = 0; j < plat->n_models; j++) {
- if (!strcmp(model, plat->models[j])) {
- fwts_log_info_verbatim(fw,
- "Matched reference model, "
- "device tree \"compatible\" is \"%s\" and "
- "\"model\" is \"%s\"",
- plat->compatible, model);
- found = true;
- break;
- }
- }
- } else {
- continue;
+ compat_len, plat->compatible)) {
+ compatible_is_reference = true;
+ break;
}
- if (found)
+ }
+
+ /* Not a reference platform, nothing to check */
+ if (!compatible_is_reference)
+ return true;
+
+ /* Since we're on a reference platform, ensure that the model is also
+ * one of the reference model numbers */
+ for (i = 0; i < plat->n_models; i++) {
+ if (!strcmp(model, plat->models[i])) {
+ model_is_reference = true;
break;
+ }
+ }
+
+ if (model_is_reference) {
+ fwts_log_info_verbatim(fw,
+ "Matched reference model, device tree "
+ "\"compatible\" is \"%s\" and \"model\" is "
+ "\"%s\"",
+ plat->compatible, model);
}
- return found;
+
+ return model_is_reference;
}
static int dt_sysinfo_check_ref_plat_compatible(fwts_framework *fw)
--
2.7.4
More information about the fwts-devel
mailing list