aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2007-11-15 17:41:31 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2007-11-18 21:47:37 -0500
commitb242e891c218162cfbae064b1a9136cdbed5ee53 (patch)
tree3e460f49ffd103881082bc561d0536109517b617 /drivers/net/wireless
parent2ffbb8377c7a0713baf6644e285adc27a5654582 (diff)
rt2x00: Request usb_maxpacket() once
The usb max packet size won't change during the device's presence. We should store it in a variable inside rt2x00dev and use that. This should also fix a division error when the device is being hot-unplugged while a frame is being send out. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h7
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c4
4 files changed, 17 insertions, 10 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 277a020b35e9..50775f9234cc 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1032,7 +1032,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1032} 1032}
1033 1033
1034static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev, 1034static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1035 int maxpacket, struct sk_buff *skb) 1035 struct sk_buff *skb)
1036{ 1036{
1037 int length; 1037 int length;
1038 1038
@@ -1041,7 +1041,7 @@ static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1041 * but it must _not_ be a multiple of the USB packet size. 1041 * but it must _not_ be a multiple of the USB packet size.
1042 */ 1042 */
1043 length = roundup(skb->len, 2); 1043 length = roundup(skb->len, 2);
1044 length += (2 * !(length % maxpacket)); 1044 length += (2 * !(length % rt2x00dev->usb_maxpacket));
1045 1045
1046 return length; 1046 return length;
1047} 1047}
@@ -1643,7 +1643,6 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1643 struct data_entry *beacon; 1643 struct data_entry *beacon;
1644 struct data_entry *guardian; 1644 struct data_entry *guardian;
1645 int pipe = usb_sndbulkpipe(usb_dev, 1); 1645 int pipe = usb_sndbulkpipe(usb_dev, 1);
1646 int max_packet = usb_maxpacket(usb_dev, pipe, 1);
1647 int length; 1646 int length;
1648 1647
1649 /* 1648 /*
@@ -1672,7 +1671,7 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1672 ring->desc_size), 1671 ring->desc_size),
1673 skb->len - ring->desc_size, control); 1672 skb->len - ring->desc_size, control);
1674 1673
1675 length = rt2500usb_get_tx_data_len(rt2x00dev, max_packet, skb); 1674 length = rt2500usb_get_tx_data_len(rt2x00dev, skb);
1676 1675
1677 usb_fill_bulk_urb(beacon->priv, usb_dev, pipe, 1676 usb_fill_bulk_urb(beacon->priv, usb_dev, pipe,
1678 skb->data, length, rt2500usb_beacondone, beacon); 1677 skb->data, length, rt2500usb_beacondone, beacon);
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index d1ad5251a77a..c8f16f161c28 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -418,7 +418,7 @@ struct rt2x00lib_ops {
418 int (*write_tx_data) (struct rt2x00_dev *rt2x00dev, 418 int (*write_tx_data) (struct rt2x00_dev *rt2x00dev,
419 struct data_ring *ring, struct sk_buff *skb, 419 struct data_ring *ring, struct sk_buff *skb,
420 struct ieee80211_tx_control *control); 420 struct ieee80211_tx_control *control);
421 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, int maxpacket, 421 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev,
422 struct sk_buff *skb); 422 struct sk_buff *skb);
423 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, 423 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
424 unsigned int queue); 424 unsigned int queue);
@@ -599,6 +599,11 @@ struct rt2x00_dev {
599 u32 *rf; 599 u32 *rf;
600 600
601 /* 601 /*
602 * USB Max frame size (for rt2500usb & rt73usb).
603 */
604 u16 usb_maxpacket;
605
606 /*
602 * Current TX power value. 607 * Current TX power value.
603 */ 608 */
604 u16 tx_power; 609 u16 tx_power;
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 73cc726c4046..1f5675dd329f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -159,7 +159,6 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
159 interface_to_usbdev(rt2x00dev_usb(rt2x00dev)); 159 interface_to_usbdev(rt2x00dev_usb(rt2x00dev));
160 struct data_entry *entry = rt2x00_get_data_entry(ring); 160 struct data_entry *entry = rt2x00_get_data_entry(ring);
161 int pipe = usb_sndbulkpipe(usb_dev, 1); 161 int pipe = usb_sndbulkpipe(usb_dev, 1);
162 int max_packet = usb_maxpacket(usb_dev, pipe, 1);
163 u32 length; 162 u32 length;
164 163
165 if (rt2x00_ring_full(ring)) { 164 if (rt2x00_ring_full(ring)) {
@@ -194,8 +193,7 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
194 * length of the data to usb_fill_bulk_urb. Pass the skb 193 * length of the data to usb_fill_bulk_urb. Pass the skb
195 * to the driver to determine what the length should be. 194 * to the driver to determine what the length should be.
196 */ 195 */
197 length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, 196 length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, skb);
198 max_packet, skb);
199 197
200 /* 198 /*
201 * Initialize URB and send the frame to the device. 199 * Initialize URB and send the frame to the device.
@@ -490,6 +488,11 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
490 rt2x00dev->ops = ops; 488 rt2x00dev->ops = ops;
491 rt2x00dev->hw = hw; 489 rt2x00dev->hw = hw;
492 490
491 rt2x00dev->usb_maxpacket =
492 usb_maxpacket(usb_dev, usb_sndbulkpipe(usb_dev, 1), 1);
493 if (!rt2x00dev->usb_maxpacket)
494 rt2x00dev->usb_maxpacket = 1;
495
493 retval = rt2x00usb_alloc_reg(rt2x00dev); 496 retval = rt2x00usb_alloc_reg(rt2x00dev);
494 if (retval) 497 if (retval)
495 goto exit_free_device; 498 goto exit_free_device;
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index dc640bf6b5eb..c0671c2e6e73 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1251,7 +1251,7 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1251} 1251}
1252 1252
1253static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev, 1253static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1254 int maxpacket, struct sk_buff *skb) 1254 struct sk_buff *skb)
1255{ 1255{
1256 int length; 1256 int length;
1257 1257
@@ -1260,7 +1260,7 @@ static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1260 * but it must _not_ be a multiple of the USB packet size. 1260 * but it must _not_ be a multiple of the USB packet size.
1261 */ 1261 */
1262 length = roundup(skb->len, 4); 1262 length = roundup(skb->len, 4);
1263 length += (4 * !(length % maxpacket)); 1263 length += (4 * !(length % rt2x00dev->usb_maxpacket));
1264 1264
1265 return length; 1265 return length;
1266} 1266}