dmaengine: k3dma: Fine-tuning for five function implementations
Subsystems (2)
cover dmaengine: k3dma: Fine-tuning for five function implementations
From: Markus Elfring <[email protected]>
Date: Sun, 23 Apr 2017 10:56:54 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use devm_kcalloc() in k3_dma_probe()
Adjust six checks for null pointers
drivers/dma/k3dma.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.12.2
PATCH 1/2 dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe()
From: Markus Elfring <[email protected]>
Date: Sun, 23 Apr 2017 10:30:32 +0200
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "devm_kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/dma/k3dma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/k3dma.c +4 -4
@@ -845,8 +845,8 @@ static int k3_dma_probe(struct platform_device *op)return -ENOMEM ;/* init phy channel */ - d->phy =devm_kzalloc (&op->dev, - d->dma_channels *sizeof (struct k3_dma_phy ),GFP_KERNEL ); + d->phy =devm_kcalloc (&op->dev, d->dma_channels,sizeof (*d->phy), +GFP_KERNEL );if (d->phy =NULL )return -ENOMEM ;
@@ -875,8 +875,8 @@ static int k3_dma_probe(struct platform_device *op) d->slave.copy_align =DMAENGINE_ALIGN_8_BYTES ;/* init virtual channel */ - d->chans =devm_kzalloc (&op->dev, - d->dma_requests *sizeof (struct k3_dma_chan ),GFP_KERNEL ); + d->chans =devm_kcalloc (&op->dev, d->dma_requests,sizeof (*d->chans), +GFP_KERNEL );if (d->chans =NULL )return -ENOMEM ;
Signature · 1 line
2.12.2
PATCH 2/2 dmaengine: k3dma: Adjust six checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 23 Apr 2017 10:47:04 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written …
Thus fix the affected source code places.
--- drivers/dma/k3dma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/dma/k3dma.c +6 -6
@@ -230,7 +230,7 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id) }if (c && (tc2 &BIT (i))) {spin_lock_irqsave (&c->vc.lock, flags); -if (p->ds_run !=NULL ) +if (p->ds_run)vchan_cyclic_callback (&p->ds_run->vd);spin_unlock_irqrestore (&c->vc.lock, flags); }
@@ -312,7 +312,7 @@ static void k3_dma_tasklet(unsigned long arg)for (pch =0 ; pch < d->dma_channels; pch++) { p = &d->phy[pch]; -if (p->vchan =NULL && !list_empty (&d->chan_pending)) { +if (!p->vchan && !list_empty (&d->chan_pending)) { c =list_first_entry (&d->chan_pending, struct k3_dma_chan, node);/* remove from d->chan_pending */
@@ -527,7 +527,7 @@ static struct dma_async_tx_descriptor *k3_dma_prep_slave_sg(dma_addr_t addr, src =0 , dst =0 ;int num = sglen, i; -if (sgl =NULL ) +if (!sgl)return NULL ; c->cyclic =0 ;
@@ -645,7 +645,7 @@ static int k3_dma_config(struct dma_chan *chan,u32 maxburst =0 , val =0 ;enum dma_slave_buswidth width =DMA_SLAVE_BUSWIDTH_UNDEFINED ; -if (cfg =NULL ) +if (!cfg)return -EINVAL ; c->dir = cfg->direction;if (c->dir =DMA_DEV_TO_MEM ) {
@@ -847,7 +847,7 @@ static int k3_dma_probe(struct platform_device *op)/* init phy channel */ d->phy =devm_kcalloc (&op->dev, d->dma_channels,sizeof (*d->phy),GFP_KERNEL ); -if (d->phy =NULL ) +if (!d->phy)return -ENOMEM ;for (i =0 ; i < d->dma_channels; i++) {
@@ -877,7 +877,7 @@ static int k3_dma_probe(struct platform_device *op)/* init virtual channel */ d->chans =devm_kcalloc (&op->dev, d->dma_requests,sizeof (*d->chans),GFP_KERNEL ); -if (d->chans =NULL ) +if (!d->chans)return -ENOMEM ;for (i =0 ; i < d->dma_requests; i++) {
Signature · 1 line
2.12.2