Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 8e98ca1e74db ("phy: apple: Add Apple Type-C PHY")
Signed-off-by: Janne Grunau <j@jannau.net>
Reviewed-by: Sven Peter <sven@kernel.org>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://patch.msgid.link/20260215-phy-apple-resource-err-ptr-v2-1-e43c22453682@jannau.net
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Janne Grunau and committed by
Vinod Koul
290a3575 b6b7d1ae

+5 -3
+5 -3
drivers/phy/apple/atc.c
··· 2202 2202 { "pipehandler", &atcphy->regs.pipehandler, NULL }, 2203 2203 }; 2204 2204 struct resource *res; 2205 + void __iomem *addr; 2205 2206 2206 2207 for (int i = 0; i < ARRAY_SIZE(resources); i++) { 2207 2208 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), 2211 2212 "Unable to map %s regs", resources[i].name); 2212 2213 2214 + *resources[i].addr = addr; 2213 2215 if (resources[i].res) 2214 2216 *resources[i].res = res; 2215 2217 }