linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Joe Perches <joe@perches.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>,
	nbd@nbd.name, linux-wireless@vger.kernel.org,
	sgruszka@redhat.com
Subject: Re: [PATCH] mt76: usb: reduce code indentation in mt76u_alloc_tx
Date: Mon, 4 Mar 2019 12:41:12 +0100	[thread overview]
Message-ID: <20190304114111.GD3073@localhost.localdomain> (raw)
In-Reply-To: <c422bd435e6172424ac2c27f673a64316576e819.camel@perches.com>

[-- Attachment #1: Type: text/plain, Size: 2313 bytes --]

> On Sat, 2019-03-02 at 14:50 +0100, Lorenzo Bianconi wrote:
> > Improve code readability reducing code indentation in
> > mt76u_alloc_tx
> 
> Trivial note below:
> 
> > diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
> []
> > @@ -787,6 +787,7 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
> >  {
> >  	struct mt76u_buf *buf;
> >  	struct mt76_queue *q;
> > +	size_t size;
> >  	int i, j;
> >  
> >  	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
> > @@ -810,15 +811,15 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
> >  			if (!buf->urb)
> >  				return -ENOMEM;
> >  
> > -			if (dev->usb.sg_en) {
> > -				size_t size = MT_SG_MAX_SIZE *
> > -					      sizeof(struct scatterlist);
> > +			if (!dev->usb.sg_en)
> > +				continue;
> >  
> > -				buf->urb->sg = devm_kzalloc(dev->dev, size,
> > -							    GFP_KERNEL);
> > -				if (!buf->urb->sg)
> > -					return -ENOMEM;
> > -			}
> > +			size = MT_SG_MAX_SIZE * sizeof(struct scatterlist);
> > +
> > +			buf->urb->sg = devm_kzalloc(dev->dev, size,
> > +						    GFP_KERNEL);
> 
> Perhaps eliminate size and use devm_kcalloc instead like
> the allocation immediately above this.
> ---
>  drivers/net/wireless/mediatek/mt76/usb.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
> index ae6ada370597..fc87ae223f8d 100644
> --- a/drivers/net/wireless/mediatek/mt76/usb.c
> +++ b/drivers/net/wireless/mediatek/mt76/usb.c
> @@ -806,15 +806,15 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
>  			if (!buf->urb)
>  				return -ENOMEM;
>  
> -			if (dev->usb.sg_en) {
> -				size_t size = MT_SG_MAX_SIZE *
> -					      sizeof(struct scatterlist);
> -
> -				buf->urb->sg = devm_kzalloc(dev->dev, size,
> -							    GFP_KERNEL);
> -				if (!buf->urb->sg)
> -					return -ENOMEM;
> -			}
> +			if (!dev->usb.sg_en)
> +				continue;
> +
> +			buf->urb->sg = devm_kcalloc(dev->dev,
> +						    MT_SG_MAX_SIZE,
> +						    sizeof(*buf->urb->sg),
> +						    GFP_KERNEL);
> +			if (!buf->urb->sg)
> +				return -ENOMEM;
>  		}
>  	}
>  	return 0;
> 

ack, I will post a v2, thx

Regards,
Lorenzo

> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2019-03-04 11:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1551534029.git.lorenzo@kernel.org>
2019-03-02 13:50 ` [PATCH] mt76: usb: reduce code indentation in mt76u_alloc_tx Lorenzo Bianconi
2019-03-02 20:30   ` Joe Perches
2019-03-04 11:41     ` Lorenzo Bianconi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190304114111.GD3073@localhost.localdomain \
    --to=lorenzo.bianconi@redhat.com \
    --cc=joe@perches.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    --cc=sgruszka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).