Skip to contentSkip to conversation

DMA-PPC4xx: Adjustments for three function implementations

PATCH In review SF Markus Elfring 2 participants 4 messages Feb 13, 2018

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

cover 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(-)
Signature · 1 line
2.16.1
#1 lore raw

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.

---
 drivers/dma/ppc4xx/adma.c | 2 --
 1 file changed, 2 deletions(-)
drivers/dma/ppc4xx/adma.c +0 -2
index 4cf0d4d0cecf..f4033367d59b 100644
@@ -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 lore raw

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

Quoted 1 line · SF Markus Elfring

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

[]

drivers/dma/ppc4xx/adma.c

Quoted 1 line
drivers/dma/ppc4xx/adma.c +0 -0

[]

drivers/dma/ppc4xx/adma.c static int ppc440spe_adma_probe(struct platform_device *ofdev) · line 4188

Quoted 8 lines
drivers/dma/ppc4xx/adma.c +0 -1
@@ -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(-)

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

drivers/dma/ppc4xx/adma.c +5 -6
index 4cf0d4d0cecf..1fc1a2f03aa4 100644
@@ -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;
#3 lore raw

PATCH 2/2 dma/ppc4xx: Improve a size determination in ppc440spe_adma_alloc_chan_resources()

In reply to SF Markus Elfring

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.

---
 drivers/dma/ppc4xx/adma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/ppc4xx/adma.c +1 -2
index f4033367d59b..27ea48a2c1dc 100644
@@ -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--);