linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations
@ 2017-04-17 15:03 SF Markus Elfring
  2017-04-17 15:08 ` [PATCH 01/25] net: mvneta: Use devm_kmalloc_array() in mvneta_init() SF Markus Elfring
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:03 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 16:44:32 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (25):
  Use devm_kmalloc_array() in mvneta_init()
  Improve two size determinations in mvneta_init()
  Use kmalloc_array() in mvneta_txq_init()
  Adjust six checks for null pointers
  Use kmalloc_array() in mvpp2_txq_init()
  Improve two size determinations in mvpp2_probe()
  Improve another size determination in mvpp2_init()
  Improve another size determination in mvpp2_port_probe()
  Improve another size determination in mvpp2_bm_init()
  Improve another size determination in mvpp2_prs_default_init()
  Improve 27 size determinations
  Improve a size determination in two functions
  Fix a jump label position in mvpp2_rx()
  Rename a jump label in two functions
  Adjust three error messages
  Rename a jump label in mvpp2_tx_frag_process()
  Rename a jump label in mvpp2_txq_init()
  Rename a jump label in mvpp2_prs_double_vlan_add()
  Rename a jump label in mvpp2_prs_vlan_add()
  Adjust a null pointer check in mvpp2_egress_enable()
  Use kcalloc() in two functions
  Adjust four checks for null pointers
  Use seq_puts() in skge_debug_show()
  Adjust a null pointer check in skge_down()
  Use seq_puts() in sky2_debug_show()

 drivers/net/ethernet/marvell/mvneta.c     |  29 +++----
 drivers/net/ethernet/marvell/mvpp2.c      | 127 ++++++++++++++----------------
 drivers/net/ethernet/marvell/pxa168_eth.c |  14 ++--
 drivers/net/ethernet/marvell/skge.c       |   4 +-
 drivers/net/ethernet/marvell/sky2.c       |   2 +-
 5 files changed, 84 insertions(+), 92 deletions(-)

-- 
2.12.2

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 01/25] net: mvneta: Use devm_kmalloc_array() in mvneta_init()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
@ 2017-04-17 15:08 ` SF Markus Elfring
  2017-04-17 15:10 ` [PATCH 02/25] net: mvneta: Improve two size determinations " SF Markus Elfring
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:08 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Apr 2017 21:23:19 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "devm_kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvneta.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 34a3686d2ce6..46fa74e93814 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4017,9 +4017,11 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp)
 		rxq->size = pp->rx_ring_size;
 		rxq->pkts_coal = MVNETA_RX_COAL_PKTS;
 		rxq->time_coal = MVNETA_RX_COAL_USEC;
-		rxq->buf_virt_addr = devm_kmalloc(pp->dev->dev.parent,
-						  rxq->size * sizeof(void *),
-						  GFP_KERNEL);
+		rxq->buf_virt_addr
+			= devm_kmalloc_array(pp->dev->dev.parent,
+					     rxq->size,
+					     sizeof(*rxq->buf_virt_addr),
+					     GFP_KERNEL);
 		if (!rxq->buf_virt_addr)
 			return -ENOMEM;
 	}
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 02/25] net: mvneta: Improve two size determinations in mvneta_init()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
  2017-04-17 15:08 ` [PATCH 01/25] net: mvneta: Use devm_kmalloc_array() in mvneta_init() SF Markus Elfring
@ 2017-04-17 15:10 ` SF Markus Elfring
  2017-04-17 15:13 ` [PATCH 03/25] net: mvneta: Use kmalloc_array() in mvneta_txq_init() SF Markus Elfring
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:10 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Apr 2017 21:45:38 +0200

Replace the specification of two data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvneta.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 46fa74e93814..9c9eed5a8e28 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3992,8 +3992,7 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp)
 	/* Set port default values */
 	mvneta_defaults_set(pp);
 
-	pp->txqs = devm_kcalloc(dev, txq_number, sizeof(struct mvneta_tx_queue),
-				GFP_KERNEL);
+	pp->txqs = devm_kcalloc(dev, txq_number, sizeof(*pp->txqs), GFP_KERNEL);
 	if (!pp->txqs)
 		return -ENOMEM;
 
@@ -4005,8 +4004,7 @@ static int mvneta_init(struct device *dev, struct mvneta_port *pp)
 		txq->done_pkts_coal = MVNETA_TXDONE_COAL_PKTS;
 	}
 
-	pp->rxqs = devm_kcalloc(dev, rxq_number, sizeof(struct mvneta_rx_queue),
-				GFP_KERNEL);
+	pp->rxqs = devm_kcalloc(dev, rxq_number, sizeof(*pp->rxqs), GFP_KERNEL);
 	if (!pp->rxqs)
 		return -ENOMEM;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 03/25] net: mvneta: Use kmalloc_array() in mvneta_txq_init()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
  2017-04-17 15:08 ` [PATCH 01/25] net: mvneta: Use devm_kmalloc_array() in mvneta_init() SF Markus Elfring
  2017-04-17 15:10 ` [PATCH 02/25] net: mvneta: Improve two size determinations " SF Markus Elfring
@ 2017-04-17 15:13 ` SF Markus Elfring
  2017-04-17 15:14 ` [PATCH 04/25] net: mvneta: Adjust six checks for null pointers SF Markus Elfring
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:13 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Apr 2017 22:11:22 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvneta.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 9c9eed5a8e28..9c2ddd22a86f 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2933,7 +2933,8 @@ static int mvneta_txq_init(struct mvneta_port *pp,
 	mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), txq->descs_phys);
 	mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), txq->size);
 
-	txq->tx_skb = kmalloc(txq->size * sizeof(*txq->tx_skb), GFP_KERNEL);
+	txq->tx_skb = kmalloc_array(txq->size, sizeof(*txq->tx_skb),
+				    GFP_KERNEL);
 	if (txq->tx_skb == NULL) {
 		dma_free_coherent(pp->dev->dev.parent,
 				  txq->size * MVNETA_DESC_ALIGNED_SIZE,
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 04/25] net: mvneta: Adjust six checks for null pointers
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (2 preceding siblings ...)
  2017-04-17 15:13 ` [PATCH 03/25] net: mvneta: Use kmalloc_array() in mvneta_txq_init() SF Markus Elfring
@ 2017-04-17 15:14 ` SF Markus Elfring
  2017-04-17 15:15 ` [PATCH 05/25] net: mvpp2: Use kmalloc_array() in mvpp2_txq_init() SF Markus Elfring
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:14 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Apr 2017 22:45:33 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvneta.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 9c2ddd22a86f..6f436db8b01e 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1107,7 +1107,7 @@ static void mvneta_port_up(struct mvneta_port *pp)
 	q_map = 0;
 	for (queue = 0; queue < txq_number; queue++) {
 		struct mvneta_tx_queue *txq = &pp->txqs[queue];
-		if (txq->descs != NULL)
+		if (txq->descs)
 			q_map |= (1 << queue);
 	}
 	mvreg_write(pp, MVNETA_TXQ_CMD, q_map);
@@ -1116,7 +1116,7 @@ static void mvneta_port_up(struct mvneta_port *pp)
 	for (queue = 0; queue < rxq_number; queue++) {
 		struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
 
-		if (rxq->descs != NULL)
+		if (rxq->descs)
 			q_map |= (1 << queue);
 	}
 	mvreg_write(pp, MVNETA_RXQ_CMD, q_map);
@@ -2850,7 +2850,7 @@ static int mvneta_rxq_init(struct mvneta_port *pp,
 	rxq->descs = dma_alloc_coherent(pp->dev->dev.parent,
 					rxq->size * MVNETA_DESC_ALIGNED_SIZE,
 					&rxq->descs_phys, GFP_KERNEL);
-	if (rxq->descs == NULL)
+	if (!rxq->descs)
 		return -ENOMEM;
 
 	rxq->last_desc = rxq->size - 1;
@@ -2920,7 +2920,7 @@ static int mvneta_txq_init(struct mvneta_port *pp,
 	txq->descs = dma_alloc_coherent(pp->dev->dev.parent,
 					txq->size * MVNETA_DESC_ALIGNED_SIZE,
 					&txq->descs_phys, GFP_KERNEL);
-	if (txq->descs == NULL)
+	if (!txq->descs)
 		return -ENOMEM;
 
 	txq->last_desc = txq->size - 1;
@@ -2935,7 +2935,7 @@ static int mvneta_txq_init(struct mvneta_port *pp,
 
 	txq->tx_skb = kmalloc_array(txq->size, sizeof(*txq->tx_skb),
 				    GFP_KERNEL);
-	if (txq->tx_skb == NULL) {
+	if (!txq->tx_skb) {
 		dma_free_coherent(pp->dev->dev.parent,
 				  txq->size * MVNETA_DESC_ALIGNED_SIZE,
 				  txq->descs, txq->descs_phys);
@@ -2946,7 +2946,7 @@ static int mvneta_txq_init(struct mvneta_port *pp,
 	txq->tso_hdrs = dma_alloc_coherent(pp->dev->dev.parent,
 					   txq->size * TSO_HEADER_SIZE,
 					   &txq->tso_hdrs_phys, GFP_KERNEL);
-	if (txq->tso_hdrs == NULL) {
+	if (!txq->tso_hdrs) {
 		kfree(txq->tx_skb);
 		dma_free_coherent(pp->dev->dev.parent,
 				  txq->size * MVNETA_DESC_ALIGNED_SIZE,
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 05/25] net: mvpp2: Use kmalloc_array() in mvpp2_txq_init()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (3 preceding siblings ...)
  2017-04-17 15:14 ` [PATCH 04/25] net: mvneta: Adjust six checks for null pointers SF Markus Elfring
@ 2017-04-17 15:15 ` SF Markus Elfring
  2017-04-17 15:16 ` [PATCH 06/25] net: mvpp2: Improve two size determinations in mvpp2_probe() SF Markus Elfring
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:15 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 08:09:07 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index af5bfa13d976..a86d9111c476 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5083,9 +5083,9 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
 	for_each_present_cpu(cpu) {
 		txq_pcpu = per_cpu_ptr(txq->pcpu, cpu);
 		txq_pcpu->size = txq->size;
-		txq_pcpu->buffs = kmalloc(txq_pcpu->size *
-					  sizeof(struct mvpp2_txq_pcpu_buf),
-					  GFP_KERNEL);
+		txq_pcpu->buffs = kmalloc_array(txq_pcpu->size,
+						sizeof(*txq_pcpu->buffs),
+						GFP_KERNEL);
 		if (!txq_pcpu->buffs)
 			goto error;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 06/25] net: mvpp2: Improve two size determinations in mvpp2_probe()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (4 preceding siblings ...)
  2017-04-17 15:15 ` [PATCH 05/25] net: mvpp2: Use kmalloc_array() in mvpp2_txq_init() SF Markus Elfring
@ 2017-04-17 15:16 ` SF Markus Elfring
  2017-04-17 15:17 ` [PATCH 07/25] net: mvpp2: Improve another size determination in mvpp2_init() SF Markus Elfring
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:16 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 08:38:32 +0200

Replace the specification of two data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index a86d9111c476..04aba2307b60 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6873,7 +6873,7 @@ static int mvpp2_probe(struct platform_device *pdev)
 	int port_count, cpu;
 	int err;
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(struct mvpp2), GFP_KERNEL);
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
@@ -6970,8 +6970,8 @@ static int mvpp2_probe(struct platform_device *pdev)
 	}
 
 	priv->port_list = devm_kcalloc(&pdev->dev, port_count,
-				      sizeof(struct mvpp2_port *),
-				      GFP_KERNEL);
+				       sizeof(*priv->port_list),
+				       GFP_KERNEL);
 	if (!priv->port_list) {
 		err = -ENOMEM;
 		goto err_mg_clk;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 07/25] net: mvpp2: Improve another size determination in mvpp2_init()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (5 preceding siblings ...)
  2017-04-17 15:16 ` [PATCH 06/25] net: mvpp2: Improve two size determinations in mvpp2_probe() SF Markus Elfring
@ 2017-04-17 15:17 ` SF Markus Elfring
  2017-04-17 15:18 ` [PATCH 08/25] net: mvpp2: Improve another size determination in mvpp2_port_probe() SF Markus Elfring
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:17 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 08:48:23 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 04aba2307b60..e35c4d0b112a 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6806,7 +6806,7 @@ static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv)
 
 	/* Allocate and initialize aggregated TXQs */
 	priv->aggr_txqs = devm_kcalloc(&pdev->dev, num_present_cpus(),
-				       sizeof(struct mvpp2_tx_queue),
+				       sizeof(*priv->aggr_txqs),
 				       GFP_KERNEL);
 	if (!priv->aggr_txqs)
 		return -ENOMEM;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 08/25] net: mvpp2: Improve another size determination in mvpp2_port_probe()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (6 preceding siblings ...)
  2017-04-17 15:17 ` [PATCH 07/25] net: mvpp2: Improve another size determination in mvpp2_init() SF Markus Elfring
@ 2017-04-17 15:18 ` SF Markus Elfring
  2017-04-17 15:19 ` [PATCH 09/25] net: mvpp2: Improve another size determination in mvpp2_bm_init() SF Markus Elfring
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:18 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 08:55:42 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index e35c4d0b112a..8f1fec2986f9 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6487,8 +6487,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
 	int phy_mode;
 	int err, i, cpu;
 
-	dev = alloc_etherdev_mqs(sizeof(struct mvpp2_port), txq_number,
-				 rxq_number);
+	dev = alloc_etherdev_mqs(sizeof(*port), txq_number, rxq_number);
 	if (!dev)
 		return -ENOMEM;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 09/25] net: mvpp2: Improve another size determination in mvpp2_bm_init()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (7 preceding siblings ...)
  2017-04-17 15:18 ` [PATCH 08/25] net: mvpp2: Improve another size determination in mvpp2_port_probe() SF Markus Elfring
@ 2017-04-17 15:19 ` SF Markus Elfring
  2017-04-17 15:20 ` [PATCH 10/25] net: mvpp2: Improve another size determination in mvpp2_prs_default_init() SF Markus Elfring
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:19 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 09:06:33 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 8f1fec2986f9..8fb039b2073e 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3833,7 +3833,7 @@ static int mvpp2_bm_init(struct platform_device *pdev, struct mvpp2 *priv)
 
 	/* Allocate and initialize BM pools */
 	priv->bm_pools = devm_kcalloc(&pdev->dev, MVPP2_BM_POOLS_NUM,
-				     sizeof(struct mvpp2_bm_pool), GFP_KERNEL);
+				      sizeof(*priv->bm_pools), GFP_KERNEL);
 	if (!priv->bm_pools)
 		return -ENOMEM;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 10/25] net: mvpp2: Improve another size determination in mvpp2_prs_default_init()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (8 preceding siblings ...)
  2017-04-17 15:19 ` [PATCH 09/25] net: mvpp2: Improve another size determination in mvpp2_bm_init() SF Markus Elfring
@ 2017-04-17 15:20 ` SF Markus Elfring
  2017-04-17 15:21 ` [PATCH 11/25] net: mvpp2: Improve 27 size determinations SF Markus Elfring
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:20 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 09:12:34 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 8fb039b2073e..abf084b43af7 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3205,7 +3205,7 @@ static int mvpp2_prs_default_init(struct platform_device *pdev,
 		mvpp2_prs_hw_inv(priv, index);
 
 	priv->prs_shadow = devm_kcalloc(&pdev->dev, MVPP2_PRS_TCAM_SRAM_SIZE,
-					sizeof(struct mvpp2_prs_shadow),
+					sizeof(*priv->prs_shadow),
 					GFP_KERNEL);
 	if (!priv->prs_shadow)
 		return -ENOMEM;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 11/25] net: mvpp2: Improve 27 size determinations
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (9 preceding siblings ...)
  2017-04-17 15:20 ` [PATCH 10/25] net: mvpp2: Improve another size determination in mvpp2_prs_default_init() SF Markus Elfring
@ 2017-04-17 15:21 ` SF Markus Elfring
  2017-04-17 15:22 ` [PATCH 12/25] net: mvpp2: Improve a size determination in two functions SF Markus Elfring
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:21 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 10:30:29 +0200

Replace the specification of data structures by references to
a local variable as the parameter for the operator "sizeof"
to make the corresponding size determination a bit safer.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 54 ++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index abf084b43af7..61fd87d0a4ec 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -1689,7 +1689,7 @@ static void mvpp2_prs_mac_drop_all_set(struct mvpp2 *priv, int port, bool add)
 		mvpp2_prs_hw_read(priv, &pe);
 	} else {
 		/* Entry doesn't exist - create new */
-		memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+		memset(&pe, 0, sizeof(pe));
 		mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC);
 		pe.index = MVPP2_PE_DROP_ALL;
 
@@ -1726,7 +1726,7 @@ static void mvpp2_prs_mac_promisc_set(struct mvpp2 *priv, int port, bool add)
 		mvpp2_prs_hw_read(priv, &pe);
 	} else {
 		/* Entry doesn't exist - create new */
-		memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+		memset(&pe, 0, sizeof(pe));
 		mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC);
 		pe.index = MVPP2_PE_MAC_PROMISCUOUS;
 
@@ -1772,7 +1772,7 @@ static void mvpp2_prs_mac_multi_set(struct mvpp2 *priv, int port, int index,
 		mvpp2_prs_hw_read(priv, &pe);
 	} else {
 		/* Entry doesn't exist - create new */
-		memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+		memset(&pe, 0, sizeof(pe));
 		mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC);
 		pe.index = index;
 
@@ -1824,7 +1824,7 @@ static void mvpp2_prs_dsa_tag_set(struct mvpp2 *priv, int port, bool add,
 		mvpp2_prs_hw_read(priv, &pe);
 	} else {
 		/* Entry doesn't exist - create new */
-		memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+		memset(&pe, 0, sizeof(pe));
 		mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA);
 		pe.index = tid;
 
@@ -1887,7 +1887,7 @@ static void mvpp2_prs_dsa_tag_ethertype_set(struct mvpp2 *priv, int port,
 		mvpp2_prs_hw_read(priv, &pe);
 	} else {
 		/* Entry doesn't exist - create new */
-		memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+		memset(&pe, 0, sizeof(pe));
 		mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA);
 		pe.index = tid;
 
@@ -2212,7 +2212,7 @@ static int mvpp2_prs_ip4_proto(struct mvpp2 *priv, unsigned short proto,
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4);
 	pe.index = tid;
 
@@ -2270,7 +2270,7 @@ static int mvpp2_prs_ip4_cast(struct mvpp2 *priv, unsigned short l3_cast)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4);
 	pe.index = tid;
 
@@ -2326,7 +2326,7 @@ static int mvpp2_prs_ip6_proto(struct mvpp2 *priv, unsigned short proto,
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6);
 	pe.index = tid;
 
@@ -2365,7 +2365,7 @@ static int mvpp2_prs_ip6_cast(struct mvpp2 *priv, unsigned short l3_cast)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6);
 	pe.index = tid;
 
@@ -2425,7 +2425,7 @@ static void mvpp2_prs_def_flow_init(struct mvpp2 *priv)
 	int port;
 
 	for (port = 0; port < MVPP2_MAX_PORTS; port++) {
-		memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+		memset(&pe, 0, sizeof(pe));
 		mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_FLOWS);
 		pe.index = MVPP2_PE_FIRST_DEFAULT_FLOW - port;
 
@@ -2447,7 +2447,7 @@ static void mvpp2_prs_mh_init(struct mvpp2 *priv)
 {
 	struct mvpp2_prs_entry pe;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 
 	pe.index = MVPP2_PE_MH_DEFAULT;
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MH);
@@ -2470,7 +2470,7 @@ static void mvpp2_prs_mac_init(struct mvpp2 *priv)
 {
 	struct mvpp2_prs_entry pe;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 
 	/* Non-promiscuous mode for all ports - DROP unknown packets */
 	pe.index = MVPP2_PE_MAC_NON_PROMISCUOUS;
@@ -2531,7 +2531,7 @@ static void mvpp2_prs_dsa_init(struct mvpp2 *priv)
 					MVPP2_PRS_TAGGED, MVPP2_PRS_DSA);
 
 	/* Set default entry, in case DSA or EDSA tag not found */
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA);
 	pe.index = MVPP2_PE_DSA_DEFAULT;
 	mvpp2_prs_sram_next_lu_set(&pe, MVPP2_PRS_LU_VLAN);
@@ -2561,7 +2561,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
 	pe.index = tid;
 
@@ -2587,7 +2587,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
 	pe.index = tid;
 
@@ -2617,7 +2617,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
 	pe.index = tid;
 
@@ -2651,7 +2651,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
 	pe.index = tid;
 
@@ -2716,7 +2716,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
 	pe.index = tid;
 
@@ -2813,7 +2813,7 @@ static int mvpp2_prs_vlan_init(struct platform_device *pdev, struct mvpp2 *priv)
 		return err;
 
 	/* Set default double vlan entry */
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_VLAN);
 	pe.index = MVPP2_PE_VLAN_DBL;
 
@@ -2833,7 +2833,7 @@ static int mvpp2_prs_vlan_init(struct platform_device *pdev, struct mvpp2 *priv)
 	mvpp2_prs_hw_write(priv, &pe);
 
 	/* Set default vlan none entry */
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_VLAN);
 	pe.index = MVPP2_PE_VLAN_NONE;
 
@@ -2863,7 +2863,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE);
 	pe.index = tid;
 
@@ -2913,7 +2913,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE);
 	pe.index = tid;
 
@@ -2940,7 +2940,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE);
 	pe.index = tid;
 
@@ -2998,7 +2998,7 @@ static int mvpp2_prs_ip4_init(struct mvpp2 *priv)
 		return err;
 
 	/* Default IPv4 entry for unknown protocols */
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4);
 	pe.index = MVPP2_PE_IP4_PROTO_UN;
 
@@ -3023,7 +3023,7 @@ static int mvpp2_prs_ip4_init(struct mvpp2 *priv)
 	mvpp2_prs_hw_write(priv, &pe);
 
 	/* Default IPv4 entry for unicast address */
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4);
 	pe.index = MVPP2_PE_IP4_ADDR_UN;
 
@@ -3091,7 +3091,7 @@ static int mvpp2_prs_ip6_init(struct mvpp2 *priv)
 	if (tid < 0)
 		return tid;
 
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6);
 	pe.index = tid;
 
@@ -3112,7 +3112,7 @@ static int mvpp2_prs_ip6_init(struct mvpp2 *priv)
 	mvpp2_prs_hw_write(priv, &pe);
 
 	/* Default IPv6 entry for unknown protocols */
