Subject: [PATCH 6/6] rt2x00 update: Apply correct error handling to dscape stack

From: Ivo van Doorn <[email-masked]>
Date: Fri, 28 Apr 2006 16:52:29 +0200

From: Ivo van Doorn <[email-masked]>

Return correct error code at failure, and
request debug report when the function _tx()
has received an invalid queue.

Signed-off-by: Ivo van Doorn <[email-masked]>

diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c	2006-04-28 15:32:12.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c	2006-04-28 16:34:55.000000000 +0200
@@ -1538,20 +1538,21 @@ rt2400pci_tx(struct net_device *net_dev,
 	 */
 	ring = rt2x00pci_get_ring(rt2x00pci, control->queue);
 	if (unlikely(!ring)) {
-		ERROR("Attempt to send packet over invalid queue %d.\n",
-			control->queue);
-		return NET_RX_DROP;
+		ERROR("Attempt to send packet over invalid queue %d.\n"
+			"Please file bug report to %s.\n",
+			control->queue, DRV_PROJECT);
+		return NET_XMIT_DROP;
 	}
 
 	if (rt2x00_ring_full(ring))
-		return NET_RX_DROP;
+		return NET_XMIT_DROP;
 
 	entry = rt2x00_get_data_entry(ring);
 	txd = entry->desc_addr;
 
 	if (rt2x00_get_field32(txd->word0, TXD_W0_OWNER_NIC)
 	|| rt2x00_get_field32(txd->word0, TXD_W0_VALID))
-		return NET_RX_DROP;
+		return NET_XMIT_DROP;
 
 	memcpy(entry->data_addr, skb->data, skb->len);
 	rt2400pci_write_tx_desc(rt2x00pci, txd, skb, control);
@@ -2032,7 +2033,7 @@ rt2400pci_conf_tx(struct net_device *net
 	 */
 	if (queue != IEEE80211_TX_QUEUE_DATA0) {
 		NOTICE("Ignoring configuration for queue %d.\n", queue);
-		return 0;
+		return -EINVAL;
 	}
 
 	memcpy(&ring->tx_params, params, sizeof(*params));
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c	2006-04-28 15:32:31.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c	2006-04-28 16:34:54.000000000 +0200
@@ -1661,20 +1661,21 @@ rt2500pci_tx(struct net_device *net_dev,
 	 */
 	ring = rt2x00pci_get_ring(rt2x00pci, control->queue);
 	if (unlikely(!ring)) {
-		ERROR("Attempt to send packet over invalid queue %d.\n",
-			control->queue);
-		return NET_RX_DROP;
+		ERROR("Attempt to send packet over invalid queue %d.\n"
+			"Please file bug report to %s.\n",
+			control->queue, DRV_PROJECT);
+		return NET_XMIT_DROP;
 	}
 
 	if (rt2x00_ring_full(ring))
-		return NET_RX_DROP;
+		return NET_XMIT_DROP;
 
 	entry = rt2x00_get_data_entry(ring);
 	txd = entry->desc_addr;
 
 	if (rt2x00_get_field32(txd->word0, TXD_W0_OWNER_NIC)
 	|| rt2x00_get_field32(txd->word0, TXD_W0_VALID))
-		return NET_RX_DROP;
+		return NET_XMIT_DROP;
 
 	memcpy(entry->data_addr, skb->data, skb->len);
 	rt2500pci_write_tx_desc(rt2x00pci, txd, skb, control);
@@ -2147,7 +2148,7 @@ rt2500pci_conf_tx(struct net_device *net
 	ring = rt2x00pci_get_ring(rt2x00pci, queue);
 	if (unlikely(!ring)) {
 		NOTICE("Ignoring configuration for queue %d.\n", queue);
-		return 0;
+		return -EINVAL;
 	}
 
 	memcpy(&ring->tx_params, params, sizeof(*params));
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-28 15:32:06.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-28 16:34:56.000000000 +0200
@@ -1373,13 +1373,14 @@ rt2500usb_tx(struct net_device *net_dev,
 	 */
 	ring = rt2x00usb_get_ring(rt2x00usb, control->queue);
 	if (unlikely(!ring)) {
-		ERROR("Attempt to send packet over invalid queue %d.\n",
-			control->queue);
-		return NET_RX_DROP;
+		ERROR("Attempt to send packet over invalid queue %d.\n"
+			"Please file bug report to %s.\n",
+			control->queue, DRV_PROJECT);
+		return NET_XMIT_DROP;
 	}
 
 	if (rt2x00_ring_full(ring))
-		return NET_RX_DROP;
+		return NET_XMIT_DROP;
 
 	entry = rt2x00_get_data_entry(ring);
 	txd = rt2x00usb_txdesc_addr(entry);
@@ -1797,7 +1798,7 @@ rt2500usb_conf_tx(struct net_device *net
 	ring = rt2x00usb_get_ring(rt2x00usb, queue);
 	if (unlikely(!ring)) {
 		NOTICE("Ignoring configuration for queue %d.\n", queue);
-		return 0;
+		return -EINVAL;
 	}
 
 	memcpy(&ring->tx_params, params, sizeof(*params));