aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00usb.c
diff options
context:
space:
mode:
authorIvo van Doorn <IvDoorn@gmail.com>2008-06-06 16:50:28 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-14 12:17:56 -0400
commit6db3786aee36b32e5ed072ed67fad6d5341b0991 (patch)
treeaf6ef8406b539e418f2cbc74609e50faa28a4ee1 /drivers/net/wireless/rt2x00/rt2x00usb.c
parentf019d51410a9b61278eeff811a1ca11d2a905241 (diff)
rt2x00: Move generic TX frame writing code into rt2x00queue
The write_tx_data functions in rt2x00pci and rt2x00usb have a lot in common. This moves that duplicate code into rt2x00queue_write_tx_frame(). Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c57
1 files changed, 14 insertions, 43 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index cdac9280fe42..fdf505beb79c 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -173,71 +173,42 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)
173 ieee80211_wake_queue(rt2x00dev->hw, qid); 173 ieee80211_wake_queue(rt2x00dev->hw, qid);
174} 174}
175 175
176int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, 176int rt2x00usb_write_tx_data(struct queue_entry *entry)
177 struct data_queue *queue, struct sk_buff *skb)
178{ 177{
178 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
179 struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); 179 struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev);
180 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
181 struct queue_entry_priv_usb *entry_priv = entry->priv_data; 180 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
182 struct skb_frame_desc *skbdesc; 181 struct skb_frame_desc *skbdesc;
183 struct txentry_desc txdesc;
184 u32 length; 182 u32 length;
185 183
186 if (rt2x00queue_full(queue))
187 return -EINVAL;
188
189 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) {
190 ERROR(rt2x00dev,
191 "Arrived at non-free entry in the non-full queue %d.\n"
192 "Please file bug report to %s.\n",
193 entry->queue->qid, DRV_PROJECT);
194 return -EINVAL;
195 }
196
197 /*
198 * Copy all TX descriptor information into txdesc,
199 * after that we are free to use the skb->cb array
200 * for our information.
201 */
202 entry->skb = skb;
203 rt2x00queue_create_tx_descriptor(entry, &txdesc);
204
205 /* 184 /*
206 * Add the descriptor in front of the skb. 185 * Add the descriptor in front of the skb.
207 */ 186 */
208 skb_push(skb, queue->desc_size); 187 skb_push(entry->skb, entry->queue->desc_size);
209 memset(skb->data, 0, queue->desc_size); 188 memset(entry->skb->data, 0, entry->queue->desc_size);
210 189
211 /* 190 /*
212 * Fill in skb descriptor 191 * Fill in skb descriptor
213 */ 192 */
214 skbdesc = get_skb_frame_desc(skb); 193 skbdesc = get_skb_frame_desc(entry->skb);
215 memset(skbdesc, 0, sizeof(*skbdesc)); 194 memset(skbdesc, 0, sizeof(*skbdesc));
216 skbdesc->data = skb->data + queue->desc_size; 195 skbdesc->data = entry->skb->data + entry->queue->desc_size;
217 skbdesc->data_len = skb->len - queue->desc_size; 196 skbdesc->data_len = entry->skb->len - entry->queue->desc_size;
218 skbdesc->desc = skb->data; 197 skbdesc->desc = entry->skb->data;
219 skbdesc->desc_len = queue->desc_size; 198 skbdesc->desc_len = entry->queue->desc_size;
220 skbdesc->entry = entry; 199 skbdesc->entry = entry;
221 200
222 rt2x00queue_write_tx_descriptor(entry, &txdesc);
223
224 /* 201 /*
225 * USB devices cannot blindly pass the skb->len as the 202 * USB devices cannot blindly pass the skb->len as the
226 * length of the data to usb_fill_bulk_urb. Pass the skb 203 * length of the data to usb_fill_bulk_urb. Pass the skb
227 * to the driver to determine what the length should be. 204 * to the driver to determine what the length should be.
228 */ 205 */
229 length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, skb); 206 length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, entry->skb);
230
231 /*
232 * Initialize URB and send the frame to the device.
233 */
234 __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
235 __set_bit(ENTRY_DATA_PENDING, &entry->flags);
236 207
237 usb_fill_bulk_urb(entry_priv->urb, usb_dev, usb_sndbulkpipe(usb_dev, 1), 208 usb_fill_bulk_urb(entry_priv->urb, usb_dev,
238 skb->data, length, rt2x00usb_interrupt_txdone, entry); 209 usb_sndbulkpipe(usb_dev, 1),
239 210 entry->skb->data, length,
240 rt2x00queue_index_inc(queue, Q_INDEX); 211 rt2x00usb_interrupt_txdone, entry);
241 212
242 return 0; 213 return 0;
243} 214}