* [PATCH phy-next v2] phy: apple: apple: Use local variable for ioremap return value
@ 2026-02-15 8:02 Janne Grunau
2026-02-15 12:07 ` Sven Peter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Janne Grunau @ 2026-02-15 8:02 UTC (permalink / raw)
To: Sven Peter, Neal Gompa, Vinod Koul, Neil Armstrong, Philipp Zabel
Cc: asahi, linux-phy, linux-kernel, linux-arm-kernel, Dan Carpenter,
Vladimir Oltean, Janne Grunau
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>
---
Changes in v2:
- Use a local variable instead of the complex indirection with the
resources array
- Link to v1: https://lore.kernel.org/r/20260207-phy-apple-resource-err-ptr-v1-1-78735b07ed2d@jannau.net
---
drivers/phy/apple/atc.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c
index dc867f368b68748ea953e594ad998d7f965d8d1d..64d0c3dba1cbb95f867d338da706225ee0bf79f7 100644
--- a/drivers/phy/apple/atc.c
+++ b/drivers/phy/apple/atc.c
@@ -2202,14 +2202,16 @@ static int atcphy_map_resources(struct platform_device *pdev, struct apple_atcph
{ "pipehandler", &atcphy->regs.pipehandler, NULL },
};
struct resource *res;
+ void __iomem *addr;
for (int i = 0; i < ARRAY_SIZE(resources); i++) {
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, resources[i].name);
- *resources[i].addr = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(resources[i].addr))
- return dev_err_probe(atcphy->dev, PTR_ERR(resources[i].addr),
+ addr = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(addr))
+ return dev_err_probe(atcphy->dev, PTR_ERR(addr),
"Unable to map %s regs", resources[i].name);
+ *resources[i].addr = addr;
if (resources[i].res)
*resources[i].res = res;
}
---
base-commit: dbeea86fecef7cf2b93aded4525d74f6277376ef
change-id: 20260207-phy-apple-resource-err-ptr-5923d1130465
Best regards,
--
Janne Grunau <j@jannau.net>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH phy-next v2] phy: apple: apple: Use local variable for ioremap return value
2026-02-15 8:02 [PATCH phy-next v2] phy: apple: apple: Use local variable for ioremap return value Janne Grunau
@ 2026-02-15 12:07 ` Sven Peter
2026-02-16 9:04 ` Vladimir Oltean
2026-02-27 15:29 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Sven Peter @ 2026-02-15 12:07 UTC (permalink / raw)
To: Janne Grunau, Neal Gompa, Vinod Koul, Neil Armstrong,
Philipp Zabel
Cc: asahi, linux-phy, linux-kernel, linux-arm-kernel, Dan Carpenter,
Vladimir Oltean
On 15.02.26 09:02, Janne Grunau wrote:
> 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>
> Changes in v2:
> - Use a local variable instead of the complex indirection with the
> resources array
> - Link to v1: https://lore.kernel.org/r/20260207-phy-apple-resource-err-ptr-v1-1-78735b07ed2d@jannau.net
> ---
> drivers/phy/apple/atc.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c
> index dc867f368b68748ea953e594ad998d7f965d8d1d..64d0c3dba1cbb95f867d338da706225ee0bf79f7 100644
> --- a/drivers/phy/apple/atc.c
> +++ b/drivers/phy/apple/atc.c
> @@ -2202,14 +2202,16 @@ static int atcphy_map_resources(struct platform_device *pdev, struct apple_atcph
> { "pipehandler", &atcphy->regs.pipehandler, NULL },
> };
> struct resource *res;
> + void __iomem *addr;
>
> for (int i = 0; i < ARRAY_SIZE(resources); i++) {
> res = platform_get_resource_byname(pdev, IORESOURCE_MEM, resources[i].name);
> - *resources[i].addr = devm_ioremap_resource(&pdev->dev, res);
> - if (IS_ERR(resources[i].addr))
> - return dev_err_probe(atcphy->dev, PTR_ERR(resources[i].addr),
> + addr = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(addr))
> + return dev_err_probe(atcphy->dev, PTR_ERR(addr),
> "Unable to map %s regs", resources[i].name);
>
> + *resources[i].addr = addr;
This is much easier to understand. I missed return PTR_ERR(..) error in
the first version and introduced it originally due to the indirection as
well.
Best,
Sven
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH phy-next v2] phy: apple: apple: Use local variable for ioremap return value
2026-02-15 8:02 [PATCH phy-next v2] phy: apple: apple: Use local variable for ioremap return value Janne Grunau
2026-02-15 12:07 ` Sven Peter
@ 2026-02-16 9:04 ` Vladimir Oltean
2026-02-27 15:29 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2026-02-16 9:04 UTC (permalink / raw)
To: Janne Grunau
Cc: Sven Peter, Neal Gompa, Vinod Koul, Neil Armstrong, Philipp Zabel,
asahi, linux-phy, linux-kernel, linux-arm-kernel, Dan Carpenter
On Sun, Feb 15, 2026 at 09:02:51AM +0100, Janne Grunau wrote:
> 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>
> ---
> Changes in v2:
> - Use a local variable instead of the complex indirection with the
> resources array
> - Link to v1: https://lore.kernel.org/r/20260207-phy-apple-resource-err-ptr-v1-1-78735b07ed2d@jannau.net
> ---
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
I hope this can be picked up for the linux-phy PR.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH phy-next v2] phy: apple: apple: Use local variable for ioremap return value
2026-02-15 8:02 [PATCH phy-next v2] phy: apple: apple: Use local variable for ioremap return value Janne Grunau
2026-02-15 12:07 ` Sven Peter
2026-02-16 9:04 ` Vladimir Oltean
@ 2026-02-27 15:29 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2026-02-27 15:29 UTC (permalink / raw)
To: Sven Peter, Neal Gompa, Neil Armstrong, Philipp Zabel,
Janne Grunau
Cc: asahi, linux-phy, linux-kernel, linux-arm-kernel, Dan Carpenter,
Vladimir Oltean
On Sun, 15 Feb 2026 09:02:51 +0100, Janne Grunau wrote:
> 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.
>
>
Applied, thanks!
[1/1] phy: apple: apple: Use local variable for ioremap return value
commit: 290a35756aaef85bbe0527eaf451f533a61b5f6c
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-27 15:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-15 8:02 [PATCH phy-next v2] phy: apple: apple: Use local variable for ioremap return value Janne Grunau
2026-02-15 12:07 ` Sven Peter
2026-02-16 9:04 ` Vladimir Oltean
2026-02-27 15:29 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox