Commit f66ffe28 authored by Giuseppe CAVALLARO's avatar Giuseppe CAVALLARO Committed by David S. Miller

stmmac: fix open funct when exit on error

This patch reviews the open function and fixes some
errors when exit with an error state.
It also moves the request_irq after core is initialized
when interrupts are properly masked.
Signed-off-by: default avatarShiraz Hashim <shiraz.hashim@st.com>
Hacked-by: default avatarGiuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bded18c2
...@@ -781,21 +781,6 @@ static int stmmac_open(struct net_device *dev) ...@@ -781,21 +781,6 @@ static int stmmac_open(struct net_device *dev)
stmmac_verify_args(); stmmac_verify_args();
ret = stmmac_init_phy(dev);
if (unlikely(ret)) {
pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
return ret;
}
/* Request the IRQ lines */
ret = request_irq(dev->irq, stmmac_interrupt,
IRQF_SHARED, dev->name, dev);
if (unlikely(ret < 0)) {
pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
__func__, dev->irq, ret);
return ret;
}
#ifdef CONFIG_STMMAC_TIMER #ifdef CONFIG_STMMAC_TIMER
priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL); priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
if (unlikely(priv->tm == NULL)) { if (unlikely(priv->tm == NULL)) {
...@@ -814,6 +799,11 @@ static int stmmac_open(struct net_device *dev) ...@@ -814,6 +799,11 @@ static int stmmac_open(struct net_device *dev)
} else } else
priv->tm->enable = 1; priv->tm->enable = 1;
#endif #endif
ret = stmmac_init_phy(dev);
if (unlikely(ret)) {
pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
goto open_error;
}
/* Create and initialize the TX/RX descriptors chains. */ /* Create and initialize the TX/RX descriptors chains. */
priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); priv->dma_tx_size = STMMAC_ALIGN(dma_txsize);
...@@ -822,12 +812,11 @@ static int stmmac_open(struct net_device *dev) ...@@ -822,12 +812,11 @@ static int stmmac_open(struct net_device *dev)
init_dma_desc_rings(dev); init_dma_desc_rings(dev);
/* DMA initialization and SW reset */ /* DMA initialization and SW reset */
if (unlikely(priv->hw->dma->init(priv->ioaddr, priv->plat->pbl, ret = priv->hw->dma->init(priv->ioaddr, priv->plat->pbl,
priv->dma_tx_phy, priv->dma_tx_phy, priv->dma_rx_phy);
priv->dma_rx_phy) < 0)) { if (ret < 0) {
pr_err("%s: DMA initialization failed\n", __func__); pr_err("%s: DMA initialization failed\n", __func__);
return -1; goto open_error;
} }
/* Copy the MAC addr into the HW */ /* Copy the MAC addr into the HW */
...@@ -848,6 +837,15 @@ static int stmmac_open(struct net_device *dev) ...@@ -848,6 +837,15 @@ static int stmmac_open(struct net_device *dev)
writel(0xffffffff, priv->ioaddr + MMC_HIGH_INTR_MASK); writel(0xffffffff, priv->ioaddr + MMC_HIGH_INTR_MASK);
writel(0xffffffff, priv->ioaddr + MMC_LOW_INTR_MASK); writel(0xffffffff, priv->ioaddr + MMC_LOW_INTR_MASK);
/* Request the IRQ lines */
ret = request_irq(dev->irq, stmmac_interrupt,
IRQF_SHARED, dev->name, dev);
if (unlikely(ret < 0)) {
pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
__func__, dev->irq, ret);
goto open_error;
}
/* Enable the MAC Rx/Tx */ /* Enable the MAC Rx/Tx */
stmmac_enable_mac(priv->ioaddr); stmmac_enable_mac(priv->ioaddr);
...@@ -878,7 +876,17 @@ static int stmmac_open(struct net_device *dev) ...@@ -878,7 +876,17 @@ static int stmmac_open(struct net_device *dev)
napi_enable(&priv->napi); napi_enable(&priv->napi);
skb_queue_head_init(&priv->rx_recycle); skb_queue_head_init(&priv->rx_recycle);
netif_start_queue(dev); netif_start_queue(dev);
return 0; return 0;
open_error:
#ifdef CONFIG_STMMAC_TIMER
kfree(priv->tm);
#endif
if (priv->phydev)
phy_disconnect(priv->phydev);
return ret;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment