fw_config: Add helper function fw_config_probe_dev
				
					
				
			This change adds a helper function `fw_config_probe_dev()` that allows the caller to check if any of the probe conditions are true for any given device. If device has no probe conditions or a matching probe condition, then it returns true and provides the matching probe condition back to caller (if provided with a valid pointer). Else, it returns false. When fw_config support is disabled, this function always returns true. Change-Id: Ic2dae338e6fbd7755feb23ca86c50c42103f349b Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/54751 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Karthik Ramasubramanian <kramasub@google.com> Reviewed-by: EricR Lai <ericr_lai@compal.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
		
				
					committed by
					
						
						Tim Wawrzynczak
					
				
			
			
				
	
			
			
			
						parent
						
							e59ad2e0da
						
					
				
				
					commit
					665891e3a8
				
			@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user