aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/stmmac
diff options
context:
space:
mode:
authorGiuseppe CAVALLARO <peppe.cavallaro@st.com>2011-04-10 19:16:45 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-11 15:55:47 -0400
commitf66ffe285939559d2a6f630a36f676d7c056b99d (patch)
tree3b6ee5cdd3b679b4a1d01d3b30d3cf208554183e /drivers/net/stmmac
parentbded18c2dd09eee870f4446652dbce493a6dece1 (diff)
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: Shiraz Hashim <shiraz.hashim@st.com> Hacked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/stmmac')
-rw-r--r--drivers/net/stmmac/stmmac_main.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index 0e5f03135b50..38f7b619c44c 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -781,21 +781,6 @@ static int stmmac_open(struct net_device *dev)
781 781
782 stmmac_verify_args(); 782 stmmac_verify_args();
783 783
784 ret = stmmac_init_phy(dev);
785 if (unlikely(ret)) {
786 pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
787 return ret;
788 }
789
790 /* Request the IRQ lines */
791 ret = request_irq(dev->irq, stmmac_interrupt,
792 IRQF_SHARED, dev->name, dev);
793 if (unlikely(ret < 0)) {
794 pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
795 __func__, dev->irq, ret);
796 return ret;
797 }
798
799#ifdef CONFIG_STMMAC_TIMER 784#ifdef CONFIG_STMMAC_TIMER
800 priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL); 785 priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
801 if (unlikely(priv->tm == NULL)) { 786 if (unlikely(priv->tm == NULL)) {
@@ -814,6 +799,11 @@ static int stmmac_open(struct net_device *dev)
814 } else 799 } else
815 priv->tm->enable = 1; 800 priv->tm->enable = 1;
816#endif 801#endif
802 ret = stmmac_init_phy(dev);
803 if (unlikely(ret)) {
804 pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
805 goto open_error;
806 }
817 807
818 /* Create and initialize the TX/RX descriptors chains. */ 808 /* Create and initialize the TX/RX descriptors chains. */
819 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); 809 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize);
@@ -822,12 +812,11 @@ static int stmmac_open(struct net_device *dev)
822 init_dma_desc_rings(dev); 812 init_dma_desc_rings(dev);
823 813
824 /* DMA initialization and SW reset */ 814 /* DMA initialization and SW reset */
825 if (unlikely(priv->hw->dma->init(priv->ioaddr, priv->plat->pbl, 815 ret = priv->hw->dma->init(priv->ioaddr, priv->plat->pbl,
826 priv->dma_tx_phy, 816 priv->dma_tx_phy, priv->dma_rx_phy);
827 priv->dma_rx_phy) < 0)) { 817 if (ret < 0) {
828
829 pr_err("%s: DMA initialization failed\n", __func__); 818 pr_err("%s: DMA initialization failed\n", __func__);
830 return -1; 819 goto open_error;
831 } 820 }
832 821
833 /* Copy the MAC addr into the HW */ 822 /* Copy the MAC addr into the HW */
@@ -848,6 +837,15 @@ static int stmmac_open(struct net_device *dev)
848 writel(0xffffffff, priv->ioaddr + MMC_HIGH_INTR_MASK); 837 writel(0xffffffff, priv->ioaddr + MMC_HIGH_INTR_MASK);
849 writel(0xffffffff, priv->ioaddr + MMC_LOW_INTR_MASK); 838 writel(0xffffffff, priv->ioaddr + MMC_LOW_INTR_MASK);
850 839
840 /* Request the IRQ lines */
841 ret = request_irq(dev->irq, stmmac_interrupt,
842 IRQF_SHARED, dev->name, dev);
843 if (unlikely(ret < 0)) {
844 pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
845 __func__, dev->irq, ret);
846 goto open_error;
847 }
848
851 /* Enable the MAC Rx/Tx */ 849 /* Enable the MAC Rx/Tx */
852 stmmac_enable_mac(priv->ioaddr); 850 stmmac_enable_mac(priv->ioaddr);
853 851
@@ -878,7 +876,17 @@ static int stmmac_open(struct net_device *dev)
878 napi_enable(&priv->napi); 876 napi_enable(&priv->napi);
879 skb_queue_head_init(&priv->rx_recycle); 877 skb_queue_head_init(&priv->rx_recycle);
880 netif_start_queue(dev); 878 netif_start_queue(dev);
879
881 return 0; 880 return 0;
881
882open_error:
883#ifdef CONFIG_STMMAC_TIMER
884 kfree(priv->tm);
885#endif
886 if (priv->phydev)
887 phy_disconnect(priv->phydev);
888
889 return ret;
882} 890}
883 891
884/** 892/**