Skip to content

Commit 8f71d72

Browse files
committed
phy: apple: apple: Use local variable for ioremap return value
The indirection through the resources array is unnecessarily complicated and resuling in using IS_ERR() and PTR_ERR() on a valid address. A local variable for the devm_ioremap_resource() return value is both easier to read and matches expectations when reading code. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/asahi/aYXvX1bYOXtYCgfC@stanley.mountain/ Suggested-by: Vladimir Oltean <olteanv@gmail.com> Fixes: 8e98ca1 ("phy: apple: Add Apple Type-C PHY") Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 45be7f0 commit 8f71d72

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/phy/apple/atc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,14 +2202,16 @@ static int atcphy_map_resources(struct platform_device *pdev, struct apple_atcph
22022202
{ "pipehandler", &atcphy->regs.pipehandler, NULL },
22032203
};
22042204
struct resource *res;
2205+
void __iomem *addr;
22052206

22062207
for (int i = 0; i < ARRAY_SIZE(resources); i++) {
22072208
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, resources[i].name);
2208-
*resources[i].addr = devm_ioremap_resource(&pdev->dev, res);
2209-
if (IS_ERR(resources[i].addr))
2210-
return dev_err_probe(atcphy->dev, PTR_ERR(resources[i].addr),
2209+
addr = devm_ioremap_resource(&pdev->dev, res);
2210+
if (IS_ERR(addr))
2211+
return dev_err_probe(atcphy->dev, PTR_ERR(addr),
22112212
"Unable to map %s regs", resources[i].name);
22122213

2214+
*resources[i].addr = addr;
22132215
if (resources[i].res)
22142216
*resources[i].res = res;
22152217
}

0 commit comments

Comments
 (0)