* [PATCH] mt76: usb: reduce code indentation in mt76u_alloc_tx
[not found] <cover.1551534029.git.lorenzo@kernel.org>
@ 2019-03-02 13:50 ` Lorenzo Bianconi
2019-03-02 20:30 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2019-03-02 13:50 UTC (permalink / raw)
To: nbd; +Cc: linux-wireless, sgruszka, lorenzo.bianconi
Improve code readability reducing code indentation in
mt76u_alloc_tx
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/usb.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index 4c1abd492405..c30878d2dc5c 100644
--- 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);
+ if (!buf->urb->sg)
+ return -ENOMEM;
}
}
return 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mt76: usb: reduce code indentation in mt76u_alloc_tx
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
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2019-03-02 20:30 UTC (permalink / raw)
To: Lorenzo Bianconi, nbd; +Cc: linux-wireless, sgruszka, lorenzo.bianconi
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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mt76: usb: reduce code indentation in mt76u_alloc_tx
2019-03-02 20:30 ` Joe Perches
@ 2019-03-04 11:41 ` Lorenzo Bianconi
0 siblings, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2019-03-04 11:41 UTC (permalink / raw)
To: Joe Perches; +Cc: Lorenzo Bianconi, nbd, linux-wireless, sgruszka
[-- 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 --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-04 11:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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 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).