Skip to content

Commit bd310ac

Browse files
tretterdavem330
authored andcommitted
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: Michael Tretter <[email protected]> Acked-by: Nicolas Ferre <[email protected]> Tested-by: Nicolas Ferre <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3d5c1a0 commit bd310ac

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,17 +3405,17 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
34053405
return err;
34063406
}
34073407

3408-
*tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
3408+
*tx_clk = devm_clk_get_optional(&pdev->dev, "tx_clk");
34093409
if (IS_ERR(*tx_clk))
3410-
*tx_clk = NULL;
3410+
return PTR_ERR(*tx_clk);
34113411

3412-
*rx_clk = devm_clk_get(&pdev->dev, "rx_clk");
3412+
*rx_clk = devm_clk_get_optional(&pdev->dev, "rx_clk");
34133413
if (IS_ERR(*rx_clk))
3414-
*rx_clk = NULL;
3414+
return PTR_ERR(*rx_clk);
34153415

3416-
*tsu_clk = devm_clk_get(&pdev->dev, "tsu_clk");
3416+
*tsu_clk = devm_clk_get_optional(&pdev->dev, "tsu_clk");
34173417
if (IS_ERR(*tsu_clk))
3418-
*tsu_clk = NULL;
3418+
return PTR_ERR(*tsu_clk);
34193419

34203420
err = clk_prepare_enable(*pclk);
34213421
if (err) {

0 commit comments

Comments
 (0)