diff mbox series

[03/12] mt76usb: change mt76u_fill_rx_sg arguments

Message ID 20190321152537.19105-4-sgruszka@redhat.com (mailing list archive)
State Accepted
Delegated to: Felix Fietkau
Headers show
Series mt76usb: some cleanups and optimizations | expand

Commit Message

Stanislaw Gruszka March 21, 2019, 3:25 p.m. UTC
We do not need to pass len and sglen to the function.
Additionally pass gfp to control allocation context.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/usb.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Lorenzo Bianconi March 22, 2019, 10:10 a.m. UTC | #1
> We do not need to pass len and sglen to the function.
> Additionally pass gfp to control allocation context.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/usb.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
> index 3f21599d52de..56e7a2ca8930 100644
> --- a/drivers/net/wireless/mediatek/mt76/usb.c
> +++ b/drivers/net/wireless/mediatek/mt76/usb.c
> @@ -285,11 +285,13 @@ mt76u_set_endpoints(struct usb_interface *intf,
>  }
>  
>  static int
> -mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf,
> -		 int nsgs, int len, int sglen)
> +mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf, int nsgs,
> +		 gfp_t gfp)
>  {
>  	struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
> +	int sglen = SKB_WITH_OVERHEAD(q->buf_size);
>  	struct urb *urb = buf->urb;
> +

please drop newline here

>  	int i;
>  
>  	for (i = 0; i < nsgs; i++) {
> @@ -297,7 +299,7 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf,
>  		void *data;
>  		int offset;
>  
> -		data = page_frag_alloc(&q->rx_page, len, GFP_ATOMIC);
> +		data = page_frag_alloc(&q->rx_page, q->buf_size, gfp);
>  		if (!data)
>  			break;
>  
> @@ -326,8 +328,7 @@ mt76u_refill_rx(struct mt76_dev *dev, struct mt76_queue *q,
>  		struct mt76u_buf *buf, int nsgs, gfp_t gfp)
>  {
>  	if (dev->usb.sg_en) {
> -		return mt76u_fill_rx_sg(dev, buf, nsgs, q->buf_size,
> -					SKB_WITH_OVERHEAD(q->buf_size));
> +		return mt76u_fill_rx_sg(dev, buf, nsgs, gfp);
>  	} else {
>  		buf->buf = page_frag_alloc(&q->rx_page, q->buf_size, gfp);
>  		return buf->buf ? 0 : -ENOMEM;
> -- 
> 2.20.1
>
Stanislaw Gruszka March 22, 2019, 12:45 p.m. UTC | #2
On Fri, Mar 22, 2019 at 11:10:40AM +0100, Lorenzo Bianconi wrote:
> > We do not need to pass len and sglen to the function.
> > Additionally pass gfp to control allocation context.
> > 
> > Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> > ---
> >  drivers/net/wireless/mediatek/mt76/usb.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
> > index 3f21599d52de..56e7a2ca8930 100644
> > --- a/drivers/net/wireless/mediatek/mt76/usb.c
> > +++ b/drivers/net/wireless/mediatek/mt76/usb.c
> > @@ -285,11 +285,13 @@ mt76u_set_endpoints(struct usb_interface *intf,
> >  }
> >  
> >  static int
> > -mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf,
> > -		 int nsgs, int len, int sglen)
> > +mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf, int nsgs,
> > +		 gfp_t gfp)
> >  {
> >  	struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
> > +	int sglen = SKB_WITH_OVERHEAD(q->buf_size);
> >  	struct urb *urb = buf->urb;
> > +
> 
> please drop newline here

Not sure where it came from, but is already removed on patch 8.

Stanislaw
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index 3f21599d52de..56e7a2ca8930 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -285,11 +285,13 @@  mt76u_set_endpoints(struct usb_interface *intf,
 }
 
 static int
-mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf,
-		 int nsgs, int len, int sglen)
+mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf, int nsgs,
+		 gfp_t gfp)
 {
 	struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
+	int sglen = SKB_WITH_OVERHEAD(q->buf_size);
 	struct urb *urb = buf->urb;
+
 	int i;
 
 	for (i = 0; i < nsgs; i++) {
@@ -297,7 +299,7 @@  mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf,
 		void *data;
 		int offset;
 
-		data = page_frag_alloc(&q->rx_page, len, GFP_ATOMIC);
+		data = page_frag_alloc(&q->rx_page, q->buf_size, gfp);
 		if (!data)
 			break;
 
@@ -326,8 +328,7 @@  mt76u_refill_rx(struct mt76_dev *dev, struct mt76_queue *q,
 		struct mt76u_buf *buf, int nsgs, gfp_t gfp)
 {
 	if (dev->usb.sg_en) {
-		return mt76u_fill_rx_sg(dev, buf, nsgs, q->buf_size,
-					SKB_WITH_OVERHEAD(q->buf_size));
+		return mt76u_fill_rx_sg(dev, buf, nsgs, gfp);
 	} else {
 		buf->buf = page_frag_alloc(&q->rx_page, q->buf_size, gfp);
 		return buf->buf ? 0 : -ENOMEM;