Commit 93b31f48 authored by Cyrille Pitchen's avatar Cyrille Pitchen Committed by David S. Miller

net/macb: unify clock management

Most of the functions from the Common Clk Framework handle NULL pointer as
input argument.

Since the TX clock is optional, we now set tx_clk to NULL value
instead of ERR_PTR(-ENOENT) when this clock is not available. This simplifies
the clock management and avoid the need to test tx_clk value.
Signed-off-by: default avatarCyrille Pitchen <cyrille.pitchen@atmel.com>
Acked-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a8487489
......@@ -213,6 +213,9 @@ static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
{
long ferr, rate, rate_rounded;
if (!clk)
return;
switch (speed) {
case SPEED_10:
rate = 2500000;
......@@ -292,7 +295,6 @@ static void macb_handle_link_change(struct net_device *dev)
spin_unlock_irqrestore(&bp->lock, flags);
if (!IS_ERR(bp->tx_clk))
macb_set_tx_clk(bp->tx_clk, phydev->speed, dev);
if (status_change) {
......@@ -2264,6 +2266,8 @@ static int macb_probe(struct platform_device *pdev)
}
tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
if (IS_ERR(tx_clk))
tx_clk = NULL;
err = clk_prepare_enable(pclk);
if (err) {
......@@ -2277,14 +2281,11 @@ static int macb_probe(struct platform_device *pdev)
goto err_out_disable_pclk;
}
if (!IS_ERR(tx_clk)) {
err = clk_prepare_enable(tx_clk);
if (err) {
dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n",
err);
dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n", err);
goto err_out_disable_hclk;
}
}
err = -ENOMEM;
mem = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
......@@ -2455,7 +2456,6 @@ static int macb_probe(struct platform_device *pdev)
err_out_free_netdev:
free_netdev(dev);
err_out_disable_clocks:
if (!IS_ERR(tx_clk))
clk_disable_unprepare(tx_clk);
err_out_disable_hclk:
clk_disable_unprepare(hclk);
......@@ -2480,7 +2480,6 @@ static int macb_remove(struct platform_device *pdev)
kfree(bp->mii_bus->irq);
mdiobus_free(bp->mii_bus);
unregister_netdev(dev);
if (!IS_ERR(bp->tx_clk))
clk_disable_unprepare(bp->tx_clk);
clk_disable_unprepare(bp->hclk);
clk_disable_unprepare(bp->pclk);
......@@ -2499,7 +2498,6 @@ static int __maybe_unused macb_suspend(struct device *dev)
netif_carrier_off(netdev);
netif_device_detach(netdev);
if (!IS_ERR(bp->tx_clk))
clk_disable_unprepare(bp->tx_clk);
clk_disable_unprepare(bp->hclk);
clk_disable_unprepare(bp->pclk);
......@@ -2515,7 +2513,6 @@ static int __maybe_unused macb_resume(struct device *dev)
clk_prepare_enable(bp->pclk);
clk_prepare_enable(bp->hclk);
if (!IS_ERR(bp->tx_clk))
clk_prepare_enable(bp->tx_clk);
netif_device_attach(netdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment