Skip to contentSkip to conversation

SPI: Fine-tuning for several function implementations

PATCH In review SF Markus Elfring 4 participants 41 messages Jan 13, 2017 – Jan 17, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover SPI: Fine-tuning for several function implementations

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 17:50:23 +0100

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

Markus Elfring (17):
Use kcalloc() in spi_register_board_info()
Adjust checks for null pointers in two functions
fsl: Use kcalloc() in of_fsl_spi_get_chipselects()
fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects()
fsl: Combine substrings for two messages
mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe()
mpc52xx: Combine substrings for two messages
ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe()
ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe()
ppc4xx: Adjust checks for null pointers in two functions
topcliff-pch: Use kcalloc() in pch_spi_handle_dma()
topcliff-pch: Improve size determinations in pch_spi_probe()
topcliff-pch: Delete an unnecessary return statement in two functions
topcliff-pch: Adjust six checks for null pointers
topcliff-pch: Combine substrings for four messages
topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx()
topcliff-pch: One check less in pch_spi_set_tx()

 drivers/spi/spi-fsl-spi.c      | 17 +++++-----
 drivers/spi/spi-mpc52xx.c      | 12 +++----
 drivers/spi/spi-ppc4xx.c       | 15 ++++-----
 drivers/spi/spi-topcliff-pch.c | 71 +++++++++++++++++++++---------------------
 drivers/spi/spi.c              | 10 +++---
 5 files changed, 63 insertions(+), 62 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/17 spi: Use kcalloc() in spi_register_board_info()

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 12:28:04 +0100

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

This issue was detected by using the Coccinelle software.

---
 drivers/spi/spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
index 656dd3e3220c..8c05f27bf642 100644
@@ -672,7 +672,7 @@ int spi_register_board_info(struct spi_board_info const *info, unsigned n)
 	if (!n)
 		return -EINVAL;
 
-	bi = kzalloc(n * sizeof(*bi), GFP_KERNEL);
+	bi = kcalloc(n, sizeof(*bi), GFP_KERNEL);
 	if (!bi)
 		return -ENOMEM;
 
Signature · 1 line
2.11.0
#3 lore raw

PATCH 2/17 spi: Adjust checks for null pointers in two functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:23:32 +0100
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.

---
 drivers/spi/spi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi.c +4 -4
index 8c05f27bf642..d8d273545e54 100644
@@ -816,7 +816,7 @@ static int __spi_map_msg(struct spi_master *master, struct spi_message *msg)
 		if (!master->can_dma(master, msg->spi, xfer))
 			continue;
 
