Commit bd310aca authored by Michael Tretter's avatar Michael Tretter Committed by David S. Miller

macb: propagate errors when getting optional clocks

The tx_clk, rx_clk, and tsu_clk are optional. Currently the macb driver
marks clock as not available if it receives an error when trying to get
a clock. This is wrong, because a clock controller might return
-EPROBE_DEFER if a clock is not available, but will eventually become
available.

In these cases, the driver would probe successfully but will never be
able to adjust the clocks, because the clocks were not available during
probe, but became available later.

For example, the clock controller for the ZynqMP is implemented in the
PMU firmware and the clocks are only available after the firmware driver
has been probed.

Use devm_clk_get_optional() in instead of devm_clk_get() to get the
optional clock and propagate all errors to the calling function.
Signed-off-by: default avatarMichael Tretter <m.tretter@pengutronix.de>
Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
Tested-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3d5c1a03
......@@ -3405,17 +3405,17 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
return err;
}
*tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
*tx_clk = devm_clk_get_optional(&pdev->dev, "tx_clk");
if (IS_ERR(*tx_clk))
*tx_clk = NULL;
return PTR_ERR(*tx_clk);
*rx_clk = devm_clk_get(&pdev->dev, "rx_clk");
*rx_clk = devm_clk_get_optional(&pdev->dev, "rx_clk");
if (IS_ERR(*rx_clk))
*rx_clk = NULL;
return PTR_ERR(*rx_clk);
*tsu_clk = devm_clk_get(&pdev->dev, "tsu_clk");
*tsu_clk = devm_clk_get_optional(&pdev->dev, "tsu_clk");
if (IS_ERR(*tsu_clk))
*tsu_clk = NULL;
return PTR_ERR(*tsu_clk);
err = clk_prepare_enable(*pclk);
if (err) {
......
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