Skip to content

Commit cd5afa9

Browse files
harini-katakamdavem330
authored andcommitted
net: macb: Add null check for PCLK and HCLK
Both PCLK and HCLK are "required" clocks according to macb devicetree documentation. There is a chance that devm_clk_get doesn't return a negative error but just a NULL clock structure instead. In such a case the driver proceeds as usual and uses pclk value 0 to calculate MDC divisor which is incorrect. Hence fix the same in clock initialization. Signed-off-by: Harini Katakam <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 06acc17 commit cd5afa9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,14 +3370,20 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
33703370
*hclk = devm_clk_get(&pdev->dev, "hclk");
33713371
}
33723372

3373-
if (IS_ERR(*pclk)) {
3373+
if (IS_ERR_OR_NULL(*pclk)) {
33743374
err = PTR_ERR(*pclk);
3375+
if (!err)
3376+
err = -ENODEV;
3377+
33753378
dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err);
33763379
return err;
33773380
}
33783381

3379-
if (IS_ERR(*hclk)) {
3382+
if (IS_ERR_OR_NULL(*hclk)) {
33803383
err = PTR_ERR(*hclk);
3384+
if (!err)
3385+
err = -ENODEV;
3386+
33813387
dev_err(&pdev->dev, "failed to get hclk (%u)\n", err);
33823388
return err;
33833389
}

0 commit comments

Comments
 (0)