From: SF Markus Elfring <elfring@users.sourceforge.net>
To: dmaengine@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
Shawn Guo <shawn.guo@linaro.org>,
Vinod Koul <vinod.koul@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/2] dmaengine: zx: Use devm_kcalloc() in zx_dma_probe()
Date: Sat, 22 Apr 2017 22:31:27 +0200 [thread overview]
Message-ID: <e2b06d15-e639-43d0-6eee-42268b322d88@users.sourceforge.net> (raw)
In-Reply-To: <85b8d46d-1643-0fdd-b295-9359ebca6444@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Apr 2017 22:00:10 +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/zx_dma.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c
index 2bb695315300..4f7587a100ea 100644
--- a/drivers/dma/zx_dma.c
+++ b/drivers/dma/zx_dma.c
@@ -798,8 +798,8 @@ static int zx_dma_probe(struct platform_device *op)
return -ENOMEM;
/* init phy channel */
- d->phy = devm_kzalloc(&op->dev,
- d->dma_channels * sizeof(struct zx_dma_phy), GFP_KERNEL);
+ d->phy = devm_kcalloc(&op->dev, d->dma_channels, sizeof(*d->phy),
+ GFP_KERNEL);
if (!d->phy)
return -ENOMEM;
@@ -834,8 +834,8 @@ static int zx_dma_probe(struct platform_device *op)
d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
/* init virtual channel */
- d->chans = devm_kzalloc(&op->dev,
- d->dma_requests * sizeof(struct zx_dma_chan), GFP_KERNEL);
+ d->chans = devm_kcalloc(&op->dev, d->dma_requests, sizeof(*d->chans),
+ GFP_KERNEL);
if (!d->chans)
return -ENOMEM;
--
2.12.2
next prev parent reply other threads:[~2017-04-22 20:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-22 20:30 [PATCH 0/2] dmaengine: zx: Fine-tuning for two function implementations SF Markus Elfring
2017-04-22 20:31 ` SF Markus Elfring [this message]
2017-04-22 20:32 ` [PATCH 2/2] dmaengine: zx: Fix a typo in a comment line SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2b06d15-e639-43d0-6eee-42268b322d88@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shawn.guo@linaro.org \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome