summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>2020-12-14 09:24:11 +0100
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2020-12-14 09:45:13 +0100
commite8502081953938ee42e85a2d4805bb121e35d0ea (patch)
tree1cf08dfca7854e489c401790d8413b07c9ff1919
parent5817454449802e0b55f914e4fa21049cbfe780d0 (diff)
net: stmmac: dwmac-imx: fix phy-supply null pointer issue
The following happens e.g. on the i.MX 8M Plus EVK which does not specify any phy-supply: [ 1.077851] imx-dwmac 30bf0000.ethernet: no regulator found [ 1.083445] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000078 [ 1.092234] Mem abort info: [ 1.095033] ESR = 0x96000004 [ 1.098087] EC = 0x25: DABT (current EL), IL = 32 bits [ 1.103402] SET = 0, FnV = 0 [ 1.106456] EA = 0, S1PTW = 0 [ 1.109603] Data abort info: [ 1.112489] ISV = 0, ISS = 0x00000004 [ 1.116329] CM = 0, WnR = 0 [ 1.119301] [0000000000000078] user address but active_mm is swapper [ 1.125660] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 1.131232] Modules linked in: [ 1.134291] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.4.77-05639-g581745444980 #10 [ 1.142032] Hardware name: NXP i.MX8MPlus EVK board (DT) [ 1.147344] pstate: 60000005 (nZCv daif -PAN -UAO) [ 1.152141] pc : regulator_enable+0x1c/0x78 [ 1.156326] lr : imx_dwmac_init+0x134/0x1a8 [ 1.160508] sp : ffff80001003bad0 Fixes: ca8811172bdc ("net: stmmac: dwmac-imx: add phy-supply") Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index f79dcca08806..0ca403fff0c0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -178,10 +178,12 @@ static int imx_dwmac_init(struct platform_device *pdev, void *priv)
goto intf_mode_failed;
}
- ret = regulator_enable(dwmac->regulator);
- if (ret) {
- dev_err(dwmac->dev, "fail to enable phy-supply\n");
- goto intf_mode_failed;
+ if (dwmac->regulator) {
+ ret = regulator_enable(dwmac->regulator);
+ if (ret) {
+ dev_err(dwmac->dev, "fail to enable phy-supply\n");
+ goto intf_mode_failed;
+ }
}
return 0;
@@ -214,9 +216,11 @@ static void imx_dwmac_exit(struct platform_device *pdev, void *priv)
clk_disable_unprepare(dwmac->clk_tx);
clk_disable_unprepare(dwmac->clk_mem);
- ret = regulator_disable(dwmac->regulator);
- if (ret)
- dev_err(dwmac->dev, "fail to disable phy-supply\n");
+ if (dwmac->regulator) {
+ ret = regulator_disable(dwmac->regulator);
+ if (ret)
+ dev_err(dwmac->dev, "fail to disable phy-supply\n");
+ }
pm_runtime_put(&pdev->dev);
}
@@ -293,6 +297,7 @@ imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev)
}
}
+ /* Optional regulator for PHY */
dwmac->regulator = devm_regulator_get_optional(dev, "phy");
if (IS_ERR(dwmac->regulator)) {
if (PTR_ERR(dwmac->regulator) == -EPROBE_DEFER) {