Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd5afa91 authored by Harini Katakam's avatar Harini Katakam Committed by David S. Miller
Browse files

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: default avatarHarini Katakam <harini.katakam@xilinx.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 06acc17a
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -3370,14 +3370,20 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
		*hclk = devm_clk_get(&pdev->dev, "hclk");
	}

	if (IS_ERR(*pclk)) {
	if (IS_ERR_OR_NULL(*pclk)) {
		err = PTR_ERR(*pclk);
		if (!err)
			err = -ENODEV;

		dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err);
		return err;
	}

	if (IS_ERR(*hclk)) {
	if (IS_ERR_OR_NULL(*hclk)) {
		err = PTR_ERR(*hclk);
		if (!err)
			err = -ENODEV;

		dev_err(&pdev->dev, "failed to get hclk (%u)\n", err);
		return err;
	}