net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt()
authorSimon Horman <horms@kernel.org>
Thu, 6 Apr 2023 17:30:10 +0000 (19:30 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 8 Apr 2023 03:06:04 +0000 (20:06 -0700)
Always return struct anarion_gmac * from anarion_config_dt().
In the case where ctl_block was an error pointer it was being
returned directly. Which sparse flags as follows:

 .../dwmac-anarion.c:73:24: warning: incorrect type in return expression (different address spaces)
 .../dwmac-anarion.c:73:24:    expected struct anarion_gmac *
 .../dwmac-anarion.c:73:24:    got void [noderef] __iomem *[assigned] ctl_block

Avoid this by converting the error pointer to an error.
And then reversing the conversion.

As a side effect, the error can be used for logging purposes,
subjectively, leading to a minor cleanup.

No functional change intended.
Compile tested only.

Signed-off-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c

index 2357e77..9354bf4 100644 (file)
@@ -68,9 +68,9 @@ static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev)
 
        ctl_block = devm_platform_ioremap_resource(pdev, 1);
        if (IS_ERR(ctl_block)) {
-               dev_err(&pdev->dev, "Cannot get reset region (%ld)!\n",
-                       PTR_ERR(ctl_block));
-               return ctl_block;
+               err = PTR_ERR(ctl_block);
+               dev_err(&pdev->dev, "Cannot get reset region (%d)!\n", err);
+               return ERR_PTR(err);
        }
 
        gmac = devm_kzalloc(&pdev->dev, sizeof(*gmac), GFP_KERNEL);