diff mbox series

[v2] net: mdio-ipq4019: Fix the error for an optional regs resource

Message ID 20210928134849.2092-1-caihuoqing@baidu.com (mailing list archive)
State Accepted
Commit 9e28cfead2f8f5aba7df03c74c9ec645b5ffc5fd
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: mdio-ipq4019: Fix the error for an optional regs resource | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Cai,Huoqing Sept. 28, 2021, 1:48 p.m. UTC
The second resource is optional which is only provided on the chipset
IPQ5018. But the blamed commit ignores that and if the resource is
not there it just fails.

the resource is used like this,
	if (priv->eth_ldo_rdy) {
		val = readl(priv->eth_ldo_rdy);
		val |= BIT(0);
		writel(val, priv->eth_ldo_rdy);
		fsleep(IPQ_PHY_SET_DELAY_US);
	}

This patch reverts that to still allow the second resource to be optional
because other SoC have the some MDIO controller and doesn't need to
second resource.

Fixes: fa14d03e014a ("net: mdio-ipq4019: Make use of devm_platform_ioremap_resource()")
Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
v1->v2: Update the fixes tag.

 drivers/net/mdio/mdio-ipq4019.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Sept. 28, 2021, 3:26 p.m. UTC | #1
On Tue, Sep 28, 2021 at 09:48:49PM +0800, Cai Huoqing wrote:
> The second resource is optional which is only provided on the chipset
> IPQ5018. But the blamed commit ignores that and if the resource is
> not there it just fails.
> 
> the resource is used like this,
> 	if (priv->eth_ldo_rdy) {
> 		val = readl(priv->eth_ldo_rdy);
> 		val |= BIT(0);
> 		writel(val, priv->eth_ldo_rdy);
> 		fsleep(IPQ_PHY_SET_DELAY_US);
> 	}
> 
> This patch reverts that to still allow the second resource to be optional
> because other SoC have the some MDIO controller and doesn't need to
> second resource.
> 
> Fixes: fa14d03e014a ("net: mdio-ipq4019: Make use of devm_platform_ioremap_resource()")
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>

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

    Andrew
patchwork-bot+netdevbpf@kernel.org Sept. 29, 2021, 2:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue, 28 Sep 2021 21:48:49 +0800 you wrote:
> The second resource is optional which is only provided on the chipset
> IPQ5018. But the blamed commit ignores that and if the resource is
> not there it just fails.
> 
> the resource is used like this,
> 	if (priv->eth_ldo_rdy) {
> 		val = readl(priv->eth_ldo_rdy);
> 		val |= BIT(0);
> 		writel(val, priv->eth_ldo_rdy);
> 		fsleep(IPQ_PHY_SET_DELAY_US);
> 	}
> 
> [...]

Here is the summary with links:
  - [v2] net: mdio-ipq4019: Fix the error for an optional regs resource
    https://git.kernel.org/netdev/net/c/9e28cfead2f8

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c
index 0d7d3e15d2f0..5f4cd24a0241 100644
--- a/drivers/net/mdio/mdio-ipq4019.c
+++ b/drivers/net/mdio/mdio-ipq4019.c
@@ -207,6 +207,7 @@  static int ipq4019_mdio_probe(struct platform_device *pdev)
 {
 	struct ipq4019_mdio_data *priv;
 	struct mii_bus *bus;
+	struct resource *res;
 	int ret;
 
 	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
@@ -224,7 +225,10 @@  static int ipq4019_mdio_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->mdio_clk);
 
 	/* The platform resource is provided on the chipset IPQ5018 */
-	priv->eth_ldo_rdy = devm_platform_ioremap_resource(pdev, 1);
+	/* This resource is optional */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res)
+		priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res);
 
 	bus->name = "ipq4019_mdio";
 	bus->read = ipq4019_mdio_read;