-	memset(&pe, 0, sizeof(struct mvpp2_prs_entry));
+	memset(&pe, 0, sizeof(pe));
 	mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6);
 	pe.index = MVPP2_PE_IP6_PROTO_UN;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 12/25] net: mvpp2: Improve a size determination in two functions
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (10 preceding siblings ...)
  2017-04-17 15:21 ` [PATCH 11/25] net: mvpp2: Improve 27 size determinations SF Markus Elfring
@ 2017-04-17 15:22 ` SF Markus Elfring
  2017-04-17 15:23 ` [PATCH 13/25] net: mvpp2: Fix a jump label position in mvpp2_rx() SF Markus Elfring
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:22 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 10:40:32 +0200

Replace the specification of two data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 61fd87d0a4ec..3bddb8fcd595 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -2024,7 +2024,7 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
 			goto error;
 		}
 
-		memset(pe, 0 , sizeof(struct mvpp2_prs_entry));
+		memset(pe, 0, sizeof(*pe));
 		mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN);
 		pe->index = tid;
 
@@ -2165,7 +2165,7 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
 			goto error;
 		}
 
-		memset(pe, 0, sizeof(struct mvpp2_prs_entry));
+		memset(pe, 0, sizeof(*pe));
 		mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN);
 		pe->index = tid;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 13/25] net: mvpp2: Fix a jump label position in mvpp2_rx()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (11 preceding siblings ...)
  2017-04-17 15:22 ` [PATCH 12/25] net: mvpp2: Improve a size determination in two functions SF Markus Elfring
@ 2017-04-17 15:23 ` SF Markus Elfring
  2017-04-17 15:24 ` [PATCH 14/25] net: mvpp2: Rename a jump label in two functions SF Markus Elfring
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:23 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 10:52:02 +0200

The script "checkpatch.pl" pointed out that labels should not be indented.
Thus delete two horizontal tabs before the jump label "err_drop_frame"
in the function "mvpp2_rx".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 3bddb8fcd595..4f4b659d7297 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5515,7 +5515,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
 		 * comprised by the RX descriptor.
 		 */
 		if (rx_status & MVPP2_RXD_ERR_SUMMARY) {
-		err_drop_frame:
+err_drop_frame:
 			dev->stats.rx_errors++;
 			mvpp2_rx_error(port, rx_desc);
 			/* Return the buffer to the pool */
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 14/25] net: mvpp2: Rename a jump label in two functions
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (12 preceding siblings ...)
  2017-04-17 15:23 ` [PATCH 13/25] net: mvpp2: Fix a jump label position in mvpp2_rx() SF Markus Elfring
@ 2017-04-17 15:24 ` SF Markus Elfring
  2017-04-17 15:25 ` [PATCH 15/25] net: mvpp2: Adjust three error messages SF Markus Elfring
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:24 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 11:10:47 +0200

Adjust jump labels according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 4f4b659d7297..89237abf386d 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6065,7 +6065,7 @@ static int mvpp2_set_mac_address(struct net_device *dev, void *p)
 
 	if (!is_valid_ether_addr(addr->sa_data)) {
 		err = -EADDRNOTAVAIL;
-		goto error;
+		goto log_error;
 	}
 
 	if (!netif_running(dev)) {
@@ -6075,7 +6075,7 @@ static int mvpp2_set_mac_address(struct net_device *dev, void *p)
 		/* Reconfigure parser to accept the original MAC address */
 		err = mvpp2_prs_update_mac_da(dev, dev->dev_addr);
 		if (err)
-			goto error;
+			goto log_error;
 	}
 
 	mvpp2_stop_dev(port);
@@ -6087,14 +6087,13 @@ static int mvpp2_set_mac_address(struct net_device *dev, void *p)
 	/* Reconfigure parser accept the original MAC address */
 	err = mvpp2_prs_update_mac_da(dev, dev->dev_addr);
 	if (err)
-		goto error;
+		goto log_error;
 out_start:
 	mvpp2_start_dev(port);
 	mvpp2_egress_enable(port);
 	mvpp2_ingress_enable(port);
 	return 0;
-
-error:
+log_error:
 	netdev_err(dev, "fail to change MAC address\n");
 	return err;
 }
@@ -6120,7 +6119,7 @@ static int mvpp2_change_mtu(struct net_device *dev, int mtu)
 		/* Reconfigure BM to the original MTU */
 		err = mvpp2_bm_update_mtu(dev, dev->mtu);
 		if (err)
-			goto error;
+			goto log_error;
 	}
 
 	mvpp2_stop_dev(port);
@@ -6134,7 +6133,7 @@ static int mvpp2_change_mtu(struct net_device *dev, int mtu)
 	/* Reconfigure BM to the original MTU */
 	err = mvpp2_bm_update_mtu(dev, dev->mtu);
 	if (err)
-		goto error;
+		goto log_error;
 
 out_start:
 	mvpp2_start_dev(port);
@@ -6142,8 +6141,7 @@ static int mvpp2_change_mtu(struct net_device *dev, int mtu)
 	mvpp2_ingress_enable(port);
 
 	return 0;
-
-error:
+log_error:
 	netdev_err(dev, "fail to change MTU\n");
 	return err;
 }
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 15/25] net: mvpp2: Adjust three error messages
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (13 preceding siblings ...)
  2017-04-17 15:24 ` [PATCH 14/25] net: mvpp2: Rename a jump label in two functions SF Markus Elfring
@ 2017-04-17 15:25 ` SF Markus Elfring
  2017-04-17 15:26 ` [PATCH 16/25] net: mvpp2: Rename a jump label in mvpp2_tx_frag_process() SF Markus Elfring
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:25 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 11:20:41 +0200

Use the word "failed" in the string for three function calls.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 89237abf386d..717d79dcb6aa 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6094,7 +6094,7 @@ static int mvpp2_set_mac_address(struct net_device *dev, void *p)
 	mvpp2_ingress_enable(port);
 	return 0;
 log_error:
-	netdev_err(dev, "fail to change MAC address\n");
+	netdev_err(dev, "failed to change MAC address\n");
 	return err;
 }
 
@@ -6142,7 +6142,7 @@ static int mvpp2_change_mtu(struct net_device *dev, int mtu)
 
 	return 0;
 log_error:
-	netdev_err(dev, "fail to change MTU\n");
+	netdev_err(dev, "failed to change MTU\n");
 	return err;
 }
 
@@ -6311,7 +6311,7 @@ static int mvpp2_ethtool_set_ringparam(struct net_device *dev,
 err_clean_rxqs:
 	mvpp2_cleanup_rxqs(port);
 err_out:
-	netdev_err(dev, "fail to change ring parameters");
+	netdev_err(dev, "failed to change ring parameters");
 	return err;
 }
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 16/25] net: mvpp2: Rename a jump label in mvpp2_tx_frag_process()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (14 preceding siblings ...)
  2017-04-17 15:25 ` [PATCH 15/25] net: mvpp2: Adjust three error messages SF Markus Elfring
@ 2017-04-17 15:26 ` SF Markus Elfring
  2017-04-17 15:27 ` [PATCH 17/25] net: mvpp2: Rename a jump label in mvpp2_txq_init() SF Markus Elfring
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:26 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 11:36:34 +0200

Adjust jump labels according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 717d79dcb6aa..8f4348316d28 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5606,7 +5606,7 @@ static int mvpp2_tx_frag_process(struct mvpp2_port *port, struct sk_buff *skb,
 					       DMA_TO_DEVICE);
 		if (dma_mapping_error(port->dev->dev.parent, buf_dma_addr)) {
 			mvpp2_txq_desc_put(txq);
-			goto error;
+			goto cleanup;
 		}
 
 		mvpp2_txdesc_offset_set(port, tx_desc,
@@ -5627,8 +5627,7 @@ static int mvpp2_tx_frag_process(struct mvpp2_port *port, struct sk_buff *skb,
 	}
 
 	return 0;
-
-error:
+cleanup:
 	/* Release all descriptors that were used to map fragments of
 	 * this packet, as well as the corresponding DMA mappings
 	 */
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 17/25] net: mvpp2: Rename a jump label in mvpp2_txq_init()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (15 preceding siblings ...)
  2017-04-17 15:26 ` [PATCH 16/25] net: mvpp2: Rename a jump label in mvpp2_tx_frag_process() SF Markus Elfring
@ 2017-04-17 15:27 ` SF Markus Elfring
  2017-04-17 15:28 ` [PATCH 18/25] net: mvpp2: Rename a jump label in mvpp2_prs_double_vlan_add() SF Markus Elfring
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:27 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 12:58:33 +0200

Adjust jump labels according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 8f4348316d28..a5cd1036012a 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5087,7 +5087,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
 						sizeof(*txq_pcpu->buffs),
 						GFP_KERNEL);
 		if (!txq_pcpu->buffs)
-			goto error;
+			goto cleanup;
 
 		txq_pcpu->count = 0;
 		txq_pcpu->reserved_num = 0;
@@ -5096,8 +5096,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
 	}
 
 	return 0;
-
-error:
+cleanup:
 	for_each_present_cpu(cpu) {
 		txq_pcpu = per_cpu_ptr(txq->pcpu, cpu);
 		kfree(txq_pcpu->buffs);
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 18/25] net: mvpp2: Rename a jump label in mvpp2_prs_double_vlan_add()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (16 preceding siblings ...)
  2017-04-17 15:27 ` [PATCH 17/25] net: mvpp2: Rename a jump label in mvpp2_txq_init() SF Markus Elfring
@ 2017-04-17 15:28 ` SF Markus Elfring
  2017-04-17 15:29 ` [PATCH 19/25] net: mvpp2: Rename a jump label in mvpp2_prs_vlan_add() SF Markus Elfring
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:28 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 13:03:49 +0200

Adjust jump labels according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index a5cd1036012a..0c190bd003b1 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -2139,7 +2139,7 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
 		ai = mvpp2_prs_double_vlan_ai_free_get(priv);
 		if (ai < 0) {
 			ret = ai;
-			goto error;
+			goto free_pe;
 		}
 
 		/* Get first single/triple vlan tid */
@@ -2162,7 +2162,7 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
 
 		if (tid >= tid_aux) {
 			ret = -ERANGE;
-			goto error;
+			goto free_pe;
 		}
 
 		memset(pe, 0, sizeof(*pe));
@@ -2189,8 +2189,7 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
 	/* Update ports' mask */
 	mvpp2_prs_tcam_port_map_set(pe, port_map);
 	mvpp2_prs_hw_write(priv, pe);
-
-error:
+free_pe:
 	kfree(pe);
 	return ret;
 }
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 19/25] net: mvpp2: Rename a jump label in mvpp2_prs_vlan_add()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (17 preceding siblings ...)
  2017-04-17 15:28 ` [PATCH 18/25] net: mvpp2: Rename a jump label in mvpp2_prs_double_vlan_add() SF Markus Elfring
@ 2017-04-17 15:29 ` SF Markus Elfring
  2017-04-17 15:30 ` [PATCH 20/25] net: mvpp2: Adjust a null pointer check in mvpp2_egress_enable() SF Markus Elfring
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:29 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 13:50:35 +0200

Adjust jump labels according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 0c190bd003b1..3bdd3f1fe34e 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -2021,7 +2021,7 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
 
 		if (tid <= tid_aux) {
 			ret = -EINVAL;
-			goto error;
+			goto free_pe;
 		}
 
 		memset(pe, 0, sizeof(*pe));
@@ -2053,8 +2053,7 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
 	mvpp2_prs_tcam_port_map_set(pe, port_map);
 
 	mvpp2_prs_hw_write(priv, pe);
