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 <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58909
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
This commit is contained in:
Angel Pons
2021-11-03 13:25:02 +01:00
committed by Felix Held
parent e058841913
commit c167b74868
13 changed files with 14 additions and 14 deletions

View File

@@ -35,7 +35,7 @@
void f71808a_hwm_init(struct device *dev) 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) { if (!res) {
printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n"); printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n");

View File

@@ -41,7 +41,7 @@
void f71869ad_hwm_init(struct device *dev) void f71869ad_hwm_init(struct device *dev)
{ {
const struct superio_fintek_f71869ad_config *conf = dev->chip_info; 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) { if (!res) {
printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n"); printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n");

View File

@@ -38,7 +38,7 @@
void f81866d_hwm_init(struct device *dev) 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) { if (!res) {
printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n"); printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n");

View File

@@ -19,7 +19,7 @@
*/ */
void f81866d_uart_init(struct device *dev) 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; u8 tmp;
if (!res) { if (!res) {

View File

@@ -19,7 +19,7 @@ static void it8613e_init(struct device *dev)
switch (dev->path.pnp.device) { switch (dev->path.pnp.device) {
case IT8613E_EC: case IT8613E_EC:
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!conf || !res) if (!conf || !res)
break; break;
ite_ec_init(res->base, &conf->ec); ite_ec_init(res->base, &conf->ec);

View File

@@ -19,7 +19,7 @@ static void it8623e_init(struct device *dev)
switch (dev->path.pnp.device) { switch (dev->path.pnp.device) {
case IT8623E_EC: case IT8623E_EC:
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!conf || !res) if (!conf || !res)
break; break;
ite_ec_init(res->base, &conf->ec); ite_ec_init(res->base, &conf->ec);

View File

@@ -24,7 +24,7 @@ static void init(struct device *dev)
break; break;
case IT8718F_EC: case IT8718F_EC:
conf = dev->chip_info; conf = dev->chip_info;
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!conf || !res) if (!conf || !res)
break; break;
ite_ec_init(res->base, &conf->ec); ite_ec_init(res->base, &conf->ec);

View File

@@ -51,7 +51,7 @@ static void it8720f_init(struct device *dev)
switch (dev->path.pnp.device) { switch (dev->path.pnp.device) {
case IT8720F_EC: case IT8720F_EC:
conf = dev->chip_info; conf = dev->chip_info;
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!conf || !res) if (!conf || !res)
break; break;
ite_ec_init(res->base, &conf->ec); ite_ec_init(res->base, &conf->ec);

View File

@@ -20,7 +20,7 @@ static void it8728f_init(struct device *dev)
switch (dev->path.pnp.device) { switch (dev->path.pnp.device) {
/* TODO: Might potentially need code for FDC etc. */ /* TODO: Might potentially need code for FDC etc. */
case IT8728F_EC: case IT8728F_EC:
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!conf || !res) if (!conf || !res)
break; break;
ite_ec_init(res->base, &conf->ec); ite_ec_init(res->base, &conf->ec);

View File

@@ -171,7 +171,7 @@ static void it8772f_init(struct device *dev)
switch (dev->path.pnp.device) { switch (dev->path.pnp.device) {
case IT8772F_EC: case IT8772F_EC:
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!res) if (!res)
break; break;
@@ -203,7 +203,7 @@ static void it8772f_init(struct device *dev)
break; break;
case IT8772F_GPIO: case IT8772F_GPIO:
/* Set GPIO output levels */ /* Set GPIO output levels */
res = find_resource(dev, PNP_IDX_IO1); res = probe_resource(dev, PNP_IDX_IO1);
if (res) { if (res) {
if (conf->gpio_set1) if (conf->gpio_set1)
outb(conf->gpio_set1, res->base + 0); outb(conf->gpio_set1, res->base + 0);

View File

@@ -20,7 +20,7 @@ static void it8783ef_init(struct device *const dev)
switch (dev->path.pnp.device) { switch (dev->path.pnp.device) {
case IT8783EF_EC: case IT8783EF_EC:
conf = dev->chip_info; conf = dev->chip_info;
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!conf || !res) if (!conf || !res)
break; break;
ite_ec_init(res->base, &conf->ec); ite_ec_init(res->base, &conf->ec);

View File

@@ -20,7 +20,7 @@ static void it8786e_init(struct device *const dev)
switch (dev->path.pnp.device) { switch (dev->path.pnp.device) {
case IT8786E_EC: case IT8786E_EC:
conf = dev->chip_info; conf = dev->chip_info;
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!conf || !res) if (!conf || !res)
break; break;
ite_ec_init(res->base, &conf->ec); ite_ec_init(res->base, &conf->ec);

View File

@@ -60,7 +60,7 @@ static void npcd378_init(struct device *dev)
pc_keyboard_init(PROBE_AUX_DEVICE); pc_keyboard_init(PROBE_AUX_DEVICE);
break; break;
case NPCD378_HWM: case NPCD378_HWM:
res = find_resource(dev, PNP_IDX_IO0); res = probe_resource(dev, PNP_IDX_IO0);
if (!res || !res->base) { if (!res || !res->base) {
printk(BIOS_ERR, "NPCD378: LDN%u IOBASE not set.\n", NPCD378_HWM); printk(BIOS_ERR, "NPCD378: LDN%u IOBASE not set.\n", NPCD378_HWM);
break; break;