mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-15 19:04:04 +00:00
mt76: usb: introduce mt76u_fill_bulk_urb routine
Add mt76u_fill_bulk_urb to initialize tx/rx urbs and remove duplicate code Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
cb1847cce0
commit
4de92bf10c
1 changed files with 26 additions and 19 deletions
|
@ -376,9 +376,10 @@ void mt76u_buf_free(struct mt76u_buf *buf)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mt76u_buf_free);
|
EXPORT_SYMBOL_GPL(mt76u_buf_free);
|
||||||
|
|
||||||
int mt76u_submit_buf(struct mt76_dev *dev, int dir, int index,
|
static void
|
||||||
struct mt76u_buf *buf, gfp_t gfp,
|
mt76u_fill_bulk_urb(struct mt76_dev *dev, int dir, int index,
|
||||||
usb_complete_t complete_fn, void *context)
|
struct mt76u_buf *buf, usb_complete_t complete_fn,
|
||||||
|
void *context)
|
||||||
{
|
{
|
||||||
struct usb_interface *intf = to_usb_interface(dev->dev);
|
struct usb_interface *intf = to_usb_interface(dev->dev);
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
struct usb_device *udev = interface_to_usbdev(intf);
|
||||||
|
@ -392,6 +393,14 @@ int mt76u_submit_buf(struct mt76_dev *dev, int dir, int index,
|
||||||
|
|
||||||
usb_fill_bulk_urb(buf->urb, udev, pipe, data, buf->len,
|
usb_fill_bulk_urb(buf->urb, udev, pipe, data, buf->len,
|
||||||
complete_fn, context);
|
complete_fn, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
int mt76u_submit_buf(struct mt76_dev *dev, int dir, int index,
|
||||||
|
struct mt76u_buf *buf, gfp_t gfp,
|
||||||
|
usb_complete_t complete_fn, void *context)
|
||||||
|
{
|
||||||
|
mt76u_fill_bulk_urb(dev, dir, index, buf, complete_fn,
|
||||||
|
context);
|
||||||
trace_submit_urb(dev, buf->urb);
|
trace_submit_urb(dev, buf->urb);
|
||||||
|
|
||||||
return usb_submit_urb(buf->urb, gfp);
|
return usb_submit_urb(buf->urb, gfp);
|
||||||
|
@ -724,11 +733,16 @@ static void mt76u_complete_tx(struct urb *urb)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mt76u_tx_build_sg(struct sk_buff *skb, struct urb *urb)
|
mt76u_tx_build_sg(struct mt76_dev *dev, struct sk_buff *skb,
|
||||||
|
struct urb *urb)
|
||||||
{
|
{
|
||||||
int nsgs = 1 + skb_shinfo(skb)->nr_frags;
|
|
||||||
struct sk_buff *iter;
|
struct sk_buff *iter;
|
||||||
|
int nsgs;
|
||||||
|
|
||||||
|
if (!dev->usb.sg_en)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
nsgs = 1 + skb_shinfo(skb)->nr_frags;
|
||||||
skb_walk_frags(skb, iter)
|
skb_walk_frags(skb, iter)
|
||||||
nsgs += 1 + skb_shinfo(iter)->nr_frags;
|
nsgs += 1 + skb_shinfo(iter)->nr_frags;
|
||||||
|
|
||||||
|
@ -746,12 +760,8 @@ mt76u_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
|
||||||
struct sk_buff *skb, struct mt76_wcid *wcid,
|
struct sk_buff *skb, struct mt76_wcid *wcid,
|
||||||
struct ieee80211_sta *sta)
|
struct ieee80211_sta *sta)
|
||||||
{
|
{
|
||||||
struct usb_interface *intf = to_usb_interface(dev->dev);
|
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
|
||||||
u8 *data = NULL, ep = q2ep(q->hw_idx);
|
|
||||||
struct mt76u_buf *buf;
|
struct mt76u_buf *buf;
|
||||||
u16 idx = q->tail;
|
u16 idx = q->tail;
|
||||||
unsigned int pipe;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (q->queued == q->ndesc)
|
if (q->queued == q->ndesc)
|
||||||
|
@ -763,19 +773,16 @@ mt76u_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
buf = &q->entry[idx].ubuf;
|
buf = &q->entry[idx].ubuf;
|
||||||
|
buf->buf = skb->data;
|
||||||
|
buf->len = skb->len;
|
||||||
buf->done = false;
|
buf->done = false;
|
||||||
|
|
||||||
if (dev->usb.sg_en) {
|
err = mt76u_tx_build_sg(dev, skb, buf->urb);
|
||||||
err = mt76u_tx_build_sg(skb, buf->urb);
|
if (err < 0)
|
||||||
if (err < 0)
|
return err;
|
||||||
return err;
|
|
||||||
} else {
|
|
||||||
data = skb->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe = usb_sndbulkpipe(udev, dev->usb.out_ep[ep]);
|
mt76u_fill_bulk_urb(dev, USB_DIR_OUT, q2ep(q->hw_idx),
|
||||||
usb_fill_bulk_urb(buf->urb, udev, pipe, data, skb->len,
|
buf, mt76u_complete_tx, buf);
|
||||||
mt76u_complete_tx, buf);
|
|
||||||
|
|
||||||
q->tail = (q->tail + 1) % q->ndesc;
|
q->tail = (q->tail + 1) % q->ndesc;
|
||||||
q->entry[idx].skb = skb;
|
q->entry[idx].skb = skb;
|
||||||
|
|
Loading…
Add table
Reference in a new issue