net: stmmac: dwmac-anarion: address issues flagged by sparse
Subsystems (4)
Simon Horman
reviewercover net: stmmac: dwmac-anarion: address issues flagged by sparse
Two minor enhancements to dwmac-anarion to address issues flagged by sparse.
1. Always return struct anarion_gmac * from anarion_config_dt()
2. Add __iomem annotation to register base
No functional change intended.
Compile tested only.
---
Simon Horman (2):
net: stmmac: dwmac-anarion: Use annotation __iomem for register base
net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt()
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
base-commit: 0ebd4fd6b9064764a3af3d671463b1350abffb6c
Simon Horman
reviewerPATCH 1/2 net: stmmac: dwmac-anarion: Use annotation __iomem for register base
Use __iomem annotation the register base: the ctl_block field of struct anarion_gmac. I believe this is the normal practice for such variables.
By doing so some casting is avoided.
And sparse no longer reports:
.../dwmac-anarion.c:29:23: warning: incorrect type in argument 1 (different address spaces)
.../dwmac-anarion.c:29:23: expected void const volatile [noderef] __iomem *addr
.../dwmac-anarion.c:29:23: got void *
.../dwmac-anarion.c:34:22: warning: incorrect type in argument 2 (different address spaces)
.../dwmac-anarion.c:34:22: expected void volatile [noderef] __iomem *addr
.../dwmac-anarion.c:34:22: got void *
No functional change intended.
Compile tested only.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c +4 -4
@@ -20,18 +20,18 @@#define GMAC_CONFIG_INTF_RGMII (0x1 << 0)struct anarion_gmac { -uintptr_t ctl_block; +void __iomem *ctl_block;uint32_t phy_intf_sel; };static uint32_t gmac_read_reg (struct anarion_gmac *gmac,uint8_t reg) { -return readl ((void *)(gmac->ctl_block + reg)); +return readl (gmac->ctl_block + reg); };static void gmac_write_reg (struct anarion_gmac *gmac,uint8_t reg,uint32_t val) { -writel (val, (void *)(gmac->ctl_block + reg)); +writel (val, gmac->ctl_block + reg); }static int anarion_gmac_init (struct platform_device *pdev,void *priv)
@@ -77,7 +77,7 @@ static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev)if (!gmac)return ERR_PTR (-ENOMEM ); - gmac->ctl_block = (uintptr_t )ctl_block; + gmac->ctl_block = ctl_block; err =of_get_phy_mode (pdev->dev.of_node, &phy_mode);if (err)
Signature · 1 line
2.30.2
Simon Horman
reviewerPATCH 2/2 net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt()
In reply to Simon HormanAlways 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.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c +3 -3
@@ -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 );
Signature · 1 line
2.30.2
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 06 Apr 2023 19:30:08 +0200 you wrote:
Two minor enhancements to dwmac-anarion to address issues flagged by sparse.
1. Always return struct
anarion_gmac* fromanarion_config_dt()
2. Add__iomemannotation to register baseNo functional change intended.
Compile tested only.[...]
Here is the summary with links:
- [net-next,1/2] net: stmmac: dwmac-anarion: Use annotation __iomem for register base
https://git.kernel.org/netdev/net-next/c/9f12541d684b - [net-next,2/2] net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt() https://git.kernel.org/netdev/net-next/c/51fe084b17e7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html