net: stmmac: Allocate and pass soc/board specific data to callbacks
The current .init and .exit callbacks requires access to driver private data structures. This is not a good seperation and abstraction. Instead, we add a new .setup callback for allocating private data, and pass the returned pointer to the other callbacks. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
c5e4ddbdfa
commit
938dfdaa3c
@@ -144,9 +144,16 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
/* Custom setup (if needed) */
|
||||
if (plat_dat->setup) {
|
||||
plat_dat->bsp_priv = plat_dat->setup(pdev);
|
||||
if (IS_ERR(plat_dat->bsp_priv))
|
||||
return PTR_ERR(plat_dat->bsp_priv);
|
||||
}
|
||||
|
||||
/* Custom initialisation (if needed)*/
|
||||
if (plat_dat->init) {
|
||||
ret = plat_dat->init(pdev);
|
||||
ret = plat_dat->init(pdev, plat_dat->bsp_priv);
|
||||
if (unlikely(ret))
|
||||
return ret;
|
||||
}
|
||||
@@ -203,7 +210,10 @@ static int stmmac_pltfr_remove(struct platform_device *pdev)
|
||||
int ret = stmmac_dvr_remove(ndev);
|
||||
|
||||
if (priv->plat->exit)
|
||||
priv->plat->exit(pdev);
|
||||
priv->plat->exit(pdev, priv->plat->bsp_priv);
|
||||
|
||||
if (priv->plat->free)
|
||||
priv->plat->free(pdev, priv->plat->bsp_priv);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -218,7 +228,7 @@ static int stmmac_pltfr_suspend(struct device *dev)
|
||||
|
||||
ret = stmmac_suspend(ndev);
|
||||
if (priv->plat->exit)
|
||||
priv->plat->exit(pdev);
|
||||
priv->plat->exit(pdev, priv->plat->bsp_priv);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -230,7 +240,7 @@ static int stmmac_pltfr_resume(struct device *dev)
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
|
||||
if (priv->plat->init)
|
||||
priv->plat->init(pdev);
|
||||
priv->plat->init(pdev, priv->plat->bsp_priv);
|
||||
|
||||
return stmmac_resume(ndev);
|
||||
}
|
||||
|
Reference in New Issue
Block a user