soc/intel: Replace bad uses of find_resource

The `find_resource` function will never return null (will die instead).
In cases where the existing code already accounts for null pointers, it
is better to use `probe_resource` instead, which returns a null pointer
instead of dying.

Change-Id: I2a57ea1c2f5b156afd0724829e5b1880246f351f
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58907
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
Angel Pons 2021-11-03 13:18:53 +01:00 committed by Felix Held
commit c1bfbe03a2
22 changed files with 32 additions and 32 deletions

View file

@ -100,7 +100,7 @@ static uintptr_t graphics_get_bar(struct device *dev, unsigned long index)
{
struct resource *gm_res;
gm_res = find_resource(dev, index);
gm_res = probe_resource(dev, index);
if (!gm_res)
return 0;

View file

@ -123,7 +123,7 @@ uintptr_t dw_i2c_base_address(unsigned int bus)
return (uintptr_t)NULL;
/* dev -> bar0 */
res = find_resource(dev, PCI_BASE_ADDRESS_0);
res = probe_resource(dev, PCI_BASE_ADDRESS_0);
if (res)
return res->base;

View file

@ -46,7 +46,7 @@ static void pch_smbus_init(struct device *dev)
~((1 << 8) | (1 << 10) | (1 << 12) | (1 << 14)), 0);
/* Set Receive Slave Address */
res = find_resource(dev, PCI_BASE_ADDRESS_4);
res = probe_resource(dev, PCI_BASE_ADDRESS_4);
if (res)
smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR);
}

View file

@ -55,7 +55,7 @@ void pch_thermal_configuration(void)
return;
}
res = find_resource(dev, PCI_BASE_ADDRESS_0);
res = probe_resource(dev, PCI_BASE_ADDRESS_0);
if (!res) {
printk(BIOS_ERR, "ERROR: PCH thermal device not found!\n");
return;

View file

@ -33,7 +33,7 @@ static bool is_usb_port_connected(const struct xhci_usb_info *info,
return false;
/* Calculate port status register address and read the status */
res = find_resource(PCH_DEV_XHCI, PCI_BASE_ADDRESS_0);
res = probe_resource(PCH_DEV_XHCI, PCI_BASE_ADDRESS_0);
/* If the memory BAR is not allocated for XHCI, leave the devices enabled */
if (!res)
return true;