[linux-oxnas] [PATCH net 2/3] net: stmmac: dwmac-oxnas: fix fixed-link-phydev leaks |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/linux-oxnas Archives
]
- To: "David S. Miller" <davem@xxxxxxxxxxxxx>
- Subject: [linux-oxnas] [PATCH net 2/3] net: stmmac: dwmac-oxnas: fix fixed-link-phydev leaks
- From: Johan Hovold <johan@xxxxxxxxxx>
- Date: Mon, 2 Jan 2017 12:56:03 +0100
- Cc: Giuseppe Cavallaro <peppe.cavallaro@xxxxxx>, Alexandre Torgue <alexandre.torgue@xxxxxx>, Neil Armstrong <narmstrong@xxxxxxxxxxxx>, netdev@xxxxxxxxxxxxxxx, linux-oxnas@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Johan Hovold <johan@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q7aopMu6k6NflTqo6wee/fOihqUpohUmsTvEU96cNro=; b=rOPgNnvEInK7MZsh2nTM0PgkdOFVMJtM4SnIAvdJEvIc5cuVytzWROP7FpHcGUjObV 2zjsImSn9jrpRw1kbugeIWEYJuFbi7ZKP4OnYYo8D8eLdwU4GbUHTnuLQPHRt3fp1sOV OHijGQE+e/QtjAz/Zi962nAVfi05GFumS4JsuySu/JScwK9HYka9Ac3Ij1faML3GqoNH 4f+COQnzAUxtqgHBx+yL2S/FMy75bUL/0bwi+GOIp1Ccx4Tg+Wq+fh0J3fFYr5OxI2SV uPZ85XuWhDBBY55N9NJ92DxW/HVZN9JZsQljHxmFhrkVtNxH1l+/cLr1mvRMlp9tnzWY SksQ==
Make sure to deregister and free any fixed-link phy registered during
probe on probe errors and on driver unbind by calling the new glue
helper function.
For driver unbind, use the generic stmmac-platform remove implementation
and add an exit callback to disable the clock.
Fixes: 5ed7414062e7 ("net: stmmac: Add OXNAS Glue Driver")
Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c | 41 ++++++++++++++---------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
index fcc237e0aae1..3efd110613df 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
@@ -105,6 +105,13 @@ static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac)
return 0;
}
+static void oxnas_dwmac_exit(struct platform_device *pdev, void *priv)
+{
+ struct oxnas_dwmac *dwmac = priv;
+
+ clk_disable_unprepare(dwmac->clk);
+}
+
static int oxnas_dwmac_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat_dat;
@@ -121,40 +128,44 @@ static int oxnas_dwmac_probe(struct platform_device *pdev)
return PTR_ERR(plat_dat);
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
- if (!dwmac)
- return -ENOMEM;
+ if (!dwmac) {
+ ret = -ENOMEM;
+ goto err_remove_config_dt;
+ }
dwmac->dev = &pdev->dev;
plat_dat->bsp_priv = dwmac;
+ plat_dat->exit = oxnas_dwmac_exit;
dwmac->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
"oxsemi,sys-ctrl");
if (IS_ERR(dwmac->regmap)) {
dev_err(&pdev->dev, "failed to have sysctrl regmap\n");
- return PTR_ERR(dwmac->regmap);
+ ret = PTR_ERR(dwmac->regmap);
+ goto err_remove_config_dt;
}
dwmac->clk = devm_clk_get(&pdev->dev, "gmac");
- if (IS_ERR(dwmac->clk))
- return PTR_ERR(dwmac->clk);
+ if (IS_ERR(dwmac->clk)) {
+ ret = PTR_ERR(dwmac->clk);
+ goto err_remove_config_dt;
+ }
ret = oxnas_dwmac_init(dwmac);
if (ret)
- return ret;
+ goto err_remove_config_dt;
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
if (ret)
- clk_disable_unprepare(dwmac->clk);
+ goto err_dwmac_exit;
- return ret;
-}
-static int oxnas_dwmac_remove(struct platform_device *pdev)
-{
- struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
- int ret = stmmac_dvr_remove(&pdev->dev);
+ return 0;
- clk_disable_unprepare(dwmac->clk);
+err_dwmac_exit:
+ oxnas_dwmac_exit(pdev, plat_dat->bsp_priv);
+err_remove_config_dt:
+ stmmac_remove_config_dt(pdev, plat_dat);
return ret;
}
@@ -197,7 +208,7 @@ MODULE_DEVICE_TABLE(of, oxnas_dwmac_match);
static struct platform_driver oxnas_dwmac_driver = {
.probe = oxnas_dwmac_probe,
- .remove = oxnas_dwmac_remove,
+ .remove = stmmac_pltfr_remove,
.driver = {
.name = "oxnas-dwmac",
.pm = &oxnas_dwmac_pm_ops,
--
2.10.2