stmmac: platform: Move plat_dat checking earlier
Subsystems (4)
PATCH v2 1/1 stmmac: platform: Move plat_dat checking earlier
Original code only check/alloc plat_dat for the CONFIG_OF case, this patch check/alloc it earlier and unconditionally to avoid kernel build warnings:
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:275 stmmac_pltfr_probe() warn: variable dereferenced before check 'plat_dat'
V2: Fix coding style.
--- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +9 -9
@@ -265,6 +265,15 @@ static int stmmac_pltfr_probe(struct platform_device *pdev) plat_dat =dev_get_platdata (&pdev->dev); +if (!plat_dat) + plat_dat =devm_kzalloc (&pdev->dev, +sizeof (struct plat_stmmacenet_data ), +GFP_KERNEL ); +if (!plat_dat) { +pr_err ("%s: ERROR: no memory" , __func__); +return -ENOMEM ; + } +/* Set default value for multicast hash bins */ plat_dat->multicast_filter_bins =HASH_TABLE_SIZE ;
@@ -272,15 +281,6 @@ static int stmmac_pltfr_probe(struct platform_device *pdev) plat_dat->unicast_filter_entries =1 ;if (pdev->dev.of_node) { -if (!plat_dat) - plat_dat =devm_kzalloc (&pdev->dev, -sizeof (struct plat_stmmacenet_data ), -GFP_KERNEL ); -if (!plat_dat) { -pr_err ("%s: ERROR: no memory" , __func__); -return -ENOMEM ; - } - ret =stmmac_probe_config_dt (pdev, plat_dat, &mac);if (ret) {pr_err ("%s: main dt probe failed" , __func__);
Signature · 1 line
1.7.7.3
From: Huacai Chen <[email protected]>
Date: Thu, 27 Nov 2014 21:05:34 +0800
Quoted 10 lines
Original code only check/alloc
plat_datfor theCONFIG_OFcase, this patch check/alloc it earlier and unconditionally to avoid kernel build warnings:
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:275stmmac_pltfr_probe()warn: variable dereferenced before check 'plat_dat'V2: Fix coding style.
Signed-off-by Huacai Chen <[email protected]>
Applied, thanks.