提交 aa8d4225 编写于 作者: L Laurent Pinchart 提交者: David S. Miller

sh_eth: Use the platform device for memory allocation

Memory allocated for the MDIO bus with the devm_kzalloc() API is
associated with the network device. While this will cause memory to be
freed at the right time, it doesn't allow allocating memory before the
network device is initialized.

Replace the network device with the parent platform device for memory
allocation to remove that dependency. This also improves consistency
with the other devm_* calls in the driver that all use the platform
device.
Signed-off-by: NLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: NGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 54af36e7
...@@ -2606,10 +2606,10 @@ static int sh_mdio_init(struct net_device *ndev, int id, ...@@ -2606,10 +2606,10 @@ static int sh_mdio_init(struct net_device *ndev, int id,
int ret, i; int ret, i;
struct bb_info *bitbang; struct bb_info *bitbang;
struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_private *mdp = netdev_priv(ndev);
struct device *dev = &mdp->pdev->dev;
/* create bit control struct for PHY */ /* create bit control struct for PHY */
bitbang = devm_kzalloc(&ndev->dev, sizeof(struct bb_info), bitbang = devm_kzalloc(dev, sizeof(struct bb_info), GFP_KERNEL);
GFP_KERNEL);
if (!bitbang) { if (!bitbang) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -2638,8 +2638,7 @@ static int sh_mdio_init(struct net_device *ndev, int id, ...@@ -2638,8 +2638,7 @@ static int sh_mdio_init(struct net_device *ndev, int id,
mdp->pdev->name, id); mdp->pdev->name, id);
/* PHY IRQ */ /* PHY IRQ */
mdp->mii_bus->irq = devm_kzalloc(&ndev->dev, mdp->mii_bus->irq = devm_kzalloc(dev, sizeof(int) * PHY_MAX_ADDR,
sizeof(int) * PHY_MAX_ADDR,
GFP_KERNEL); GFP_KERNEL);
if (!mdp->mii_bus->irq) { if (!mdp->mii_bus->irq) {
ret = -ENOMEM; ret = -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册