diff options
author | Linas Vepstas <linas@austin.ibm.com> | 2006-12-13 16:17:39 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-05 16:58:44 -0500 |
commit | 7f7223b8f11f9857fba1dbd5474882219a7ae6e9 (patch) | |
tree | 0a71c86067c95d6f9567f54b7afd2ce5710d476d | |
parent | 366684bd0d6bc5b224fc798675b9a85eb9279227 (diff) |
Spidernet Cleanup return codes
Simplify the somewhat convoluted use of return codes
in the rx buffer handling.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | drivers/net/spider_net.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index 4c26b9a5683e..32a45859dfdd 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -911,12 +911,10 @@ spider_net_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | |||
911 | * @descr: descriptor to process | 911 | * @descr: descriptor to process |
912 | * @card: card structure | 912 | * @card: card structure |
913 | * | 913 | * |
914 | * returns 1 on success, 0 if no packet was passed to the stack | ||
915 | * | ||
916 | * Fills out skb structure and passes the data to the stack. | 914 | * Fills out skb structure and passes the data to the stack. |
917 | * The descriptor state is not changed. | 915 | * The descriptor state is not changed. |
918 | */ | 916 | */ |
919 | static int | 917 | static void |
920 | spider_net_pass_skb_up(struct spider_net_descr *descr, | 918 | spider_net_pass_skb_up(struct spider_net_descr *descr, |
921 | struct spider_net_card *card) | 919 | struct spider_net_card *card) |
922 | { | 920 | { |
@@ -961,8 +959,6 @@ spider_net_pass_skb_up(struct spider_net_descr *descr, | |||
961 | /* update netdevice statistics */ | 959 | /* update netdevice statistics */ |
962 | card->netdev_stats.rx_packets++; | 960 | card->netdev_stats.rx_packets++; |
963 | card->netdev_stats.rx_bytes += skb->len; | 961 | card->netdev_stats.rx_bytes += skb->len; |
964 | |||
965 | return 1; | ||
966 | } | 962 | } |
967 | 963 | ||
968 | /** | 964 | /** |
@@ -981,7 +977,6 @@ spider_net_decode_one_descr(struct spider_net_card *card) | |||
981 | struct spider_net_descr_chain *chain = &card->rx_chain; | 977 | struct spider_net_descr_chain *chain = &card->rx_chain; |
982 | struct spider_net_descr *descr = chain->tail; | 978 | struct spider_net_descr *descr = chain->tail; |
983 | int status; | 979 | int status; |
984 | int result; | ||
985 | 980 | ||
986 | status = spider_net_get_descr_status(descr); | 981 | status = spider_net_get_descr_status(descr); |
987 | 982 | ||
@@ -999,8 +994,6 @@ spider_net_decode_one_descr(struct spider_net_card *card) | |||
999 | /* descriptor definitively used -- move on tail */ | 994 | /* descriptor definitively used -- move on tail */ |
1000 | chain->tail = descr->next; | 995 | chain->tail = descr->next; |
1001 | 996 | ||
1002 | result = 0; | ||
1003 | |||
1004 | /* unmap descriptor */ | 997 | /* unmap descriptor */ |
1005 | pci_unmap_single(card->pdev, descr->buf_addr, | 998 | pci_unmap_single(card->pdev, descr->buf_addr, |
1006 | SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE); | 999 | SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE); |
@@ -1012,8 +1005,7 @@ spider_net_decode_one_descr(struct spider_net_card *card) | |||
1012 | pr_err("%s: dropping RX descriptor with state %d\n", | 1005 | pr_err("%s: dropping RX descriptor with state %d\n", |
1013 | card->netdev->name, status); | 1006 | card->netdev->name, status); |
1014 | card->netdev_stats.rx_dropped++; | 1007 | card->netdev_stats.rx_dropped++; |
1015 | dev_kfree_skb_irq(descr->skb); | 1008 | goto bad_desc; |
1016 | goto refill; | ||
1017 | } | 1009 | } |
1018 | 1010 | ||
1019 | if ( (status != SPIDER_NET_DESCR_COMPLETE) && | 1011 | if ( (status != SPIDER_NET_DESCR_COMPLETE) && |
@@ -1022,8 +1014,7 @@ spider_net_decode_one_descr(struct spider_net_card *card) | |||
1022 | pr_err("%s: RX descriptor with unkown state %d\n", | 1014 | pr_err("%s: RX descriptor with unkown state %d\n", |
1023 | card->netdev->name, status); | 1015 | card->netdev->name, status); |
1024 | card->spider_stats.rx_desc_unk_state++; | 1016 | card->spider_stats.rx_desc_unk_state++; |
1025 | dev_kfree_skb_irq(descr->skb); | 1017 | goto bad_desc; |
1026 | goto refill; | ||
1027 | } | 1018 | } |
1028 | 1019 | ||
1029 | /* The cases we'll throw away the packet immediately */ | 1020 | /* The cases we'll throw away the packet immediately */ |
@@ -1033,17 +1024,18 @@ spider_net_decode_one_descr(struct spider_net_card *card) | |||
1033 | "data_status=x%08x, data_error=x%08x\n", | 1024 | "data_status=x%08x, data_error=x%08x\n", |
1034 | card->netdev->name, | 1025 | card->netdev->name, |
1035 | descr->data_status, descr->data_error); | 1026 | descr->data_status, descr->data_error); |
1036 | card->spider_stats.rx_desc_error++; | 1027 | goto bad_desc; |
1037 | dev_kfree_skb_irq(descr->skb); | ||
1038 | goto refill; | ||
1039 | } | 1028 | } |
1040 | 1029 | ||
1041 | /* ok, we've got a packet in descr */ | 1030 | /* Ok, we've got a packet in descr */ |
1042 | result = spider_net_pass_skb_up(descr, card); | 1031 | spider_net_pass_skb_up(descr, card); |
1043 | refill: | ||
1044 | /* change the descriptor state: */ | ||
1045 | descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE; | 1032 | descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE; |
1046 | return result; | 1033 | return 1; |
1034 | |||
1035 | bad_desc: | ||
1036 | dev_kfree_skb_irq(descr->skb); | ||
1037 | descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE; | ||
1038 | return 0; | ||
1047 | } | 1039 | } |
1048 | 1040 | ||
1049 | /** | 1041 | /** |