Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[firefly-linux-kernel-4.4.55.git] / drivers / net / ethernet / broadcom / bcm63xx_enet.c
index 8256b55883e2a7b43bc698a90d260bad0081eb0b..0b3e23ec37f769dde56f47f475b262c5c101f35d 100644 (file)
@@ -862,27 +862,25 @@ static int bcm_enet_open(struct net_device *dev)
 
        /* allocate rx dma ring */
        size = priv->rx_ring_size * sizeof(struct bcm_enet_desc);
-       p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL);
+       p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma,
+                              GFP_KERNEL | __GFP_ZERO);
        if (!p) {
-               dev_err(kdev, "cannot allocate rx ring %u\n", size);
                ret = -ENOMEM;
                goto out_freeirq_tx;
        }
 
-       memset(p, 0, size);
        priv->rx_desc_alloc_size = size;
        priv->rx_desc_cpu = p;
 
        /* allocate tx dma ring */
        size = priv->tx_ring_size * sizeof(struct bcm_enet_desc);
-       p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL);
+       p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma,
+                              GFP_KERNEL | __GFP_ZERO);
        if (!p) {
-               dev_err(kdev, "cannot allocate tx ring\n");
                ret = -ENOMEM;
                goto out_free_rx_ring;
        }
 
-       memset(p, 0, size);
        priv->tx_desc_alloc_size = size;
        priv->tx_desc_cpu = p;
 
@@ -1670,7 +1668,7 @@ static int bcm_enet_probe(struct platform_device *pdev)
                ret = PTR_ERR(priv->mac_clk);
                goto out;
        }
-       clk_enable(priv->mac_clk);
+       clk_prepare_enable(priv->mac_clk);
 
        /* initialize default and fetch platform data */
        priv->rx_ring_size = BCMENET_DEF_RX_DESC;
@@ -1699,7 +1697,7 @@ static int bcm_enet_probe(struct platform_device *pdev)
                        priv->phy_clk = NULL;
                        goto out_put_clk_mac;
                }
-               clk_enable(priv->phy_clk);
+               clk_prepare_enable(priv->phy_clk);
        }
 
        /* do minimal hardware init to be able to probe mii bus */
@@ -1727,7 +1725,8 @@ static int bcm_enet_probe(struct platform_device *pdev)
                 * if a slave is not present on hw */
                bus->phy_mask = ~(1 << priv->phy_id);
 
-               bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
+               bus->irq = devm_kzalloc(&pdev->dev, sizeof(int) * PHY_MAX_ADDR,
+                                       GFP_KERNEL);
                if (!bus->irq) {
                        ret = -ENOMEM;
                        goto out_free_mdio;
@@ -1788,10 +1787,8 @@ static int bcm_enet_probe(struct platform_device *pdev)
        return 0;
 
 out_unregister_mdio:
-       if (priv->mii_bus) {
+       if (priv->mii_bus)
                mdiobus_unregister(priv->mii_bus);
-               kfree(priv->mii_bus->irq);
-       }
 
 out_free_mdio:
        if (priv->mii_bus)
@@ -1801,12 +1798,12 @@ out_uninit_hw:
        /* turn off mdc clock */
        enet_writel(priv, 0, ENET_MIISC_REG);
        if (priv->phy_clk) {
-               clk_disable(priv->phy_clk);
+               clk_disable_unprepare(priv->phy_clk);
                clk_put(priv->phy_clk);
        }
 
 out_put_clk_mac:
-       clk_disable(priv->mac_clk);
+       clk_disable_unprepare(priv->mac_clk);
        clk_put(priv->mac_clk);
 out:
        free_netdev(dev);
@@ -1832,7 +1829,6 @@ static int bcm_enet_remove(struct platform_device *pdev)
 
        if (priv->has_phy) {
                mdiobus_unregister(priv->mii_bus);
-               kfree(priv->mii_bus->irq);
                mdiobus_free(priv->mii_bus);
        } else {
                struct bcm63xx_enet_platform_data *pd;
@@ -1845,10 +1841,10 @@ static int bcm_enet_remove(struct platform_device *pdev)
 
        /* disable hw block clocks */
        if (priv->phy_clk) {
-               clk_disable(priv->phy_clk);
+               clk_disable_unprepare(priv->phy_clk);
                clk_put(priv->phy_clk);
        }
-       clk_disable(priv->mac_clk);
+       clk_disable_unprepare(priv->mac_clk);
        clk_put(priv->mac_clk);
 
        platform_set_drvdata(pdev, NULL);