-
-error:
+free_pe:
 	kfree(pe);
 
 	return ret;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 20/25] net: mvpp2: Adjust a null pointer check in mvpp2_egress_enable()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (18 preceding siblings ...)
  2017-04-17 15:29 ` [PATCH 19/25] net: mvpp2: Rename a jump label in mvpp2_prs_vlan_add() SF Markus Elfring
@ 2017-04-17 15:30 ` SF Markus Elfring
  2017-04-17 15:31 ` [PATCH 21/25] net: pxa168_eth: Use kcalloc() in two functions SF Markus Elfring
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:30 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 14:07:52 +0200

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written "txq->descs".

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 3bdd3f1fe34e..9b875d776b29 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -4415,7 +4415,7 @@ static void mvpp2_egress_enable(struct mvpp2_port *port)
 	for (queue = 0; queue < txq_number; queue++) {
 		struct mvpp2_tx_queue *txq = port->txqs[queue];
 
-		if (txq->descs != NULL)
+		if (txq->descs)
 			qmap |= (1 << queue);
 	}
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 21/25] net: pxa168_eth: Use kcalloc() in two functions
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (19 preceding siblings ...)
  2017-04-17 15:30 ` [PATCH 20/25] net: mvpp2: Adjust a null pointer check in mvpp2_egress_enable() SF Markus Elfring
@ 2017-04-17 15:31 ` SF Markus Elfring
  2017-04-17 15:32 ` [PATCH 22/25] net: pxa168_eth: Adjust four checks for null pointers SF Markus Elfring
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:31 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 14:32:14 +0200

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/pxa168_eth.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 28cb36d9e50a..2404eac51c63 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1036,8 +1036,7 @@ static int rxq_init(struct net_device *dev)
 	int rx_desc_num = pep->rx_ring_size;
 
 	/* Allocate RX skb rings */
-	pep->rx_skb = kzalloc(sizeof(*pep->rx_skb) * pep->rx_ring_size,
-			     GFP_KERNEL);
+	pep->rx_skb = kcalloc(rx_desc_num, sizeof(*pep->rx_skb), GFP_KERNEL);
 	if (!pep->rx_skb)
 		return -ENOMEM;
 
@@ -1096,8 +1095,7 @@ static int txq_init(struct net_device *dev)
 	int size = 0, i = 0;
 	int tx_desc_num = pep->tx_ring_size;
 
-	pep->tx_skb = kzalloc(sizeof(*pep->tx_skb) * pep->tx_ring_size,
-			     GFP_KERNEL);
+	pep->tx_skb = kcalloc(tx_desc_num, sizeof(*pep->tx_skb), GFP_KERNEL);
 	if (!pep->tx_skb)
 		return -ENOMEM;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 22/25] net: pxa168_eth: Adjust four checks for null pointers
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (20 preceding siblings ...)
  2017-04-17 15:31 ` [PATCH 21/25] net: pxa168_eth: Use kcalloc() in two functions SF Markus Elfring
@ 2017-04-17 15:32 ` SF Markus Elfring
  2017-04-17 15:33 ` [PATCH 23/25] skge: Use seq_puts() in skge_debug_show() SF Markus Elfring
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:32 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 15:23:45 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/pxa168_eth.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 2404eac51c63..993724959a7c 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -556,11 +556,11 @@ static int init_hash_table(struct pxa168_eth_private *pep)
 	 * function.Driver can dynamically switch to them if the 1/2kB hash
 	 * table is full.
 	 */
-	if (pep->htpr == NULL) {
+	if (!pep->htpr) {
 		pep->htpr = dma_zalloc_coherent(pep->dev->dev.parent,
 						HASH_ADDR_TABLE_SIZE,
 						&pep->htpr_dma, GFP_KERNEL);
-		if (pep->htpr == NULL)
+		if (!pep->htpr)
 			return -ENOMEM;
 	} else {
 		memset(pep->htpr, 0, HASH_ADDR_TABLE_SIZE);
@@ -1356,7 +1356,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum,
 static int pxa168_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr,
 			       int cmd)
 {
-	if (dev->phydev != NULL)
+	if (dev->phydev)
 		return phy_mii_ioctl(dev->phydev, ifr, cmd);
 
 	return -EOPNOTSUPP;
@@ -1501,7 +1501,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
 	pep->timeout.data = (unsigned long)pep;
 
 	pep->smi_bus = mdiobus_alloc();
-	if (pep->smi_bus == NULL) {
+	if (!pep->smi_bus) {
 		err = -ENOMEM;
 		goto err_netdev;
 	}
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 23/25] skge: Use seq_puts() in skge_debug_show()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (21 preceding siblings ...)
  2017-04-17 15:32 ` [PATCH 22/25] net: pxa168_eth: Adjust four checks for null pointers SF Markus Elfring
@ 2017-04-17 15:33 ` SF Markus Elfring
  2017-04-17 15:34 ` [PATCH 24/25] skge: Adjust a null pointer check in skge_down() SF Markus Elfring
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:33 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 15:43:08 +0200

A string which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/skge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index edb95271a4f2..90bfdbcfd910 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -3718,7 +3718,7 @@ static int skge_debug_show(struct seq_file *seq, void *v)
 			   t->csum_offs, t->csum_write, t->csum_start);
 	}
 
