From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>,
Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays
Date: Thu, 18 Oct 2012 16:43:19 +0200 [thread overview]
Message-ID: <1350571399-17723-4-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1350571399-17723-1-git-send-email-lars@metafoo.de>
Use dev_kcalloc instead of devm_kzalloc to allocate arrays since it is
semantically more appropriate.
While we are at it the patch also fixes the following coccinelle warning:
drivers/iio/adc/at91_adc.c:277:25-31: ERROR: application of sizeof to pointer
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/iio/adc/at91_adc.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 3ed94bf..b81f93b 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -126,10 +126,8 @@ static int at91_adc_channel_init(struct iio_dev *idev)
idev->num_channels = bitmap_weight(&st->channels_mask,
st->num_channels) + 1;
- chan_array = devm_kzalloc(&idev->dev,
- ((idev->num_channels + 1) *
- sizeof(struct iio_chan_spec)),
- GFP_KERNEL);
+ chan_array = devm_kcalloc(&idev->dev, idev->num_channels + 1,
+ sizeof(*chan_array), GFP_KERNEL);
if (!chan_array)
return -ENOMEM;
@@ -273,9 +271,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
struct at91_adc_state *st = iio_priv(idev);
int i, ret;
- st->trig = devm_kzalloc(&idev->dev,
- st->trigger_number * sizeof(st->trig),
- GFP_KERNEL);
+ st->trig = devm_kcalloc(&idev->dev, st->trigger_number,
+ sizeof(*st->trig), GFP_KERNEL);
if (st->trig == NULL) {
ret = -ENOMEM;
@@ -457,9 +454,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
st->registers->trigger_register = prop;
st->trigger_number = of_get_child_count(node);
- st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number *
- sizeof(struct at91_adc_trigger),
- GFP_KERNEL);
+ st->trigger_list = devm_kcalloc(&idev->dev, st->trigger_number,
+ sizeof(*st->trigger_list), GFP_KERNEL);
if (!st->trigger_list) {
dev_err(&idev->dev, "Could not allocate trigger list memory.\n");
ret = -ENOMEM;
--
1.7.10.4
next prev parent reply other threads:[~2012-10-18 14:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 14:43 [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Lars-Peter Clausen
2012-10-18 14:43 ` [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it Lars-Peter Clausen
2012-10-18 16:16 ` Roland Stigge
2012-10-19 15:26 ` Jonathan Cameron
2012-10-18 14:43 ` [PATCH 3/4] iio: Don't compare boolean values to true/false Lars-Peter Clausen
2012-10-19 15:27 ` Jonathan Cameron
2012-10-18 14:43 ` Lars-Peter Clausen [this message]
2012-10-19 8:54 ` [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays Maxime Ripard
2012-10-19 15:32 ` Jonathan Cameron
2012-10-19 15:24 ` [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Jonathan Cameron
2012-10-19 17:55 ` Lars-Peter Clausen
2012-10-19 17:59 ` Jonathan Cameron
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=1350571399-17723-4-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
--cc=maxime.ripard@free-electrons.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;
as well as URLs for NNTP newsgroup(s).