All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net: mdio-ipq4019: Fix the error for an optional regs resource
@ 2021-09-28 13:48 Cai Huoqing
  2021-09-28 15:26 ` Andrew Lunn
  2021-09-29  2:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Cai Huoqing @ 2021-09-28 13:48 UTC (permalink / raw)
  To: andrew, horatiu.vultur, hkallweit1, linux, davem, kuba
  Cc: netdev, linux-kernel, Cai Huoqing

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(-)

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;
-- 
2.25.1


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

* Re: [PATCH v2] net: mdio-ipq4019: Fix the error for an optional regs resource
  2021-09-28 13:48 [PATCH v2] net: mdio-ipq4019: Fix the error for an optional regs resource Cai Huoqing
@ 2021-09-28 15:26 ` Andrew Lunn
  2021-09-29  2:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2021-09-28 15:26 UTC (permalink / raw)
  To: Cai Huoqing
  Cc: horatiu.vultur, hkallweit1, linux, davem, kuba, netdev, linux-kernel

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

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

* Re: [PATCH v2] net: mdio-ipq4019: Fix the error for an optional regs resource
  2021-09-28 13:48 [PATCH v2] net: mdio-ipq4019: Fix the error for an optional regs resource Cai Huoqing
  2021-09-28 15:26 ` Andrew Lunn
@ 2021-09-29  2:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-09-29  2:40 UTC (permalink / raw)
  To: Cai Huoqing
  Cc: andrew, horatiu.vultur, hkallweit1, linux, davem, kuba, netdev,
	linux-kernel

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



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

end of thread, other threads:[~2021-09-29  2:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 13:48 [PATCH v2] net: mdio-ipq4019: Fix the error for an optional regs resource Cai Huoqing
2021-09-28 15:26 ` Andrew Lunn
2021-09-29  2:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.