-		if (xfer->tx_buf != NULL) {
+		if (xfer->tx_buf) {
 			ret = spi_map_buf(master, tx_dev, &xfer->tx_sg,
 					  (void *)xfer->tx_buf, xfer->len,
 					  DMA_TO_DEVICE);
@@ -824,7 +824,7 @@ static int __spi_map_msg(struct spi_master *master, struct spi_message *msg)
 				return ret;
 		}
 
-		if (xfer->rx_buf != NULL) {
+		if (xfer->rx_buf) {
 			ret = spi_map_buf(master, rx_dev, &xfer->rx_sg,
 					  xfer->rx_buf, xfer->len,
 					  DMA_FROM_DEVICE);
@@ -3133,7 +3133,7 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action,
 	switch (of_reconfig_get_state_change(action, arg)) {
 	case OF_RECONFIG_CHANGE_ADD:
 		master = of_find_spi_master_by_node(rd->dn->parent);
-		if (master = NULL)
+		if (!master)
 			return NOTIFY_OK;	/* not for us */
 
 		if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) {
@@ -3159,7 +3159,7 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action,
 
 		/* find our device by node */
 		spi = of_find_spi_device_by_node(rd->dn);
-		if (spi = NULL)
+		if (!spi)
 			return NOTIFY_OK;	/* no? not meant for us */
 
 		/* unregister takes one ref away */
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH 3/17 spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:33:02 +0100

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

This issue was detected by using the Coccinelle software.

---
 drivers/spi/spi-fsl-spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-fsl-spi.c +1 -1
index 8b290d9d7935..d1b26c9fe950 100644
@@ -732,7 +732,7 @@ static int of_fsl_spi_get_chipselects(struct device *dev)
 		return -ENOMEM;
 	memset(pinfo->gpios, -1, ngpios * sizeof(*pinfo->gpios));
 
-	pinfo->alow_flags = kzalloc(ngpios * sizeof(*pinfo->alow_flags),
+	pinfo->alow_flags = kcalloc(ngpios, sizeof(*pinfo->alow_flags),
 				    GFP_KERNEL);
 	if (!pinfo->alow_flags) {
 		ret = -ENOMEM;
Signature · 1 line
2.11.0
#7 lore raw

PATCH 4/17 spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:37:25 +0100

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.

---
 drivers/spi/spi-fsl-spi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-fsl-spi.c +2 -1
index d1b26c9fe950..cdee556037f9 100644
@@ -727,7 +727,8 @@ static int of_fsl_spi_get_chipselects(struct device *dev)
 		return 0;
 	}
 
-	pinfo->gpios = kmalloc(ngpios * sizeof(*pinfo->gpios), GFP_KERNEL);
+	pinfo->gpios = kmalloc_array(ngpios, sizeof(*pinfo->gpios),
+				     GFP_KERNEL);
 	if (!pinfo->gpios)
 		return -ENOMEM;
 	memset(pinfo->gpios, -1, ngpios * sizeof(*pinfo->gpios));
Signature · 1 line
2.11.0
#10 lore raw

PATCH 5/17 spi: fsl: Combine substrings for two messages

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:50:21 +0100

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

WARNING: quoted string split across lines

Thus fix the affected source code places.

---
 drivers/spi/spi-fsl-spi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-spi.c +6 -6
index cdee556037f9..0fc3452652ae 100644
@@ -267,10 +267,9 @@ static int fsl_spi_setup_transfer(struct spi_device *spi,
 	if ((mpc8xxx_spi->spibrg / hz) > 64) {
 		cs->hw_mode |= SPMODE_DIV16;
 		pm = (mpc8xxx_spi->spibrg - 1) / (hz * 64) + 1;
-
-		WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. "
-			  "Will use %d Hz instead.\n", dev_name(&spi->dev),
-			  hz, mpc8xxx_spi->spibrg / 1024);
+		WARN_ONCE(pm > 16,
+			  "%s: Requested speed is too low: %d Hz. Will use %d Hz instead.\n",
+			  dev_name(&spi->dev), hz, mpc8xxx_spi->spibrg / 1024);
 		if (pm > 16)
 			pm = 16;
 	} else {
@@ -763,8 +762,9 @@ static int of_fsl_spi_get_chipselects(struct device *dev)
 		ret = gpio_direction_output(pinfo->gpios[i],
 					    pinfo->alow_flags[i]);
 		if (ret) {
-			dev_err(dev, "can't set output direction for gpio "
-				"#%d: %d\n", i, ret);
+			dev_err(dev,
+				"can't set output direction for gpio #%d: %d\n",
+				i, ret);
 			goto err_loop;
 		}
 	}
Signature · 1 line
2.11.0
#12 lore raw

PATCH 6/17 spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:06:10 +0100

* 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 type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/spi/spi-mpc52xx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-mpc52xx.c +3 -2
index c36002110c30..8cc129efe7ba 100644
@@ -437,8 +437,9 @@ static int mpc52xx_spi_probe(struct platform_device *op)
 	ms->gpio_cs_count = of_gpio_count(op->dev.of_node);
 	if (ms->gpio_cs_count > 0) {
 		master->num_chipselect = ms->gpio_cs_count;
-		ms->gpio_cs = kmalloc(ms->gpio_cs_count * sizeof(unsigned int),
-				GFP_KERNEL);
+		ms->gpio_cs = kmalloc_array(ms->gpio_cs_count,
+					    sizeof(*ms->gpio_cs),
+					    GFP_KERNEL);
 		if (!ms->gpio_cs) {
 			rc = -ENOMEM;
 			goto err_alloc_gpio;
Signature · 1 line
2.11.0
#14 lore raw

PATCH 7/17 spi/mpc52xx: Combine substrings for two messages

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:14:45 +0100

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

WARNING: quoted string split across lines

Thus fix the affected source code places.

---
 drivers/spi/spi-mpc52xx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/spi/spi-mpc52xx.c +3 -4
index 8cc129efe7ba..e8b59ce4dc3a 100644
@@ -449,8 +449,7 @@ static int mpc52xx_spi_probe(struct platform_device *op)
 			gpio_cs = of_get_gpio(op->dev.of_node, i);
 			if (gpio_cs < 0) {
 				dev_err(&op->dev,
-					"could not parse the gpio field "
-					"in oftree\n");
+					"could not parse the gpio field in oftree\n");
 				rc = -ENODEV;
 				goto err_gpio;
 			}
@@ -458,8 +457,8 @@ static int mpc52xx_spi_probe(struct platform_device *op)
 			rc = gpio_request(gpio_cs, dev_name(&op->dev));
 			if (rc) {
 				dev_err(&op->dev,
-					"can't request spi cs gpio #%d "
-					"on gpio line %d\n", i, gpio_cs);
+					"can't request spi cs gpio #%d on gpio line %d\n",
+					i, gpio_cs);
 				goto err_gpio;
 			}
 
Signature · 1 line
2.11.0
#17 lore raw

PATCH 8/17 spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:30:43 +0100

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

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.

---
 drivers/spi/spi-ppc4xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-ppc4xx.c +1 -1
index dd3d0a218d8b..e0c39734d6ef 100644
@@ -411,7 +411,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 	if (num_gpios > 0) {
 		int i;
 
-		hw->gpios = kzalloc(sizeof(int) * num_gpios, GFP_KERNEL);
+		hw->gpios = kcalloc(num_gpios, sizeof(*hw->gpios), GFP_KERNEL);
 		if (!hw->gpios) {
 			ret = -ENOMEM;
 			goto free_master;
Signature · 1 line
2.11.0
#19 lore raw

PATCH 9/17 spi/ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:43:06 +0100

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

WARNING: quoted string split across lines

Thus fix the affected source code place.

---
 drivers/spi/spi-ppc4xx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-ppc4xx.c +3 -2
index e0c39734d6ef..967d94844b30 100644
@@ -428,8 +428,9 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 				/* Real CS - set the initial state. */
 				ret = gpio_request(gpio, np->name);
 				if (ret < 0) {
-					dev_err(dev, "can't request gpio "
-							"#%d: %d\n", i, ret);
+					dev_err(dev,
+						"can't request gpio #%d: %d\n",
+						i, ret);
 					goto free_gpios;
 				}
 
Signature · 1 line
2.11.0
#21 lore raw

PATCH 10/17 spi/ppc4xx: Adjust checks for null pointers in two functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:56:10 +0100
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.

---
 drivers/spi/spi-ppc4xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-ppc4xx.c +4 -4
index 967d94844b30..048794f043a0 100644
@@ -229,7 +229,7 @@ static int spi_ppc4xx_setup(struct spi_device *spi)
 		return -EINVAL;
 	}
 
-	if (cs = NULL) {
+	if (!cs) {
 		cs = kzalloc(sizeof *cs, GFP_KERNEL);
 		if (!cs)
 			return -ENOMEM;
@@ -392,7 +392,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 	const unsigned int *clk;
 
 	master = spi_alloc_master(dev, sizeof *hw);
-	if (master = NULL)
+	if (!master)
 		return -ENOMEM;
 	master->dev.of_node = np;
 	platform_set_drvdata(op, master);
@@ -466,14 +466,14 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 
 	/* Get the clock for the OPB */
 	opbnp = of_find_compatible_node(NULL, NULL, "ibm,opb");
-	if (opbnp = NULL) {
+	if (!opbnp) {
 		dev_err(dev, "OPB: cannot find node\n");
 		ret = -ENODEV;
 		goto free_gpios;
 	}
 	/* Get the clock (Hz) for the OPB */
 	clk = of_get_property(opbnp, "clock-frequency", NULL);
-	if (clk = NULL) {
+	if (!clk) {
 		dev_err(dev, "OPB: no clock-frequency property set\n");
 		of_node_put(opbnp);
 		ret = -ENODEV;
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#27 lore raw

PATCH 11/17 spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 15:25:22 +0100

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

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

---
 drivers/spi/spi-topcliff-pch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-topcliff-pch.c +2 -2
index fcb991034c3d..0488b7c7cc19 100644
@@ -1008,7 +1008,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
 	spin_unlock_irqrestore(&data->lock, flags);
 
 	/* RX */
-	dma->sg_rx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC);
+	dma->sg_rx_p = kcalloc(num, sizeof(*dma->sg_rx_p), GFP_ATOMIC);
 	sg_init_table(dma->sg_rx_p, num); /* Initialize SG table */
 	/* offset, length setting */
 	sg = dma->sg_rx_p;
@@ -1068,7 +1068,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
 		head = 0;
 	}
 
-	dma->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC);
+	dma->sg_tx_p = kcalloc(num, sizeof(*dma->sg_tx_p), GFP_ATOMIC);
 	sg_init_table(dma->sg_tx_p, num); /* Initialize SG table */
 	/* offset, length setting */
 	sg = dma->sg_tx_p;
Signature · 1 line
2.11.0
#29 lore raw

PATCH 12/17 spi/topcliff-pch: Improve size determinations in pch_spi_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 15:46:35 +0100

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

---
 drivers/spi/spi-topcliff-pch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-topcliff-pch.c +2 -2
index 0488b7c7cc19..4bba39e70c7b 100644
@@ -1541,11 +1541,11 @@ static int pch_spi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	int i;
 	struct pch_pd_dev_save *pd_dev_save;
 
-	pd_dev_save = kzalloc(sizeof(struct pch_pd_dev_save), GFP_KERNEL);
+	pd_dev_save = kzalloc(sizeof(*pd_dev_save), GFP_KERNEL);
 	if (!pd_dev_save)
 		return -ENOMEM;
 
-	board_dat = kzalloc(sizeof(struct pch_spi_board_data), GFP_KERNEL);
+	board_dat = kzalloc(sizeof(*board_dat), GFP_KERNEL);
 	if (!board_dat) {
 		retval = -ENOMEM;
 		goto err_no_mem;
Signature · 1 line
2.11.0
#31 lore raw

PATCH 13/17 spi/topcliff-pch: Delete an unnecessary return statement in two functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 15:57:03 +0100

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

WARNING: void function return statements are not generally useful

Thus remove such statements here.

---
 drivers/spi/spi-topcliff-pch.c | 2 --
 1 file changed, 2 deletions(-)
drivers/spi/spi-topcliff-pch.c +0 -2
index 4bba39e70c7b..0a876311b67b 100644
@@ -915,7 +915,6 @@ static void pch_spi_release_dma(struct pch_spi_data *data)
 		dma_release_channel(dma->chan_rx);
 		dma->chan_rx = NULL;
 	}
-	return;
 }
 
 static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
@@ -1292,7 +1291,6 @@ static void pch_free_dma_buf(struct pch_spi_board_data *board_dat,
 	if (dma->rx_buf_dma)
 		dma_free_coherent(&board_dat->pdev->dev, PCH_BUF_SIZE,
 				  dma->rx_buf_virt, dma->rx_buf_dma);
-	return;
 }
 
 static void pch_alloc_dma_buf(struct pch_spi_board_data *board_dat,
Signature · 1 line
2.11.0
#33 lore raw

PATCH 14/17 spi/topcliff-pch: Adjust six checks for null pointers

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 16:16:05 +0100
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.

---
 drivers/spi/spi-topcliff-pch.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/spi/spi-topcliff-pch.c +6 -9
index 0a876311b67b..e4f1f66b751b 100644
@@ -531,12 +531,11 @@ static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg)
 static inline void pch_spi_select_chip(struct pch_spi_data *data,
 				       struct spi_device *pspi)
 {
-	if (data->current_chip != NULL) {
+	if (data->current_chip)
 		if (pspi->chip_select != data->n_curnt_chip) {
 			dev_dbg(&pspi->dev, "%s : different slave\n", __func__);
 			data->current_chip = NULL;
 		}
-	}
 
 	data->current_chip = pspi;
 
@@ -583,7 +582,7 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 
 	/* allocate memory for pkt_tx_buff & pkt_rx_buffer */
 	data->pkt_tx_buff = kzalloc(size, GFP_KERNEL);
-	if (data->pkt_tx_buff != NULL) {
+	if (data->pkt_tx_buff) {
 		data->pkt_rx_buff = kzalloc(size, GFP_KERNEL);
 		if (!data->pkt_rx_buff)
 			kfree(data->pkt_tx_buff);
@@ -605,7 +604,7 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 	}
 
 	/* copy Tx Data */
-	if (data->cur_trans->tx_buf != NULL) {
+	if (data->cur_trans->tx_buf) {
 		if (*bpw = 8) {
 			tx_buf = data->cur_trans->tx_buf;
 			for (j = 0; j < data->bpw_len; j++)
@@ -965,7 +964,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
 	}
 
 	/* copy Tx Data */
-	if (data->cur_trans->tx_buf != NULL) {
+	if (data->cur_trans->tx_buf) {
 		if (*bpw = 8) {
 			tx_buf = data->cur_trans->tx_buf;
 			tx_dma_buf = dma->tx_buf_virt;
@@ -1176,7 +1175,7 @@ static void pch_spi_process_messages(struct work_struct *pwork)
 		transfer structure from the message otherwise retrieve
 		the 1st transfer request from the message. */
 		spin_lock(&data->lock);
-		if (data->cur_trans = NULL) {
+		if (!data->cur_trans) {
 			data->cur_trans  				list_entry(data->current_msg->transfers.next,
 					   struct spi_transfer, transfer_list);
@@ -1247,9 +1246,7 @@ static void pch_spi_process_messages(struct work_struct *pwork)
 		}
 
 		spin_unlock(&data->lock);
-
-	} while (data->cur_trans != NULL);
-
+	} while (data->cur_trans);
 out:
 	pch_spi_writereg(data->master, PCH_SSNXCR, SSN_HIGH);
 	if (data->use_dma)
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#35 lore raw

PATCH 15/17 spi/topcliff-pch: Combine substrings for four messages

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 16:36:09 +0100

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

WARNING: quoted string split across lines

Thus fix the affected source code places.

---
 drivers/spi/spi-topcliff-pch.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/spi/spi-topcliff-pch.c +11 -9
index e4f1f66b751b..d36d42653087 100644
@@ -621,8 +621,9 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 	if (n_writes > PCH_MAX_FIFO_DEPTH)
 		n_writes = PCH_MAX_FIFO_DEPTH;
 
-	dev_dbg(&data->master->dev, "\n%s:Pulling down SSN low - writing "
-		"0x2 to SSNXCR\n", __func__);
+	dev_dbg(&data->master->dev,
+		"\n%s:Pulling down SSN low - writing 0x2 to SSNXCR\n",
+		__func__);
 	pch_spi_writereg(data->master, PCH_SSNXCR, SSN_LOW);
 
 	for (j = 0; j < n_writes; j++)
@@ -1179,14 +1180,16 @@ static void pch_spi_process_messages(struct work_struct *pwork)
 			data->cur_trans  				list_entry(data->current_msg->transfers.next,
 					   struct spi_transfer, transfer_list);
-			dev_dbg(&data->master->dev, "%s "
-				":Getting 1st transfer message\n", __func__);
+			dev_dbg(&data->master->dev,
+				"%s :Getting 1st transfer message\n",
+				__func__);
 		} else {
 			data->cur_trans  				list_entry(data->cur_trans->transfer_list.next,
 					   struct spi_transfer, transfer_list);
-			dev_dbg(&data->master->dev, "%s "
-				":Getting next transfer message\n", __func__);
+			dev_dbg(&data->master->dev,
+				"%s :Getting next transfer message\n",
+				__func__);
 		}
 		spin_unlock(&data->lock);
 
@@ -1231,9 +1234,8 @@ static void pch_spi_process_messages(struct work_struct *pwork)
 
 		/* check for delay */
 		if (data->cur_trans->delay_usecs) {
-			dev_dbg(&data->master->dev, "%s:"
-				"delay in usec=%d\n", __func__,
-				data->cur_trans->delay_usecs);
+			dev_dbg(&data->master->dev, "%s:delay in usec=%d\n",
+				__func__, data->cur_trans->delay_usecs);
 			udelay(data->cur_trans->delay_usecs);
 		}
 
Signature · 1 line
2.11.0
#37 lore raw

PATCH 16/17 spi/topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 17:00:08 +0100

Omit an extra message for a memory allocation failure in this function.

---
 drivers/spi/spi-topcliff-pch.c | 1 -
 1 file changed, 1 deletion(-)
drivers/spi/spi-topcliff-pch.c +0 -1
index d36d42653087..97fd1ea9826b 100644
@@ -590,7 +590,6 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 
 	if (!data->pkt_rx_buff) {
 		/* flush queue and set status of all transfers to -ENOMEM */
-		dev_err(&data->master->dev, "%s :kzalloc failed\n", __func__);
 		list_for_each_entry_safe(pmsg, tmp, data->queue.next, queue) {
 			pmsg->status = -ENOMEM;
 
Signature · 1 line
2.11.0
#39 lore raw

PATCH 17/17 spi/topcliff-pch: One check less in pch_spi_set_tx()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 17:30:46 +0100

Delete a duplicate check after a bit of exception handling was moved into a previous if branch of this function.

---
 drivers/spi/spi-topcliff-pch.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/spi/spi-topcliff-pch.c +14 -11
index 97fd1ea9826b..33043a830032 100644
@@ -584,22 +584,25 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 	data->pkt_tx_buff = kzalloc(size, GFP_KERNEL);
 	if (data->pkt_tx_buff) {
 		data->pkt_rx_buff = kzalloc(size, GFP_KERNEL);
-		if (!data->pkt_rx_buff)
+		if (!data->pkt_rx_buff) {
 			kfree(data->pkt_tx_buff);
-	}
 
-	if (!data->pkt_rx_buff) {
-		/* flush queue and set status of all transfers to -ENOMEM */
-		list_for_each_entry_safe(pmsg, tmp, data->queue.next, queue) {
-			pmsg->status = -ENOMEM;
+			/*
+			 * Flush queue and set status of all transfers
+			 * to -ENOMEM.
+			 */
+			list_for_each_entry_safe(pmsg, tmp, data->queue.next,
+						 queue) {
+				pmsg->status = -ENOMEM;
 
-			if (pmsg->complete)
-				pmsg->complete(pmsg->context);
+				if (pmsg->complete)
+					pmsg->complete(pmsg->context);
 
-			/* delete from queue */
-			list_del_init(&pmsg->queue);
+				/* delete from queue */
+				list_del_init(&pmsg->queue);
+			}
+			return;
 		}
-		return;
 	}
 
 	/* copy Tx Data */
Signature · 1 line
2.11.0
#40 lore raw

Re: [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx()

Hi Markus,

Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 17:30:46 +0100

Delete a duplicate check after a bit of exception handling was moved into a previous if branch of this function.

This is not equivalent: if data->pkt_tx_buff = NULL, the queue is no longer flushed.

Quoted 46 lines
---
 drivers/spi/spi-topcliff-pch.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/spi/spi-topcliff-pch.c +14 -11
index 97fd1ea9826b..33043a830032 100644
@@ -584,22 +584,25 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
        data->pkt_tx_buff = kzalloc(size, GFP_KERNEL);
        if (data->pkt_tx_buff) {
                data->pkt_rx_buff = kzalloc(size, GFP_KERNEL);
-               if (!data->pkt_rx_buff)
+               if (!data->pkt_rx_buff) {
                        kfree(data->pkt_tx_buff);
-       }
 
-       if (!data->pkt_rx_buff) {
-               /* flush queue and set status of all transfers to -ENOMEM */
-               list_for_each_entry_safe(pmsg, tmp, data->queue.next, queue) {
-                       pmsg->status = -ENOMEM;
+                       /*
+                        * Flush queue and set status of all transfers
+                        * to -ENOMEM.
+                        */
+                       list_for_each_entry_safe(pmsg, tmp, data->queue.next,
+                                                queue) {
+                               pmsg->status = -ENOMEM;
 
-                       if (pmsg->complete)
-                               pmsg->complete(pmsg->context);
+                               if (pmsg->complete)
+                                       pmsg->complete(pmsg->context);
 
-                       /* delete from queue */
-                       list_del_init(&pmsg->queue);
+                               /* delete from queue */
+                               list_del_init(&pmsg->queue);
+                       }
+                       return;
                }
-               return;
        }
 
        /* copy Tx Data */
Signature · 10 lines
Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#34 lore raw

Re: [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers

In reply to SF Markus Elfring
Quoted 22 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 16:16:05 +0100
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.

---
 drivers/spi/spi-topcliff-pch.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/spi/spi-topcliff-pch.c +0 -0
index 0a876311b67b..e4f1f66b751b 100644

drivers/spi/spi-topcliff-pch.c static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg) · line 534

Quoted 5 lines
drivers/spi/spi-topcliff-pch.c +1 -1
@@ -531,12 +531,11 @@ static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg)
 static inline void pch_spi_select_chip(struct pch_spi_data *data,
 				       struct spi_device *pspi)
 {
-	if (data->current_chip != NULL) {
+	if (data->current_chip)

Put the curly braces back. Multi-line indents get curly braces for readability.

drivers/spi/spi-topcliff-pch.c static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg) · line 539

Quoted 5 lines
drivers/spi/spi-topcliff-pch.c +0 -1
 		if (pspi->chip_select != data->n_curnt_chip) {
 			dev_dbg(&pspi->dev, "%s : different slave\n", __func__);
 			data->current_chip = NULL;
 		}
-	}

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#4 lore raw

Re: [PATCH 02/17] spi: Adjust checks for null pointers in two functions

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:23:32 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Something's messed up with your setup for sending out patches here... can you check please?

Quoted 5 lines

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

Comparison to NULL could be written !…

Thus fix the affected source code places.

This isn't a fix, it's a stylistic choice.

maintainer
#8 lore raw

Re: [PATCH 04/17] spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects()

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:37:25 +0100

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

The previous patch changed a similar call site to use kcalloc() with a similar explanation, the choice of function to translate to seems entirely random since the changelogs don't address the zeroing that kzalloc() and kcalloc() do but kmalloc() and kmalloc_array() don't.

maintainer
#15 lore raw

Re: [PATCH 07/17] spi/mpc52xx: Combine substrings for two messages

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:14:45 +0100

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

WARNING: quoted string split across lines

Thus fix the affected source code places.

You should provide more explanation and analysis for changes than just saying "checkpatch" - it's not a 100% reliable tool and sometimes it gives false positives or simply silencing the warning actually makes things worse (as some of the other feedback on the series shows). It is better to provide something in the changelog which explains why the change improves things, giving credit to checkpatch is of course nice to do but something that shows an understanding of what it's saying really helps.

maintainer
#22 lore raw

Re: [PATCH 10/17] spi/ppc4xx: Adjust checks for null pointers in two functions

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:56:10 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is also corrupted.

maintainer
#38 lore raw

Applied "spi/topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx()" to the spi tree

In reply to SF Markus Elfring

The patch

spi/topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 45e861a1c12cfd717b8e47103f1aaf2e34cc6688 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 17:00:08 +0100
Subject: [PATCH] spi/topcliff-pch: Delete an error message for a failed memory
allocation in pch_spi_set_tx()

Omit an extra message for a memory allocation failure in this function.

---
 drivers/spi/spi-topcliff-pch.c | 1 -
 1 file changed, 1 deletion(-)
drivers/spi/spi-topcliff-pch.c +0 -1
index 2b9405819075..97d137591b18 100644
@@ -591,7 +591,6 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 
 	if (!data->pkt_rx_buff) {
 		/* flush queue and set status of all transfers to -ENOMEM */
-		dev_err(&data->master->dev, "%s :kzalloc failed\n", __func__);
 		list_for_each_entry_safe(pmsg, tmp, data->queue.next, queue) {
 			pmsg->status = -ENOMEM;
 
Signature · 1 line
2.11.0
maintainer
#36 lore raw

Applied "spi/topcliff-pch: Combine substrings for four messages" to the spi tree

In reply to SF Markus Elfring

The patch

spi/topcliff-pch: Combine substrings for four messages

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From b996356d305fd311eaa652890b255a0ff4d13de4 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 16:36:09 +0100
Subject: [PATCH] spi/topcliff-pch: Combine substrings for four messages

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

WARNING: quoted string split across lines

Thus fix the affected source code places.

---
 drivers/spi/spi-topcliff-pch.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/spi/spi-topcliff-pch.c +11 -9
index 0a876311b67b..2b9405819075 100644
@@ -622,8 +622,9 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 	if (n_writes > PCH_MAX_FIFO_DEPTH)
 		n_writes = PCH_MAX_FIFO_DEPTH;
 
-	dev_dbg(&data->master->dev, "\n%s:Pulling down SSN low - writing "
-		"0x2 to SSNXCR\n", __func__);
+	dev_dbg(&data->master->dev,
+		"\n%s:Pulling down SSN low - writing 0x2 to SSNXCR\n",
+		__func__);
 	pch_spi_writereg(data->master, PCH_SSNXCR, SSN_LOW);
 
 	for (j = 0; j < n_writes; j++)
@@ -1180,14 +1181,16 @@ static void pch_spi_process_messages(struct work_struct *pwork)
 			data->cur_trans  				list_entry(data->current_msg->transfers.next,
 					   struct spi_transfer, transfer_list);
-			dev_dbg(&data->master->dev, "%s "
-				":Getting 1st transfer message\n", __func__);
+			dev_dbg(&data->master->dev,
+				"%s :Getting 1st transfer message\n",
+				__func__);
 		} else {
 			data->cur_trans  				list_entry(data->cur_trans->transfer_list.next,
 					   struct spi_transfer, transfer_list);
-			dev_dbg(&data->master->dev, "%s "
-				":Getting next transfer message\n", __func__);
+			dev_dbg(&data->master->dev,
+				"%s :Getting next transfer message\n",
+				__func__);
 		}
 		spin_unlock(&data->lock);
 
@@ -1232,9 +1235,8 @@ static void pch_spi_process_messages(struct work_struct *pwork)
 
 		/* check for delay */
 		if (data->cur_trans->delay_usecs) {
-			dev_dbg(&data->master->dev, "%s:"
-				"delay in usec=%d\n", __func__,
-				data->cur_trans->delay_usecs);
+			dev_dbg(&data->master->dev, "%s:delay in usec=%d\n",
+				__func__, data->cur_trans->delay_usecs);
 			udelay(data->cur_trans->delay_usecs);
 		}
 
Signature · 1 line
2.11.0
maintainer
#30 lore raw

Applied "spi/topcliff-pch: Improve size determinations in pch_spi_probe()" to the spi tree

In reply to SF Markus Elfring

The patch

spi/topcliff-pch: Improve size determinations in pch_spi_probe()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From baa35f5734aa1c0207e4e6b8e15079475b1fa252 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 15:46:35 +0100
Subject: [PATCH] spi/topcliff-pch: Improve size determinations in
pch_spi_probe()

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

---
 drivers/spi/spi-topcliff-pch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-topcliff-pch.c +2 -2
index 1beeb16e836a..0a876311b67b 100644
@@ -1539,11 +1539,11 @@ static int pch_spi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	int i;
 	struct pch_pd_dev_save *pd_dev_save;
 
-	pd_dev_save = kzalloc(sizeof(struct pch_pd_dev_save), GFP_KERNEL);
+	pd_dev_save = kzalloc(sizeof(*pd_dev_save), GFP_KERNEL);
 	if (!pd_dev_save)
 		return -ENOMEM;
 
-	board_dat = kzalloc(sizeof(struct pch_spi_board_data), GFP_KERNEL);
+	board_dat = kzalloc(sizeof(*board_dat), GFP_KERNEL);
 	if (!board_dat) {
 		retval = -ENOMEM;
 		goto err_no_mem;
Signature · 1 line
2.11.0
maintainer
#28 lore raw

Applied "spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma()" to the spi tree

In reply to SF Markus Elfring

The patch

spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 84aa0ba12442fa46f461c491c42efdadf6995c96 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 15:25:22 +0100
Subject: [PATCH] spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma()

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

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

---
 drivers/spi/spi-topcliff-pch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-topcliff-pch.c +2 -2
index 250452a6eead..1beeb16e836a 100644
@@ -1007,7 +1007,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
 	spin_unlock_irqrestore(&data->lock, flags);
 
 	/* RX */
-	dma->sg_rx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC);
+	dma->sg_rx_p = kcalloc(num, sizeof(*dma->sg_rx_p), GFP_ATOMIC);
 	sg_init_table(dma->sg_rx_p, num); /* Initialize SG table */
 	/* offset, length setting */
 	sg = dma->sg_rx_p;
@@ -1067,7 +1067,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
 		head = 0;
 	}
 
-	dma->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC);
+	dma->sg_tx_p = kcalloc(num, sizeof(*dma->sg_tx_p), GFP_ATOMIC);
 	sg_init_table(dma->sg_tx_p, num); /* Initialize SG table */
 	/* offset, length setting */
 	sg = dma->sg_tx_p;
Signature · 1 line
2.11.0
maintainer
#32 lore raw

Applied "spi/topcliff-pch: Delete an unnecessary return statement in two functions" to the spi tree

In reply to SF Markus Elfring

The patch

spi/topcliff-pch: Delete an unnecessary return statement in two functions

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 6ceb3b27b1edd1112f1879cc1f149d39a3da2dc2 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 15:57:03 +0100
Subject: [PATCH] spi/topcliff-pch: Delete an unnecessary return statement in
two functions

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

WARNING: void function return statements are not generally useful

Thus remove such statements here.

---
 drivers/spi/spi-topcliff-pch.c | 2 --
 1 file changed, 2 deletions(-)
drivers/spi/spi-topcliff-pch.c +0 -2
index fcb991034c3d..250452a6eead 100644
@@ -915,7 +915,6 @@ static void pch_spi_release_dma(struct pch_spi_data *data)
 		dma_release_channel(dma->chan_rx);
 		dma->chan_rx = NULL;
 	}
-	return;
 }
 
 static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
@@ -1292,7 +1291,6 @@ static void pch_free_dma_buf(struct pch_spi_board_data *board_dat,
 	if (dma->rx_buf_dma)
 		dma_free_coherent(&board_dat->pdev->dev, PCH_BUF_SIZE,
 				  dma->rx_buf_virt, dma->rx_buf_dma);
-	return;
 }
 
 static void pch_alloc_dma_buf(struct pch_spi_board_data *board_dat,
Signature · 1 line
2.11.0
maintainer
#18 lore raw

Applied "spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe()" to the spi tree

In reply to SF Markus Elfring

The patch

spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 797236f10a095a1742373bca5f284c5ec8afb446 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:30:43 +0100
Subject: [PATCH] spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe()

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

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.

---
 drivers/spi/spi-ppc4xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-ppc4xx.c +1 -1
index b2df63c66494..967d94844b30 100644
@@ -411,7 +411,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 	if (num_gpios > 0) {
 		int i;
 
-		hw->gpios = kzalloc(sizeof(int) * num_gpios, GFP_KERNEL);
+		hw->gpios = kcalloc(num_gpios, sizeof(*hw->gpios), GFP_KERNEL);
 		if (!hw->gpios) {
 			ret = -ENOMEM;
 			goto free_master;
Signature · 1 line
2.11.0
maintainer
#20 lore raw

Applied "spi/ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe()" to the spi tree

In reply to SF Markus Elfring

The patch

spi/ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From ffcaef5ac27b62b480b94036615b3ae4f1b725fe Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:43:06 +0100
Subject: [PATCH] spi/ppc4xx: Combine substrings for a message in
spi_ppc4xx_of_probe()

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

WARNING: quoted string split across lines

Thus fix the affected source code place.

---
 drivers/spi/spi-ppc4xx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-ppc4xx.c +3 -2
index dd3d0a218d8b..b2df63c66494 100644
@@ -428,8 +428,9 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 				/* Real CS - set the initial state. */
 				ret = gpio_request(gpio, np->name);
 				if (ret < 0) {
-					dev_err(dev, "can't request gpio "
-							"#%d: %d\n", i, ret);
+					dev_err(dev,
+						"can't request gpio #%d: %d\n",
+						i, ret);
 					goto free_gpios;
 				}
 
Signature · 1 line
2.11.0
maintainer
#16 lore raw

Applied "spi/mpc52xx: Combine substrings for two messages" to the spi tree

In reply to SF Markus Elfring

The patch

spi/mpc52xx: Combine substrings for two messages

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 9c4f0440ba8f3ad57bebb46cfa29a18333fe4860 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:14:45 +0100
Subject: [PATCH] spi/mpc52xx: Combine substrings for two messages

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

WARNING: quoted string split across lines

Thus fix the affected source code places.

---
 drivers/spi/spi-mpc52xx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/spi/spi-mpc52xx.c +3 -4
index 8cc129efe7ba..e8b59ce4dc3a 100644
@@ -449,8 +449,7 @@ static int mpc52xx_spi_probe(struct platform_device *op)
 			gpio_cs = of_get_gpio(op->dev.of_node, i);
 			if (gpio_cs < 0) {
 				dev_err(&op->dev,
-					"could not parse the gpio field "
-					"in oftree\n");
+					"could not parse the gpio field in oftree\n");
 				rc = -ENODEV;
 				goto err_gpio;
 			}
@@ -458,8 +457,8 @@ static int mpc52xx_spi_probe(struct platform_device *op)
 			rc = gpio_request(gpio_cs, dev_name(&op->dev));
 			if (rc) {
 				dev_err(&op->dev,
-					"can't request spi cs gpio #%d "
-					"on gpio line %d\n", i, gpio_cs);
+					"can't request spi cs gpio #%d on gpio line %d\n",
+					i, gpio_cs);
 				goto err_gpio;
 			}
 
Signature · 1 line
2.11.0
maintainer
#13 lore raw

Applied "spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe()" to the spi tree

In reply to SF Markus Elfring

The patch

spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 8b6c8955b5dc21358cb1f67cadc5514d2353375d Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:06:10 +0100
Subject: [PATCH] spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe()

* 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 type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/spi/spi-mpc52xx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-mpc52xx.c +3 -2
index c36002110c30..8cc129efe7ba 100644
@@ -437,8 +437,9 @@ static int mpc52xx_spi_probe(struct platform_device *op)
 	ms->gpio_cs_count = of_gpio_count(op->dev.of_node);
 	if (ms->gpio_cs_count > 0) {
 		master->num_chipselect = ms->gpio_cs_count;
-		ms->gpio_cs = kmalloc(ms->gpio_cs_count * sizeof(unsigned int),
-				GFP_KERNEL);
+		ms->gpio_cs = kmalloc_array(ms->gpio_cs_count,
+					    sizeof(*ms->gpio_cs),
+					    GFP_KERNEL);
 		if (!ms->gpio_cs) {
 			rc = -ENOMEM;
 			goto err_alloc_gpio;
Signature · 1 line
2.11.0
maintainer
#11 lore raw

Applied "spi: fsl: Combine substrings for two messages" to the spi tree

In reply to SF Markus Elfring

The patch

spi: fsl: Combine substrings for two messages

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 31ae779421098e9a58a3f10e1e09b2c63f4514fa Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:50:21 +0100
Subject: [PATCH] spi: fsl: Combine substrings for two messages

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

WARNING: quoted string split across lines

Thus fix the affected source code places.

---
 drivers/spi/spi-fsl-spi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-spi.c +6 -6
index cdee556037f9..0fc3452652ae 100644
@@ -267,10 +267,9 @@ static int fsl_spi_setup_transfer(struct spi_device *spi,
 	if ((mpc8xxx_spi->spibrg / hz) > 64) {
 		cs->hw_mode |= SPMODE_DIV16;
 		pm = (mpc8xxx_spi->spibrg - 1) / (hz * 64) + 1;
-
-		WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. "
-			  "Will use %d Hz instead.\n", dev_name(&spi->dev),
-			  hz, mpc8xxx_spi->spibrg / 1024);
+		WARN_ONCE(pm > 16,
+			  "%s: Requested speed is too low: %d Hz. Will use %d Hz instead.\n",
+			  dev_name(&spi->dev), hz, mpc8xxx_spi->spibrg / 1024);
 		if (pm > 16)
 			pm = 16;
 	} else {
@@ -763,8 +762,9 @@ static int of_fsl_spi_get_chipselects(struct device *dev)
 		ret = gpio_direction_output(pinfo->gpios[i],
 					    pinfo->alow_flags[i]);
 		if (ret) {
-			dev_err(dev, "can't set output direction for gpio "
-				"#%d: %d\n", i, ret);
+			dev_err(dev,
+				"can't set output direction for gpio #%d: %d\n",
+				i, ret);
 			goto err_loop;
 		}
 	}
Signature · 1 line
2.11.0
maintainer
#6 lore raw

Applied "spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects()" to the spi tree

In reply to SF Markus Elfring

The patch

spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 5223db0b10c7917d7c6b4f7d8e2c0af0eb1158f5 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:33:02 +0100
Subject: [PATCH] spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects()

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

This issue was detected by using the Coccinelle software.

---
 drivers/spi/spi-fsl-spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-fsl-spi.c +1 -1
index 9873d39d1a95..cdee556037f9 100644
@@ -733,7 +733,7 @@ static int of_fsl_spi_get_chipselects(struct device *dev)
 		return -ENOMEM;
 	memset(pinfo->gpios, -1, ngpios * sizeof(*pinfo->gpios));
 
-	pinfo->alow_flags = kzalloc(ngpios * sizeof(*pinfo->alow_flags),
+	pinfo->alow_flags = kcalloc(ngpios, sizeof(*pinfo->alow_flags),
 				    GFP_KERNEL);
 	if (!pinfo->alow_flags) {
 		ret = -ENOMEM;
Signature · 1 line
2.11.0
maintainer
#9 lore raw

Applied "spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects()" to the spi tree

In reply to SF Markus Elfring

The patch

spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From d9bc4a8539a518636cd70d498e94787e32ea8fbe Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 13:37:25 +0100
Subject: [PATCH] spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects()

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.

---
 drivers/spi/spi-fsl-spi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-fsl-spi.c +2 -1
index 8b290d9d7935..9873d39d1a95 100644
@@ -727,7 +727,8 @@ static int of_fsl_spi_get_chipselects(struct device *dev)
 		return 0;
 	}
 
-	pinfo->gpios = kmalloc(ngpios * sizeof(*pinfo->gpios), GFP_KERNEL);
+	pinfo->gpios = kmalloc_array(ngpios, sizeof(*pinfo->gpios),
+				     GFP_KERNEL);
 	if (!pinfo->gpios)
 		return -ENOMEM;
 	memset(pinfo->gpios, -1, ngpios * sizeof(*pinfo->gpios));
Signature · 1 line
2.11.0
maintainer
#2 lore raw

Applied "spi: Use kcalloc() in spi_register_board_info()" to the spi tree

In reply to SF Markus Elfring

The patch

spi: Use kcalloc() in spi_register_board_info()

has been applied to the spi tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From f9bdb7fdd2cac17bdc9c344b6036e6939fa087cd Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 12:28:04 +0100
Subject: [PATCH] spi: Use kcalloc() in spi_register_board_info()

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

This issue was detected by using the Coccinelle software.

---
 drivers/spi/spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
index 656dd3e3220c..8c05f27bf642 100644
@@ -672,7 +672,7 @@ int spi_register_board_info(struct spi_board_info const *info, unsigned n)
 	if (!n)
 		return -EINVAL;
 
-	bi = kzalloc(n * sizeof(*bi), GFP_KERNEL);
+	bi = kcalloc(n, sizeof(*bi), GFP_KERNEL);
 	if (!bi)
 		return -ENOMEM;
 
Signature · 1 line
2.11.0
#23 lore raw

Re: spi/ppc4xx: Adjust checks for null pointers in two functions

In reply to Mark Brown
Quoted 7 lines
Quoted 5 lines

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:56:10 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is also corrupted.

Would you like to explain this information a bit more?

The published patch looks reasonable in principle by other interfaces, doesn't it?
https://lkml.org/lkml/2017/1/13/609
https://patchwork.kernel.org/patch/9516059/
https://lkml.kernel.org/r/<[email protected]>

Regards,
Markus

maintainer
#24 lore raw

Re: spi/ppc4xx: Adjust checks for null pointers in two functions

Quoted 9 lines · SF Markus Elfring
Quoted 7 lines
Quoted 5 lines

From: Markus Elfring <[email protected]>
Date: Fri, 13 Jan 2017 14:56:10 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is also corrupted.

Would you like to explain this information a bit more?

You've got MIME headers in the middle of the patch description.

#25 lore raw

Re: spi/ppc4xx: Adjust checks for null pointers in two functions

Quoted 1 line

You've got MIME headers in the middle of the patch description.

The extra header fields were automatically added by the tool “git” because I dared to use an Unicode character in the commit message for this patch (and a few others).

Would you like to change the mentioned implementation detail at all?

Regards,
Markus

maintainer
#26 lore raw

Re: spi/ppc4xx: Adjust checks for null pointers in two functions

Quoted 7 lines · SF Markus Elfring
Quoted 1 line

You've got MIME headers in the middle of the patch description.

The extra header fields were automatically added by the tool “git” because I dared to use an Unicode character in the commit message for this patch (and a few others).

Would you like to change the mentioned implementation detail at all?

Well, I've deleted the mails now so...

Better yet would be to send patches with a sender address matching the author information in your patches so they don't get any mangling in the body at all.