Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1558593 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-01-13 18:10 +0100 |
| Last post | 2017-01-13 18:30 +0100 |
| Articles | 20 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 00/17] SPI: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:10 +0100
[PATCH 01/17] spi: Use kcalloc() in spi_register_board_info() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:10 +0100
[PATCH 04/17] spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 07/17] spi/mpc52xx: Combine substrings for two messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 06/17] spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 02/17] spi: Adjust checks for null pointers in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 03/17] spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 10/17] spi/ppc4xx: Adjust checks for null pointers in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 08/17] spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 09/17] spi/ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 05/17] spi: fsl: Combine substrings for two messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
Re: [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-01-13 19:20 +0100
[PATCH 12/17] spi/topcliff-pch: Improve size determinations in pch_spi_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
Re: [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers Dan Carpenter <dan.carpenter@oracle.com> - 2017-01-14 07:40 +0100
[PATCH 16/17] spi/topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 13/17] spi/topcliff-pch: Delete an unnecessary return statement in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 15/17] spi/topcliff-pch: Combine substrings for four messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 11/17] spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:10 +0100 |
| Subject | [PATCH 00/17] SPI: Fine-tuning for several function implementations |
| Message-ID | <sZdwt-3x7-15@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> 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(-) -- 2.11.0
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:10 +0100 |
| Subject | [PATCH 01/17] spi: Use kcalloc() in spi_register_board_info() |
| Message-ID | <sZdwu-3x7-25@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net> 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. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 656dd3e3220c..8c05f27bf642 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -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; -- 2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:20 +0100 |
| Subject | [PATCH 04/17] spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects() |
| Message-ID | <sZdG9-3Aq-1@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net> 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. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/spi/spi-fsl-spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index d1b26c9fe950..cdee556037f9 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -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)); -- 2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:20 +0100 |
| Subject | [PATCH 07/17] spi/mpc52xx: Combine substrings for two messages |
| Message-ID | <sZdG9-3Aq-5@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-mpc52xx.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index 8cc129efe7ba..e8b59ce4dc3a 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -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;
}
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:20 +0100 |
| Subject | [PATCH 06/17] spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe() |
| Message-ID | <sZdG9-3Aq-7@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-mpc52xx.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index c36002110c30..8cc129efe7ba 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -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;
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:20 +0100 |
| Subject | [PATCH 02/17] spi: Adjust checks for null pointers in two functions |
| Message-ID | <sZdGa-3Aq-17@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 8c05f27bf642..d8d273545e54 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -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 */
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:20 +0100 |
| Subject | [PATCH 03/17] spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects() |
| Message-ID | <sZdGa-3Aq-21@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-fsl-spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 8b290d9d7935..d1b26c9fe950 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -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;
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:20 +0100 |
| Subject | [PATCH 10/17] spi/ppc4xx: Adjust checks for null pointers in two functions |
| Message-ID | <sZdGa-3Aq-23@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-ppc4xx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-ppc4xx.c b/drivers/spi/spi-ppc4xx.c
index 967d94844b30..048794f043a0 100644
--- a/drivers/spi/spi-ppc4xx.c
+++ b/drivers/spi/spi-ppc4xx.c
@@ -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;
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:20 +0100 |
| Subject | [PATCH 08/17] spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe() |
| Message-ID | <sZdGa-3Aq-29@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-ppc4xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-ppc4xx.c b/drivers/spi/spi-ppc4xx.c
index dd3d0a218d8b..e0c39734d6ef 100644
--- a/drivers/spi/spi-ppc4xx.c
+++ b/drivers/spi/spi-ppc4xx.c
@@ -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;
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:20 +0100 |
| Subject | [PATCH 09/17] spi/ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe() |
| Message-ID | <sZdGa-3Aq-31@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-ppc4xx.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-ppc4xx.c b/drivers/spi/spi-ppc4xx.c
index e0c39734d6ef..967d94844b30 100644
--- a/drivers/spi/spi-ppc4xx.c
+++ b/drivers/spi/spi-ppc4xx.c
@@ -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;
}
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:30 +0100 |
| Subject | [PATCH 05/17] spi: fsl: Combine substrings for two messages |
| Message-ID | <sZdPP-3DF-1@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-fsl-spi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index cdee556037f9..0fc3452652ae 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -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;
}
}
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:30 +0100 |
| Subject | [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() |
| Message-ID | <sZdPP-3DF-11@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-topcliff-pch.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 97fd1ea9826b..33043a830032 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -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 */
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Geert Uytterhoeven <geert@linux-m68k.org> |
|---|---|
| Date | 2017-01-13 19:20 +0100 |
| Subject | Re: [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() |
| Message-ID | <sZeCe-49a-11@gated-at.bofh.it> |
| In reply to | #1558616 |
Hi Markus,
On Fri, Jan 13, 2017 at 6:28 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/spi/spi-topcliff-pch.c | 25 ++++++++++++++-----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
> index 97fd1ea9826b..33043a830032 100644
> --- a/drivers/spi/spi-topcliff-pch.c
> +++ b/drivers/spi/spi-topcliff-pch.c
> @@ -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 */
--
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:30 +0100 |
| Subject | [PATCH 12/17] spi/topcliff-pch: Improve size determinations in pch_spi_probe() |
| Message-ID | <sZdPQ-3DF-23@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-topcliff-pch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 0488b7c7cc19..4bba39e70c7b 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -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;
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:30 +0100 |
| Subject | [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers |
| Message-ID | <sZdPQ-3DF-19@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-topcliff-pch.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 0a876311b67b..e4f1f66b751b 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -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)
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2017-01-14 07:40 +0100 |
| Subject | Re: [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers |
| Message-ID | <sZqam-2Ce-5@gated-at.bofh.it> |
| In reply to | #1558618 |
On Fri, Jan 13, 2017 at 06:24:22PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/spi/spi-topcliff-pch.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
> index 0a876311b67b..e4f1f66b751b 100644
> --- a/drivers/spi/spi-topcliff-pch.c
> +++ b/drivers/spi/spi-topcliff-pch.c
> @@ -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.
> if (pspi->chip_select != data->n_curnt_chip) {
> dev_dbg(&pspi->dev, "%s : different slave\n", __func__);
> data->current_chip = NULL;
> }
> - }
regards,
dan carpenter
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:30 +0100 |
| Subject | [PATCH 16/17] spi/topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx() |
| Message-ID | <sZdPQ-3DF-25@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 17:00:08 +0100
Omit an extra message for a memory allocation failure in this function.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-topcliff-pch.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index d36d42653087..97fd1ea9826b 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -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;
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:30 +0100 |
| Subject | [PATCH 13/17] spi/topcliff-pch: Delete an unnecessary return statement in two functions |
| Message-ID | <sZdPQ-3DF-41@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net> 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. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/spi/spi-topcliff-pch.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index 4bba39e70c7b..0a876311b67b 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -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, -- 2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:30 +0100 |
| Subject | [PATCH 15/17] spi/topcliff-pch: Combine substrings for four messages |
| Message-ID | <sZdPR-3DF-49@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-topcliff-pch.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index e4f1f66b751b..d36d42653087 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -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);
}
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-13 18:30 +0100 |
| Subject | [PATCH 11/17] spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma() |
| Message-ID | <sZdPR-3DF-51@gated-at.bofh.it> |
| In reply to | #1558593 |
From: Markus Elfring <elfring@users.sourceforge.net> 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. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/spi/spi-topcliff-pch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index fcb991034c3d..0488b7c7cc19 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -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; -- 2.11.0
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web