All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] dmaengine: k3dma: Fine-tuning for five function implementations
@ 2017-04-23  9:06 ` SF Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-23  9:06 UTC (permalink / raw)
  To: dmaengine, Dan Williams, Vinod Koul, Zhangfei Gao; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.12.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 0/2] dmaengine: k3dma: Fine-tuning for five function implementations
@ 2017-04-23  9:06 ` SF Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-23  9:06 UTC (permalink / raw)
  To: dmaengine, Dan Williams, Vinod Koul, Zhangfei Gao; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.12.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe()
  2017-04-23  9:06 ` SF Markus Elfring
@ 2017-04-23  9:07   ` SF Markus Elfring
  -1 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-23  9:07 UTC (permalink / raw)
  To: dmaengine, Dan Williams, Vinod Koul, Zhangfei Gao; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/k3dma.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 01e25c68dd5a..31a51ee1a910 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -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;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe()
@ 2017-04-23  9:07   ` SF Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-23  9:07 UTC (permalink / raw)
  To: dmaengine, Dan Williams, Vinod Koul, Zhangfei Gao; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/k3dma.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 01e25c68dd5a..31a51ee1a910 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -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;
 
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] dmaengine: k3dma: Adjust six checks for null pointers
  2017-04-23  9:06 ` SF Markus Elfring
@ 2017-04-23  9:09   ` SF Markus Elfring
  -1 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-23  9:09 UTC (permalink / raw)
  To: dmaengine, Dan Williams, Vinod Koul, Zhangfei Gao; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/k3dma.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 31a51ee1a910..da20565f7a8d 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -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++) {
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] dmaengine: k3dma: Adjust six checks for null pointers
@ 2017-04-23  9:09   ` SF Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-23  9:09 UTC (permalink / raw)
  To: dmaengine, Dan Williams, Vinod Koul, Zhangfei Gao; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/k3dma.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 31a51ee1a910..da20565f7a8d 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -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++) {
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-23  9:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-23  9:06 [PATCH 0/2] dmaengine: k3dma: Fine-tuning for five function implementations SF Markus Elfring
2017-04-23  9:06 ` SF Markus Elfring
2017-04-23  9:07 ` [PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe() SF Markus Elfring
2017-04-23  9:07   ` SF Markus Elfring
2017-04-23  9:09 ` [PATCH 2/2] dmaengine: k3dma: Adjust six checks for null pointers SF Markus Elfring
2017-04-23  9:09   ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.