drivers: 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: Ia9a4b62c857f7362d67aee4f9de3bb2da1838394
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58908
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:22:22 +01:00
committed by Felix Held
parent c1bfbe03a2
commit e058841913
4 changed files with 4 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ int ast_crtc_do_set_base(struct drm_crtc *crtc)
struct drm_framebuffer *fb = crtc->primary->fb; struct drm_framebuffer *fb = crtc->primary->fb;
/* PCI BAR 0 */ /* PCI BAR 0 */
struct resource *res = find_resource(crtc->dev->pdev, PCI_BASE_ADDRESS_0); struct resource *res = probe_resource(crtc->dev->pdev, PCI_BASE_ADDRESS_0);
if (!res) { if (!res) {
printk(BIOS_ERR, "BAR0 resource not found.\n"); printk(BIOS_ERR, "BAR0 resource not found.\n");
return -EIO; return -EIO;

View File

@@ -106,7 +106,7 @@ static int atl1e_eeprom_exist(u32 mem_base)
static void atl1e_init(struct device *dev) static void atl1e_init(struct device *dev)
{ {
/* Get the resource of the NIC mmio */ /* Get the resource of the NIC mmio */
struct resource *nic_res = find_resource(dev, PCI_BASE_ADDRESS_0); struct resource *nic_res = probe_resource(dev, PCI_BASE_ADDRESS_0);
if (nic_res == NULL) { if (nic_res == NULL) {
printk(BIOS_ERR, "atl1e: resource not found\n"); printk(BIOS_ERR, "atl1e: resource not found\n");

View File

@@ -12,7 +12,7 @@ static void oxford_oxpcie_enable(struct device *dev)
{ {
printk(BIOS_DEBUG, "Initializing Oxford OXPCIe952\n"); printk(BIOS_DEBUG, "Initializing Oxford OXPCIe952\n");
struct resource *res = find_resource(dev, PCI_BASE_ADDRESS_0); struct resource *res = probe_resource(dev, PCI_BASE_ADDRESS_0);
if (!res) { if (!res) {
printk(BIOS_WARNING, "OXPCIe952: No UART resource found.\n"); printk(BIOS_WARNING, "OXPCIe952: No UART resource found.\n");
return; return;

View File

@@ -75,7 +75,7 @@ static void pci_ehci_set_resources(struct device *dev)
if (ehci_drv_ops->set_resources) if (ehci_drv_ops->set_resources)
ehci_drv_ops->set_resources(dev); ehci_drv_ops->set_resources(dev);
res = find_resource(dev, EHCI_BAR_INDEX); res = probe_resource(dev, EHCI_BAR_INDEX);
if (!res) if (!res)
return; return;