Commit eb0f3bc4 authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller

net: gemini: Fix another missing clk_disable_unprepare() in probe

We recently added some calls to clk_disable_unprepare() but we missed
the last error path if register_netdev() fails.

I made a couple cleanups so we avoid mistakes like this in the future.
First I reversed the "if (!ret)" condition and pulled the code in one
indent level.  Also, the "port->netdev = NULL;" is not required because
"port" isn't used again outside this function so I deleted that line.

Fixes: 4d5ae32f ("net: ethernet: Add a driver for Gemini gigabit ethernet")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1996cf46
...@@ -2446,8 +2446,8 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) ...@@ -2446,8 +2446,8 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
port->reset = devm_reset_control_get_exclusive(dev, NULL); port->reset = devm_reset_control_get_exclusive(dev, NULL);
if (IS_ERR(port->reset)) { if (IS_ERR(port->reset)) {
dev_err(dev, "no reset\n"); dev_err(dev, "no reset\n");
clk_disable_unprepare(port->pclk); ret = PTR_ERR(port->reset);
return PTR_ERR(port->reset); goto unprepare;
} }
reset_control_reset(port->reset); reset_control_reset(port->reset);
usleep_range(100, 500); usleep_range(100, 500);
...@@ -2502,25 +2502,25 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) ...@@ -2502,25 +2502,25 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
IRQF_SHARED, IRQF_SHARED,
port_names[port->id], port_names[port->id],
port); port);
if (ret) { if (ret)
clk_disable_unprepare(port->pclk); goto unprepare;
return ret;
}
ret = register_netdev(netdev); ret = register_netdev(netdev);
if (!ret) { if (ret)
goto unprepare;
netdev_info(netdev,
"irq %d, DMA @ 0x%pap, GMAC @ 0x%pap\n",
port->irq, &dmares->start,
&gmacres->start);
ret = gmac_setup_phy(netdev);
if (ret)
netdev_info(netdev, netdev_info(netdev,
"irq %d, DMA @ 0x%pap, GMAC @ 0x%pap\n", "PHY init failed, deferring to ifup time\n");
port->irq, &dmares->start, return 0;
&gmacres->start);
ret = gmac_setup_phy(netdev);
if (ret)
netdev_info(netdev,
"PHY init failed, deferring to ifup time\n");
return 0;
}
port->netdev = NULL; unprepare:
clk_disable_unprepare(port->pclk);
return ret; return ret;
} }
......
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