netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse
@ 2023-04-06 17:30 Simon Horman
  2023-04-06 17:30 ` [PATCH net-next 1/2] net: stmmac: dwmac-anarion: Use annotation __iomem for register base Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Simon Horman @ 2023-04-06 17:30 UTC (permalink / raw)
  To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, Maxime Coquelin,
	netdev, linux-stm32, linux-arm-kernel

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/2] net: stmmac: dwmac-anarion: Use annotation __iomem for register base
  2023-04-06 17:30 [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse Simon Horman
@ 2023-04-06 17:30 ` Simon Horman
  2023-04-06 17:30 ` [PATCH net-next 2/2] net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt() Simon Horman
  2023-04-08  3:10 ` [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-04-06 17:30 UTC (permalink / raw)
  To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, Maxime Coquelin,
	netdev, linux-stm32, linux-arm-kernel

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.

Signed-off-by: Simon Horman <horms@kernel.org>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
index dfbaea06d108..2357e77434fb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
@@ -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)

-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt()
  2023-04-06 17:30 [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse Simon Horman
  2023-04-06 17:30 ` [PATCH net-next 1/2] net: stmmac: dwmac-anarion: Use annotation __iomem for register base Simon Horman
@ 2023-04-06 17:30 ` Simon Horman
  2023-04-08  3:10 ` [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-04-06 17:30 UTC (permalink / raw)
  To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, Maxime Coquelin,
	netdev, linux-stm32, linux-arm-kernel

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>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
index 2357e77434fb..9354bf419112 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
@@ -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);

-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse
  2023-04-06 17:30 [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse Simon Horman
  2023-04-06 17:30 ` [PATCH net-next 1/2] net: stmmac: dwmac-anarion: Use annotation __iomem for register base Simon Horman
  2023-04-06 17:30 ` [PATCH net-next 2/2] net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt() Simon Horman
@ 2023-04-08  3:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-08  3:10 UTC (permalink / raw)
  To: Simon Horman
  Cc: kuba, davem, edumazet, pabeni, peppe.cavallaro, alexandre.torgue,
	joabreu, mcoquelin.stm32, netdev, linux-stm32, linux-arm-kernel

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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 * from anarion_config_dt()
> 2. Add __iomem annotation to register base
> 
> No 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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-08  3:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 17:30 [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse Simon Horman
2023-04-06 17:30 ` [PATCH net-next 1/2] net: stmmac: dwmac-anarion: Use annotation __iomem for register base Simon Horman
2023-04-06 17:30 ` [PATCH net-next 2/2] net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt() Simon Horman
2023-04-08  3:10 ` [PATCH net-next 0/2] net: stmmac: dwmac-anarion: address issues flagged by sparse patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).