summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-10-18 15:43:00 +0100
committerJonathan Cameron <jic23@kernel.org>2012-10-19 18:46:37 +0100
commit45259859492812c8b700ae1d157be01a8d2babfe (patch)
tree2e50aa19b1a1908502fd29dac2916299f3b60526
parent7737fa6d1ea3385428bd36a0dddcb33c526f7d74 (diff)
iio: at91_adc: Use devm_kcalloc to allocate arrays
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> Acked-By: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/adc/at91_adc.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 2e2c9a80aa37..a9176722042f 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -123,10 +123,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;
@@ -270,9 +268,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;
@@ -454,9 +451,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;