-	seq_printf(seq, "\nRx Ring:\n");
+	seq_puts(seq, "\nRx Ring:\n");
 	for (e = skge->rx_ring.to_clean; ; e = e->next) {
 		const struct skge_rx_desc *r = e->desc;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 24/25] skge: Adjust a null pointer check in skge_down()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (22 preceding siblings ...)
  2017-04-17 15:33 ` [PATCH 23/25] skge: Use seq_puts() in skge_debug_show() SF Markus Elfring
@ 2017-04-17 15:34 ` SF Markus Elfring
  2017-04-17 15:35 ` [PATCH 25/25] sky2: Use seq_puts() in sky2_debug_show() SF Markus Elfring
  2017-04-18 18:09 ` [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations David Miller
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:34 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 16:08:39 +0200

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written "!skge->mem".

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/skge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 90bfdbcfd910..5d7d94de4e00 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -2657,7 +2657,7 @@ static int skge_down(struct net_device *dev)
 	struct skge_hw *hw = skge->hw;
 	int port = skge->port;
 
-	if (skge->mem == NULL)
+	if (!skge->mem)
 		return 0;
 
 	netif_info(skge, ifdown, skge->netdev, "disabling interface\n");
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 25/25] sky2: Use seq_puts() in sky2_debug_show()
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (23 preceding siblings ...)
  2017-04-17 15:34 ` [PATCH 24/25] skge: Adjust a null pointer check in skge_down() SF Markus Elfring
@ 2017-04-17 15:35 ` SF Markus Elfring
  2017-04-18 18:09 ` [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations David Miller
  25 siblings, 0 replies; 27+ messages in thread
From: SF Markus Elfring @ 2017-04-17 15:35 UTC (permalink / raw)
  To: netdev, David S. Miller, Florian Fainelli, Jarod Wilson,
	Jisheng Zhang, Mirko Lindner, Philippe Reynes, Russell King,
	Sergei Shtylyov, Stephen Hemminger, Thomas Petazzoni
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 16:15:12 +0200

A string which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/marvell/sky2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 2b2cc3f3ca10..1145cde2274a 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4544,7 +4544,7 @@ static int sky2_debug_show(struct seq_file *seq, void *v)
 		   sky2_read32(hw, B0_Y2_SP_ICR));
 
 	if (!netif_running(dev)) {
-		seq_printf(seq, "network not running\n");
+		seq_puts(seq, "network not running\n");
 		return 0;
 	}
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations
  2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
                   ` (24 preceding siblings ...)
  2017-04-17 15:35 ` [PATCH 25/25] sky2: Use seq_puts() in sky2_debug_show() SF Markus Elfring
@ 2017-04-18 18:09 ` David Miller
  25 siblings, 0 replies; 27+ messages in thread
From: David Miller @ 2017-04-18 18:09 UTC (permalink / raw)
  To: elfring
  Cc: netdev, f.fainelli, jarod, jszhang, mlindner, tremyfr,
	rmk+kernel, sergei.shtylyov, stephen, thomas.petazzoni,
	linux-kernel, kernel-janitors

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Apr 2017 17:03:33 +0200

> Several update suggestions were taken into account
> from static source code analysis.

Series applied.

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2017-04-18 18:09 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-17 15:03 [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations SF Markus Elfring
2017-04-17 15:08 ` [PATCH 01/25] net: mvneta: Use devm_kmalloc_array() in mvneta_init() SF Markus Elfring
2017-04-17 15:10 ` [PATCH 02/25] net: mvneta: Improve two size determinations " SF Markus Elfring
2017-04-17 15:13 ` [PATCH 03/25] net: mvneta: Use kmalloc_array() in mvneta_txq_init() SF Markus Elfring
2017-04-17 15:14 ` [PATCH 04/25] net: mvneta: Adjust six checks for null pointers SF Markus Elfring
2017-04-17 15:15 ` [PATCH 05/25] net: mvpp2: Use kmalloc_array() in mvpp2_txq_init() SF Markus Elfring
2017-04-17 15:16 ` [PATCH 06/25] net: mvpp2: Improve two size determinations in mvpp2_probe() SF Markus Elfring
2017-04-17 15:17 ` [PATCH 07/25] net: mvpp2: Improve another size determination in mvpp2_init() SF Markus Elfring
2017-04-17 15:18 ` [PATCH 08/25] net: mvpp2: Improve another size determination in mvpp2_port_probe() SF Markus Elfring
2017-04-17 15:19 ` [PATCH 09/25] net: mvpp2: Improve another size determination in mvpp2_bm_init() SF Markus Elfring
2017-04-17 15:20 ` [PATCH 10/25] net: mvpp2: Improve another size determination in mvpp2_prs_default_init() SF Markus Elfring
2017-04-17 15:21 ` [PATCH 11/25] net: mvpp2: Improve 27 size determinations SF Markus Elfring
2017-04-17 15:22 ` [PATCH 12/25] net: mvpp2: Improve a size determination in two functions SF Markus Elfring
2017-04-17 15:23 ` [PATCH 13/25] net: mvpp2: Fix a jump label position in mvpp2_rx() SF Markus Elfring
2017-04-17 15:24 ` [PATCH 14/25] net: mvpp2: Rename a jump label in two functions SF Markus Elfring
2017-04-17 15:25 ` [PATCH 15/25] net: mvpp2: Adjust three error messages SF Markus Elfring
2017-04-17 15:26 ` [PATCH 16/25] net: mvpp2: Rename a jump label in mvpp2_tx_frag_process() SF Markus Elfring
2017-04-17 15:27 ` [PATCH 17/25] net: mvpp2: Rename a jump label in mvpp2_txq_init() SF Markus Elfring
2017-04-17 15:28 ` [PATCH 18/25] net: mvpp2: Rename a jump label in mvpp2_prs_double_vlan_add() SF Markus Elfring
2017-04-17 15:29 ` [PATCH 19/25] net: mvpp2: Rename a jump label in mvpp2_prs_vlan_add() SF Markus Elfring
2017-04-17 15:30 ` [PATCH 20/25] net: mvpp2: Adjust a null pointer check in mvpp2_egress_enable() SF Markus Elfring
2017-04-17 15:31 ` [PATCH 21/25] net: pxa168_eth: Use kcalloc() in two functions SF Markus Elfring
2017-04-17 15:32 ` [PATCH 22/25] net: pxa168_eth: Adjust four checks for null pointers SF Markus Elfring
2017-04-17 15:33 ` [PATCH 23/25] skge: Use seq_puts() in skge_debug_show() SF Markus Elfring
2017-04-17 15:34 ` [PATCH 24/25] skge: Adjust a null pointer check in skge_down() SF Markus Elfring
2017-04-17 15:35 ` [PATCH 25/25] sky2: Use seq_puts() in sky2_debug_show() SF Markus Elfring
2017-04-18 18:09 ` [PATCH 00/25] Ethernet-Marvell: Fine-tuning for several function implementations David Miller

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).