]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
dt:net:stmmac: Allocate platform data only if its NULL.
authorSrinivas Kandagatla <srinivas.kandagatla@st.com>
Thu, 4 Jul 2013 09:35:35 +0000 (10:35 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jul 2013 21:34:17 +0000 (14:34 -0700)
In some DT use-cases platform data might be already allocated and passed
via AUXDATA. These are the cases where machine level code populates few
callbacks in the platform data.

This patch adds check and reuses platform_data if its valid, before
allocating a new one.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

index 17bc7827e7cafded7ce96bb4a024ac6d8ebf525d..adfb9a3ce6c574df4e0df7154f81d7ce16362cad 100644 (file)
@@ -92,8 +92,10 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
        if (IS_ERR(addr))
                return PTR_ERR(addr);
 
+       plat_dat = pdev->dev.platform_data;
        if (pdev->dev.of_node) {
-               plat_dat = devm_kzalloc(&pdev->dev,
+               if (!plat_dat)
+                       plat_dat = devm_kzalloc(&pdev->dev,
                                        sizeof(struct plat_stmmacenet_data),
                                        GFP_KERNEL);
                if (!plat_dat) {
@@ -106,8 +108,6 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
                        pr_err("%s: main dt probe failed", __func__);
                        return ret;
                }
-       } else {
-               plat_dat = pdev->dev.platform_data;
        }
 
        /* Custom initialisation (if needed)*/