2018-02-13 20:24:58

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] DMA-PPC4xx: Adjustments for three function implementations

From: Markus Elfring <[email protected]>
Date: Tue, 13 Feb 2018 21:16:42 +0100

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

Markus Elfring (2):
Delete an error message for a failed memory allocation in two functions
Improve a size determination in ppc440spe_adma_alloc_chan_resources()

drivers/dma/ppc4xx/adma.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

--
2.16.1



2018-02-13 20:27:11

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] dma/ppc4xx: Delete an error message for a failed memory allocation in two functions

From: Markus Elfring <[email protected]>
Date: Tue, 13 Feb 2018 20:42:40 +0100

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/dma/ppc4xx/adma.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index 4cf0d4d0cecf..f4033367d59b 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -4183,7 +4183,6 @@ static int ppc440spe_adma_probe(struct platform_device *ofdev)
INIT_LIST_HEAD(&ref->node);
list_add_tail(&ref->node, &ppc440spe_adma_chan_list);
} else {
- dev_err(&ofdev->dev, "failed to allocate channel reference!\n");
ret = -ENOMEM;
goto err_ref_alloc;
}
@@ -4468,7 +4467,6 @@ static int ppc440spe_configure_raid_devices(void)
ppc440spe_dma_fifo_buf = kmalloc((DMA0_FIFO_SIZE + DMA1_FIFO_SIZE) << 1,
GFP_KERNEL);
if (!ppc440spe_dma_fifo_buf) {
- pr_err("%s: DMA FIFO buffer allocation failed.\n", __func__);
iounmap(i2o_reg);
dcr_unmap(i2o_dcr_host, dcr_len);
return -ENOMEM;
--
2.16.1


2018-02-13 20:29:24

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] dma/ppc4xx: Improve a size determination in ppc440spe_adma_alloc_chan_resources()

From: Markus Elfring <[email protected]>
Date: Tue, 13 Feb 2018 20:54:30 +0100

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

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/dma/ppc4xx/adma.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index f4033367d59b..27ea48a2c1dc 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -1795,8 +1795,7 @@ static int ppc440spe_adma_alloc_chan_resources(struct dma_chan *chan)
db_sz = sizeof(struct xor_cb);

for (; i < (ppc440spe_chan->device->pool_size / db_sz); i++) {
- slot = kzalloc(sizeof(struct ppc440spe_adma_desc_slot),
- GFP_KERNEL);
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
if (!slot) {
printk(KERN_INFO "SPE ADMA Channel only initialized"
" %d descriptor slots", i--);
--
2.16.1


2018-02-13 20:42:03

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/2] dma/ppc4xx: Delete an error message for a failed memory allocation in two functions

On Tue, 2018-02-13 at 21:25 +0100, SF Markus Elfring wrote:
> Omit an extra message for a memory allocation failure in these functions.
[]
> diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
[]
> @@ -4183,7 +4183,6 @@ static int ppc440spe_adma_probe(struct platform_device *ofdev)
> INIT_LIST_HEAD(&ref->node);
> list_add_tail(&ref->node, &ppc440spe_adma_chan_list);
> } else {
> - dev_err(&ofdev->dev, "failed to allocate channel reference!\n");
> ret = -ENOMEM;
> goto err_ref_alloc;
> }

Stop being mindless and think about the change
you are making.

Reverse the test and unindent the block above.
---
drivers/dma/ppc4xx/adma.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index 4cf0d4d0cecf..1fc1a2f03aa4 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -4178,16 +4178,15 @@ static int ppc440spe_adma_probe(struct platform_device *ofdev)
}

ref = kmalloc(sizeof(*ref), GFP_KERNEL);
- if (ref) {
- ref->chan = &chan->common;
- INIT_LIST_HEAD(&ref->node);
- list_add_tail(&ref->node, &ppc440spe_adma_chan_list);
- } else {
- dev_err(&ofdev->dev, "failed to allocate channel reference!\n");
+ if (!ref) {
ret = -ENOMEM;
goto err_ref_alloc;
}

+ ref->chan = &chan->common;
+ INIT_LIST_HEAD(&ref->node);
+ list_add_tail(&ref->node, &ppc440spe_adma_chan_list);
+
ret = ppc440spe_adma_setup_irqs(adev, chan, &initcode);
if (ret)
goto err_irq;