diff mbox series

[net] Revert "net: ethernet: bgmac: Use devm_platform_ioremap_resource_byname"

Message ID 20220216184634.2032460-1-f.fainelli@gmail.com (mailing list archive)
State Accepted
Commit 6aba04ee3263669b335458c4cf4c7d97d6940229
Delegated to: Netdev Maintainers
Headers show
Series [net] Revert "net: ethernet: bgmac: Use devm_platform_ioremap_resource_byname" | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Florian Fainelli Feb. 16, 2022, 6:46 p.m. UTC
From: Jonas Gorski <jonas.gorski@gmail.com>

This reverts commit 3710e80952cf2dc48257ac9f145b117b5f74e0a5.

Since idm_base and nicpm_base are still optional resources not present
on all platforms, this breaks the driver for everything except Northstar
2 (which has both).

The same change was already reverted once with 755f5738ff98 ("net:
broadcom: fix a mistake about ioremap resource").

So let's do it again.

Fixes: 3710e80952cf ("net: ethernet: bgmac: Use devm_platform_ioremap_resource_byname")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
[florian: Added comments to explain the resources are optional]
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 .../net/ethernet/broadcom/bgmac-platform.c    | 23 +++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)

Comments

Andrew Lunn Feb. 16, 2022, 7:01 p.m. UTC | #1
On Wed, Feb 16, 2022 at 10:46:34AM -0800, Florian Fainelli wrote:
> From: Jonas Gorski <jonas.gorski@gmail.com>
> 
> This reverts commit 3710e80952cf2dc48257ac9f145b117b5f74e0a5.
> 
> Since idm_base and nicpm_base are still optional resources not present
> on all platforms, this breaks the driver for everything except Northstar
> 2 (which has both).
> 
> The same change was already reverted once with 755f5738ff98 ("net:
> broadcom: fix a mistake about ioremap resource").
> 
> So let's do it again.
> 
> -	bgmac->plat.idm_base = devm_platform_ioremap_resource_byname(pdev, "idm_base");
> -	if (IS_ERR(bgmac->plat.idm_base))
> -		return PTR_ERR(bgmac->plat.idm_base);
> -	else
> +	/* The idm_base resource is optional for some platforms */

I see you are adding a comment. Good idea. Lets see if the bot
handlers are clever enough to actually read it, or just blindly do
what the bot says to do, without actually trying to understand the
code.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
patchwork-bot+netdevbpf@kernel.org Feb. 17, 2022, 5 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 16 Feb 2022 10:46:34 -0800 you wrote:
> From: Jonas Gorski <jonas.gorski@gmail.com>
> 
> This reverts commit 3710e80952cf2dc48257ac9f145b117b5f74e0a5.
> 
> Since idm_base and nicpm_base are still optional resources not present
> on all platforms, this breaks the driver for everything except Northstar
> 2 (which has both).
> 
> [...]

Here is the summary with links:
  - [net] Revert "net: ethernet: bgmac: Use devm_platform_ioremap_resource_byname"
    https://git.kernel.org/netdev/net/c/6aba04ee3263

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bgmac-platform.c b/drivers/net/ethernet/broadcom/bgmac-platform.c
index c6412c523637..b4381cd41979 100644
--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
+++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
@@ -172,6 +172,7 @@  static int bgmac_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct bgmac *bgmac;
+	struct resource *regs;
 	int ret;
 
 	bgmac = bgmac_alloc(&pdev->dev);
@@ -208,15 +209,23 @@  static int bgmac_probe(struct platform_device *pdev)
 	if (IS_ERR(bgmac->plat.base))
 		return PTR_ERR(bgmac->plat.base);
 
-	bgmac->plat.idm_base = devm_platform_ioremap_resource_byname(pdev, "idm_base");
-	if (IS_ERR(bgmac->plat.idm_base))
-		return PTR_ERR(bgmac->plat.idm_base);
-	else
+	/* The idm_base resource is optional for some platforms */
+	regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base");
+	if (regs) {
+		bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
+		if (IS_ERR(bgmac->plat.idm_base))
+			return PTR_ERR(bgmac->plat.idm_base);
 		bgmac->feature_flags &= ~BGMAC_FEAT_IDM_MASK;
+	}
 
-	bgmac->plat.nicpm_base = devm_platform_ioremap_resource_byname(pdev, "nicpm_base");
-	if (IS_ERR(bgmac->plat.nicpm_base))
-		return PTR_ERR(bgmac->plat.nicpm_base);
+	/* The nicpm_base resource is optional for some platforms */
+	regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base");
+	if (regs) {
+		bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev,
+							       regs);
+		if (IS_ERR(bgmac->plat.nicpm_base))
+			return PTR_ERR(bgmac->plat.nicpm_base);
+	}
 
 	bgmac->read = platform_bgmac_read;
 	bgmac->write = platform_bgmac_write;