Check the return value of dev_remap_addr() for NULL instead of
IS_ERR(). This function only ever returns NULL on failure.

Add <errno.h>, since this is the first error code used directly
in this file.

Fixes: 6b5c8d98e204 ("net: add hifemac_mdio MDIO bus driver for HiSilicon 
platform")
Signed-off-by: David Lechner <[email protected]>
---
 drivers/net/hifemac_mdio.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hifemac_mdio.c b/drivers/net/hifemac_mdio.c
index 0b59d060917..6d30ad2031c 100644
--- a/drivers/net/hifemac_mdio.c
+++ b/drivers/net/hifemac_mdio.c
@@ -7,6 +7,7 @@
 
 #include <dm.h>
 #include <clk.h>
+#include <errno.h>
 #include <miiphy.h>
 #include <dm/device_compat.h>
 #include <linux/io.h>
@@ -70,13 +71,11 @@ static int hisi_femac_mdio_write(struct udevice *dev, int 
addr, int devad, int r
 static int hisi_femac_mdio_of_to_plat(struct udevice *dev)
 {
        struct hisi_femac_mdio_data *data = dev_get_priv(dev);
-       int ret;
 
        data->membase = dev_remap_addr(dev);
-       if (IS_ERR(data->membase)) {
-               ret = PTR_ERR(data->membase);
-               dev_err(dev, "Failed to remap base addr %d\n", ret);
-               return log_msg_ret("mdio", ret);
+       if (!data->membase) {
+               dev_err(dev, "Failed to remap base addr\n");
+               return log_msg_ret("mdio", -EINVAL);
        }
 
        // clk is optional

-- 
2.43.0

Reply via email to