Skip to content

Commit

Permalink
sh_eth: Use the platform device for memory allocation
Browse files Browse the repository at this point in the history
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: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Laurent Pinchart authored and David S. Miller committed Mar 20, 2014
1 parent 54af36e commit aa8d422
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/net/ethernet/renesas/sh_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2606,10 +2606,10 @@ static int sh_mdio_init(struct net_device *ndev, int id,
int ret, i;
struct bb_info *bitbang;
struct sh_eth_private *mdp = netdev_priv(ndev);
struct device *dev = &mdp->pdev->dev;

/* create bit control struct for PHY */
bitbang = devm_kzalloc(&ndev->dev, sizeof(struct bb_info),
GFP_KERNEL);
bitbang = devm_kzalloc(dev, sizeof(struct bb_info), GFP_KERNEL);
if (!bitbang) {
ret = -ENOMEM;
goto out;
Expand Down Expand Up @@ -2638,8 +2638,7 @@ static int sh_mdio_init(struct net_device *ndev, int id,
mdp->pdev->name, id);

/* PHY IRQ */
mdp->mii_bus->irq = devm_kzalloc(&ndev->dev,
sizeof(int) * PHY_MAX_ADDR,
mdp->mii_bus->irq = devm_kzalloc(dev, sizeof(int) * PHY_MAX_ADDR,
GFP_KERNEL);
if (!mdp->mii_bus->irq) {
ret = -ENOMEM;
Expand Down

0 comments on commit aa8d422

Please sign in to comment.