Commit 45259859 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

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: default avatarLars-Peter Clausen <lars@metafoo.de>
Acked-By: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 7737fa6d
...@@ -123,10 +123,8 @@ static int at91_adc_channel_init(struct iio_dev *idev) ...@@ -123,10 +123,8 @@ static int at91_adc_channel_init(struct iio_dev *idev)
idev->num_channels = bitmap_weight(&st->channels_mask, idev->num_channels = bitmap_weight(&st->channels_mask,
st->num_channels) + 1; st->num_channels) + 1;
chan_array = devm_kzalloc(&idev->dev, chan_array = devm_kcalloc(&idev->dev, idev->num_channels + 1,
((idev->num_channels + 1) * sizeof(*chan_array), GFP_KERNEL);
sizeof(struct iio_chan_spec)),
GFP_KERNEL);
if (!chan_array) if (!chan_array)
return -ENOMEM; return -ENOMEM;
...@@ -270,9 +268,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev) ...@@ -270,9 +268,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
struct at91_adc_state *st = iio_priv(idev); struct at91_adc_state *st = iio_priv(idev);
int i, ret; int i, ret;
st->trig = devm_kzalloc(&idev->dev, st->trig = devm_kcalloc(&idev->dev, st->trigger_number,
st->trigger_number * sizeof(st->trig), sizeof(*st->trig), GFP_KERNEL);
GFP_KERNEL);
if (st->trig == NULL) { if (st->trig == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -454,9 +451,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, ...@@ -454,9 +451,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
st->registers->trigger_register = prop; st->registers->trigger_register = prop;
st->trigger_number = of_get_child_count(node); st->trigger_number = of_get_child_count(node);
st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number * st->trigger_list = devm_kcalloc(&idev->dev, st->trigger_number,
sizeof(struct at91_adc_trigger), sizeof(*st->trigger_list), GFP_KERNEL);
GFP_KERNEL);
if (!st->trigger_list) { if (!st->trigger_list) {
dev_err(&idev->dev, "Could not allocate trigger list memory.\n"); dev_err(&idev->dev, "Could not allocate trigger list memory.\n");
ret = -ENOMEM; ret = -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment