summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/fw_config.h19
-rw-r--r--src/lib/fw_config.c41
2 files changed, 47 insertions, 13 deletions
diff --git a/src/include/fw_config.h b/src/include/fw_config.h
index b702871358..7a8ad30482 100644
--- a/src/include/fw_config.h
+++ b/src/include/fw_config.h
@@ -70,6 +70,16 @@ bool fw_config_is_provisioned(void);
*/
const struct fw_config *fw_config_get_found(uint64_t field_mask);
+/**
+ * fw_config_probe_dev() - Check if any of the probe conditions are true for given device.
+ * @dev: Device for which probe conditions are checked
+ * @matching_probe: If any probe condition match, then the matching probe condition is returned
+ * to the caller.
+ * Return %true if device has no probing conditions or if a matching probe condition is
+ * encountered, %false otherwise.
+ */
+bool fw_config_probe_dev(const struct device *dev, const struct fw_config **matching_probe);
+
#else
static inline bool fw_config_probe(const struct fw_config *match)
@@ -78,6 +88,15 @@ static inline bool fw_config_probe(const struct fw_config *match)
return true;
}
+static inline bool fw_config_probe_dev(const struct device *dev,
+ const struct fw_config **matching_probe)
+{
+ /* Always return true when probing with disabled fw_config. */
+ if (matching_probe)
+ *matching_probe = NULL;
+ return true;
+}
+
#endif /* CONFIG(FW_CONFIG) */
#endif /* __FW_CONFIG__ */
diff --git a/src/lib/fw_config.c b/src/lib/fw_config.c
index 7412f383e1..8e45c004fb 100644
--- a/src/lib/fw_config.c
+++ b/src/lib/fw_config.c
@@ -74,6 +74,29 @@ bool fw_config_is_provisioned(void)
return fw_config_get() != UNDEFINED_FW_CONFIG;
}
+bool fw_config_probe_dev(const struct device *dev, const struct fw_config **matching_probe)
+{
+ const struct fw_config *probe;
+
+ if (matching_probe)
+ *matching_probe = NULL;
+
+ /* If the device does not have a probe list, then probing is not required. */
+ if (!dev->probe_list)
+ return true;
+
+ for (probe = dev->probe_list; probe && probe->mask != 0; probe++) {
+ if (!fw_config_probe(probe))
+ continue;
+
+ if (matching_probe)
+ *matching_probe = probe;
+ return true;
+ }
+
+ return false;
+}
+
#if ENV_RAMSTAGE
/*
@@ -115,23 +138,15 @@ static void fw_config_init(void *unused)
for (dev = all_devices; dev; dev = dev->next) {
const struct fw_config *probe;
- bool match = false;
-
- if (!dev->probe_list)
- continue;
- for (probe = dev->probe_list; probe && probe->mask != 0; probe++) {
- if (fw_config_probe(probe)) {
- match = true;
- cached_configs[probe_index(probe->mask)] = probe;
- break;
- }
- }
-
- if (!match) {
+ if (!fw_config_probe_dev(dev, &probe)) {
printk(BIOS_INFO, "%s disabled by fw_config\n", dev_path(dev));
dev->enabled = 0;
+ continue;
}
+
+ if (probe)
+ cached_configs[probe_index(probe->mask)] = probe;
}
}
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT_CHIPS, BS_ON_ENTRY, fw_config_init, NULL);