From c167b748686529fa9f9c667f57cba6519220b341 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Wed, 3 Nov 2021 13:25:02 +0100 Subject: superio: 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: Ic6e28add78f686fc9ab4556eddbedf7828fba9ef Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/58909 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh --- src/superio/fintek/f71808a/f71808a_hwm.c | 2 +- src/superio/fintek/f71869ad/f71869ad_hwm.c | 2 +- src/superio/fintek/f81866d/f81866d_hwm.c | 2 +- src/superio/fintek/f81866d/f81866d_uart.c | 2 +- src/superio/ite/it8613e/superio.c | 2 +- src/superio/ite/it8623e/superio.c | 2 +- src/superio/ite/it8718f/superio.c | 2 +- src/superio/ite/it8720f/superio.c | 2 +- src/superio/ite/it8728f/superio.c | 2 +- src/superio/ite/it8772f/superio.c | 4 ++-- src/superio/ite/it8783ef/superio.c | 2 +- src/superio/ite/it8786e/superio.c | 2 +- src/superio/nuvoton/npcd378/superio.c | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/superio/fintek/f71808a/f71808a_hwm.c b/src/superio/fintek/f71808a/f71808a_hwm.c index 340bc30d4d..f8c4472ce8 100644 --- a/src/superio/fintek/f71808a/f71808a_hwm.c +++ b/src/superio/fintek/f71808a/f71808a_hwm.c @@ -35,7 +35,7 @@ void f71808a_hwm_init(struct device *dev) { - struct resource *res = find_resource(dev, PNP_IDX_IO0); + struct resource *res = probe_resource(dev, PNP_IDX_IO0); if (!res) { printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n"); diff --git a/src/superio/fintek/f71869ad/f71869ad_hwm.c b/src/superio/fintek/f71869ad/f71869ad_hwm.c index 6333ae160a..9add2a779e 100644 --- a/src/superio/fintek/f71869ad/f71869ad_hwm.c +++ b/src/superio/fintek/f71869ad/f71869ad_hwm.c @@ -41,7 +41,7 @@ void f71869ad_hwm_init(struct device *dev) { const struct superio_fintek_f71869ad_config *conf = dev->chip_info; - struct resource *res = find_resource(dev, PNP_IDX_IO0); + struct resource *res = probe_resource(dev, PNP_IDX_IO0); if (!res) { printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n"); diff --git a/src/superio/fintek/f81866d/f81866d_hwm.c b/src/superio/fintek/f81866d/f81866d_hwm.c index a7ed96bb26..a82adb3472 100644 --- a/src/superio/fintek/f81866d/f81866d_hwm.c +++ b/src/superio/fintek/f81866d/f81866d_hwm.c @@ -38,7 +38,7 @@ void f81866d_hwm_init(struct device *dev) { - struct resource *res = find_resource(dev, PNP_IDX_IO0); + struct resource *res = probe_resource(dev, PNP_IDX_IO0); if (!res) { printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n"); diff --git a/src/superio/fintek/f81866d/f81866d_uart.c b/src/superio/fintek/f81866d/f81866d_uart.c index 7d98a7fd2f..f6ebbfcac8 100644 --- a/src/superio/fintek/f81866d/f81866d_uart.c +++ b/src/superio/fintek/f81866d/f81866d_uart.c @@ -19,7 +19,7 @@ */ void f81866d_uart_init(struct device *dev) { - struct resource *res = find_resource(dev, PNP_IDX_IO0); + struct resource *res = probe_resource(dev, PNP_IDX_IO0); u8 tmp; if (!res) { diff --git a/src/superio/ite/it8613e/superio.c b/src/superio/ite/it8613e/superio.c index 4d12457e0d..c18c3ec357 100644 --- a/src/superio/ite/it8613e/superio.c +++ b/src/superio/ite/it8613e/superio.c @@ -19,7 +19,7 @@ static void it8613e_init(struct device *dev) switch (dev->path.pnp.device) { case IT8613E_EC: - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!conf || !res) break; ite_ec_init(res->base, &conf->ec); diff --git a/src/superio/ite/it8623e/superio.c b/src/superio/ite/it8623e/superio.c index ca3455ae1e..15e0071db8 100644 --- a/src/superio/ite/it8623e/superio.c +++ b/src/superio/ite/it8623e/superio.c @@ -19,7 +19,7 @@ static void it8623e_init(struct device *dev) switch (dev->path.pnp.device) { case IT8623E_EC: - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!conf || !res) break; ite_ec_init(res->base, &conf->ec); diff --git a/src/superio/ite/it8718f/superio.c b/src/superio/ite/it8718f/superio.c index aab554fe95..1243e75fcf 100644 --- a/src/superio/ite/it8718f/superio.c +++ b/src/superio/ite/it8718f/superio.c @@ -24,7 +24,7 @@ static void init(struct device *dev) break; case IT8718F_EC: conf = dev->chip_info; - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!conf || !res) break; ite_ec_init(res->base, &conf->ec); diff --git a/src/superio/ite/it8720f/superio.c b/src/superio/ite/it8720f/superio.c index c63fa9ab4f..75d0be9c02 100644 --- a/src/superio/ite/it8720f/superio.c +++ b/src/superio/ite/it8720f/superio.c @@ -51,7 +51,7 @@ static void it8720f_init(struct device *dev) switch (dev->path.pnp.device) { case IT8720F_EC: conf = dev->chip_info; - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!conf || !res) break; ite_ec_init(res->base, &conf->ec); diff --git a/src/superio/ite/it8728f/superio.c b/src/superio/ite/it8728f/superio.c index 22e6ecbf95..67ef2181fd 100644 --- a/src/superio/ite/it8728f/superio.c +++ b/src/superio/ite/it8728f/superio.c @@ -20,7 +20,7 @@ static void it8728f_init(struct device *dev) switch (dev->path.pnp.device) { /* TODO: Might potentially need code for FDC etc. */ case IT8728F_EC: - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!conf || !res) break; ite_ec_init(res->base, &conf->ec); diff --git a/src/superio/ite/it8772f/superio.c b/src/superio/ite/it8772f/superio.c index 6672cdc979..82f30fa6cd 100644 --- a/src/superio/ite/it8772f/superio.c +++ b/src/superio/ite/it8772f/superio.c @@ -171,7 +171,7 @@ static void it8772f_init(struct device *dev) switch (dev->path.pnp.device) { case IT8772F_EC: - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!res) break; @@ -203,7 +203,7 @@ static void it8772f_init(struct device *dev) break; case IT8772F_GPIO: /* Set GPIO output levels */ - res = find_resource(dev, PNP_IDX_IO1); + res = probe_resource(dev, PNP_IDX_IO1); if (res) { if (conf->gpio_set1) outb(conf->gpio_set1, res->base + 0); diff --git a/src/superio/ite/it8783ef/superio.c b/src/superio/ite/it8783ef/superio.c index feb373f709..d90ae5f3b7 100644 --- a/src/superio/ite/it8783ef/superio.c +++ b/src/superio/ite/it8783ef/superio.c @@ -20,7 +20,7 @@ static void it8783ef_init(struct device *const dev) switch (dev->path.pnp.device) { case IT8783EF_EC: conf = dev->chip_info; - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!conf || !res) break; ite_ec_init(res->base, &conf->ec); diff --git a/src/superio/ite/it8786e/superio.c b/src/superio/ite/it8786e/superio.c index 55fff9154d..8d9ec1477e 100644 --- a/src/superio/ite/it8786e/superio.c +++ b/src/superio/ite/it8786e/superio.c @@ -20,7 +20,7 @@ static void it8786e_init(struct device *const dev) switch (dev->path.pnp.device) { case IT8786E_EC: conf = dev->chip_info; - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!conf || !res) break; ite_ec_init(res->base, &conf->ec); diff --git a/src/superio/nuvoton/npcd378/superio.c b/src/superio/nuvoton/npcd378/superio.c index 9889980650..f1db50934a 100644 --- a/src/superio/nuvoton/npcd378/superio.c +++ b/src/superio/nuvoton/npcd378/superio.c @@ -60,7 +60,7 @@ static void npcd378_init(struct device *dev) pc_keyboard_init(PROBE_AUX_DEVICE); break; case NPCD378_HWM: - res = find_resource(dev, PNP_IDX_IO0); + res = probe_resource(dev, PNP_IDX_IO0); if (!res || !res->base) { printk(BIOS_ERR, "NPCD378: LDN%u IOBASE not set.\n", NPCD378_HWM); break; -- cgit v1.2.3