net: stmmac: dwmac-oxnas: fix of-node leak
authorJohan Hovold <johan@kernel.org>
Mon, 2 Jan 2017 11:56:02 +0000 (12:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Jan 2017 14:33:00 +0000 (09:33 -0500)
Use the syscon lookup-by-phandle helper so that the reference taken by
of_parse_phandle() is released when done with the node.

Fixes: 5ed7414062e7 ("net: stmmac: Add OXNAS Glue Driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c

index c35597586121e5c3b41f6453711e3ea9920af463..fcc237e0aae13bb9a5c46710de99c9562f303ede 100644 (file)
@@ -109,16 +109,9 @@ static int oxnas_dwmac_probe(struct platform_device *pdev)
 {
        struct plat_stmmacenet_data *plat_dat;
        struct stmmac_resources stmmac_res;
-       struct device_node *sysctrl;
        struct oxnas_dwmac *dwmac;
        int ret;
 
-       sysctrl = of_parse_phandle(pdev->dev.of_node, "oxsemi,sys-ctrl", 0);
-       if (!sysctrl) {
-               dev_err(&pdev->dev, "failed to get sys-ctrl node\n");
-               return -EINVAL;
-       }
-
        ret = stmmac_get_platform_resources(pdev, &stmmac_res);
        if (ret)
                return ret;
@@ -134,7 +127,8 @@ static int oxnas_dwmac_probe(struct platform_device *pdev)
        dwmac->dev = &pdev->dev;
        plat_dat->bsp_priv = dwmac;
 
-       dwmac->regmap = syscon_node_to_regmap(sysctrl);
+       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);