diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2009-08-28 10:01:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-29 18:42:54 -0400 |
commit | 07b0173cb5d6a9d77646cd855066ebe90b9203f2 (patch) | |
tree | 5a2490f1965e552688f4b3cec4453d0bba99a386 /drivers | |
parent | 79ed5ac7ddd5f8d6463f5a17b3575772e9896481 (diff) |
tg3: Cleanup interrupt setup / teardown
Later patches will be adding MSIX support, which will complicate
interrupt initialization. This patch prepares for the integration by
breaking out the interrupt setup and teardown code into separate
functions and cleaning up the error return paths.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/tg3.c | 94 |
1 files changed, 46 insertions, 48 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 3725ac857086..37a462986db2 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -7865,6 +7865,33 @@ static int tg3_request_firmware(struct tg3 *tp) | |||
7865 | return 0; | 7865 | return 0; |
7866 | } | 7866 | } |
7867 | 7867 | ||
7868 | static void tg3_ints_init(struct tg3 *tp) | ||
7869 | { | ||
7870 | if (tp->tg3_flags & TG3_FLAG_SUPPORT_MSI) { | ||
7871 | /* All MSI supporting chips should support tagged | ||
7872 | * status. Assert that this is the case. | ||
7873 | */ | ||
7874 | if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) { | ||
7875 | printk(KERN_WARNING PFX "%s: MSI without TAGGED? " | ||
7876 | "Not using MSI.\n", tp->dev->name); | ||
7877 | } else if (pci_enable_msi(tp->pdev) == 0) { | ||
7878 | u32 msi_mode; | ||
7879 | |||
7880 | msi_mode = tr32(MSGINT_MODE); | ||
7881 | tw32(MSGINT_MODE, msi_mode | MSGINT_MODE_ENABLE); | ||
7882 | tp->tg3_flags2 |= TG3_FLG2_USING_MSI; | ||
7883 | } | ||
7884 | } | ||
7885 | } | ||
7886 | |||
7887 | static void tg3_ints_fini(struct tg3 *tp) | ||
7888 | { | ||
7889 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | ||
7890 | pci_disable_msi(tp->pdev); | ||
7891 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; | ||
7892 | } | ||
7893 | } | ||
7894 | |||
7868 | static int tg3_open(struct net_device *dev) | 7895 | static int tg3_open(struct net_device *dev) |
7869 | { | 7896 | { |
7870 | struct tg3 *tp = netdev_priv(dev); | 7897 | struct tg3 *tp = netdev_priv(dev); |
@@ -7906,33 +7933,14 @@ static int tg3_open(struct net_device *dev) | |||
7906 | if (err) | 7933 | if (err) |
7907 | return err; | 7934 | return err; |
7908 | 7935 | ||
7909 | if (tp->tg3_flags & TG3_FLAG_SUPPORT_MSI) { | 7936 | tg3_ints_init(tp); |
7910 | /* All MSI supporting chips should support tagged | ||
7911 | * status. Assert that this is the case. | ||
7912 | */ | ||
7913 | if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) { | ||
7914 | printk(KERN_WARNING PFX "%s: MSI without TAGGED? " | ||
7915 | "Not using MSI.\n", tp->dev->name); | ||
7916 | } else if (pci_enable_msi(tp->pdev) == 0) { | ||
7917 | u32 msi_mode; | ||
7918 | 7937 | ||
7919 | msi_mode = tr32(MSGINT_MODE); | 7938 | napi_enable(&tp->napi); |
7920 | tw32(MSGINT_MODE, msi_mode | MSGINT_MODE_ENABLE); | ||
7921 | tp->tg3_flags2 |= TG3_FLG2_USING_MSI; | ||
7922 | } | ||
7923 | } | ||
7924 | err = tg3_request_irq(tp); | ||
7925 | 7939 | ||
7926 | if (err) { | 7940 | err = tg3_request_irq(tp); |
7927 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | ||
7928 | pci_disable_msi(tp->pdev); | ||
7929 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; | ||
7930 | } | ||
7931 | tg3_free_consistent(tp); | ||
7932 | return err; | ||
7933 | } | ||
7934 | 7941 | ||
7935 | napi_enable(&tp->napi); | 7942 | if (err) |
7943 | goto err_out1; | ||
7936 | 7944 | ||
7937 | tg3_full_lock(tp, 0); | 7945 | tg3_full_lock(tp, 0); |
7938 | 7946 | ||
@@ -7960,36 +7968,19 @@ static int tg3_open(struct net_device *dev) | |||
7960 | 7968 | ||
7961 | tg3_full_unlock(tp); | 7969 | tg3_full_unlock(tp); |
7962 | 7970 | ||
7963 | if (err) { | 7971 | if (err) |
7964 | napi_disable(&tp->napi); | 7972 | goto err_out2; |
7965 | free_irq(tp->pdev->irq, dev); | ||
7966 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | ||
7967 | pci_disable_msi(tp->pdev); | ||
7968 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; | ||
7969 | } | ||
7970 | tg3_free_consistent(tp); | ||
7971 | return err; | ||
7972 | } | ||
7973 | 7973 | ||
7974 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | 7974 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { |
7975 | err = tg3_test_msi(tp); | 7975 | err = tg3_test_msi(tp); |
7976 | 7976 | ||
7977 | if (err) { | 7977 | if (err) { |
7978 | tg3_full_lock(tp, 0); | 7978 | tg3_full_lock(tp, 0); |
7979 | |||
7980 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | ||
7981 | pci_disable_msi(tp->pdev); | ||
7982 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; | ||
7983 | } | ||
7984 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 7979 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
7985 | tg3_free_rings(tp); | 7980 | tg3_free_rings(tp); |
7986 | tg3_free_consistent(tp); | ||
7987 | |||
7988 | tg3_full_unlock(tp); | 7981 | tg3_full_unlock(tp); |
7989 | 7982 | ||
7990 | napi_disable(&tp->napi); | 7983 | goto err_out1; |
7991 | |||
7992 | return err; | ||
7993 | } | 7984 | } |
7994 | 7985 | ||
7995 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | 7986 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { |
@@ -8015,6 +8006,15 @@ static int tg3_open(struct net_device *dev) | |||
8015 | netif_start_queue(dev); | 8006 | netif_start_queue(dev); |
8016 | 8007 | ||
8017 | return 0; | 8008 | return 0; |
8009 | |||
8010 | err_out2: | ||
8011 | free_irq(tp->pdev->irq, dev); | ||
8012 | |||
8013 | err_out1: | ||
8014 | napi_disable(&tp->napi); | ||
8015 | tg3_ints_fini(tp); | ||
8016 | tg3_free_consistent(tp); | ||
8017 | return err; | ||
8018 | } | 8018 | } |
8019 | 8019 | ||
8020 | #if 0 | 8020 | #if 0 |
@@ -8273,10 +8273,8 @@ static int tg3_close(struct net_device *dev) | |||
8273 | tg3_full_unlock(tp); | 8273 | tg3_full_unlock(tp); |
8274 | 8274 | ||
8275 | free_irq(tp->pdev->irq, dev); | 8275 | free_irq(tp->pdev->irq, dev); |
8276 | if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { | 8276 | |
8277 | pci_disable_msi(tp->pdev); | 8277 | tg3_ints_fini(tp); |
8278 | tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; | ||
8279 | } | ||
8280 | 8278 | ||
8281 | memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev), | 8279 | memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev), |
8282 | sizeof(tp->net_stats_prev)); | 8280 | sizeof(tp->net_stats_prev)); |