diff options
-rw-r--r-- | drivers/iio/adc/at91_adc.c | 16 |
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) | |||
123 | idev->num_channels = bitmap_weight(&st->channels_mask, | 123 | idev->num_channels = bitmap_weight(&st->channels_mask, |
124 | st->num_channels) + 1; | 124 | st->num_channels) + 1; |
125 | 125 | ||
126 | chan_array = devm_kzalloc(&idev->dev, | 126 | chan_array = devm_kcalloc(&idev->dev, idev->num_channels + 1, |
127 | ((idev->num_channels + 1) * | 127 | sizeof(*chan_array), GFP_KERNEL); |
128 | sizeof(struct iio_chan_spec)), | ||
129 | GFP_KERNEL); | ||
130 | 128 | ||
131 | if (!chan_array) | 129 | if (!chan_array) |
132 | return -ENOMEM; | 130 | return -ENOMEM; |
@@ -270,9 +268,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev) | |||
270 | struct at91_adc_state *st = iio_priv(idev); | 268 | struct at91_adc_state *st = iio_priv(idev); |
271 | int i, ret; | 269 | int i, ret; |
272 | 270 | ||
273 | st->trig = devm_kzalloc(&idev->dev, | 271 | st->trig = devm_kcalloc(&idev->dev, st->trigger_number, |
274 | st->trigger_number * sizeof(st->trig), | 272 | sizeof(*st->trig), GFP_KERNEL); |
275 | GFP_KERNEL); | ||
276 | 273 | ||
277 | if (st->trig == NULL) { | 274 | if (st->trig == NULL) { |
278 | ret = -ENOMEM; | 275 | ret = -ENOMEM; |
@@ -454,9 +451,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, | |||
454 | st->registers->trigger_register = prop; | 451 | st->registers->trigger_register = prop; |
455 | 452 | ||
456 | st->trigger_number = of_get_child_count(node); | 453 | st->trigger_number = of_get_child_count(node); |
457 | st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number * | 454 | st->trigger_list = devm_kcalloc(&idev->dev, st->trigger_number, |
458 | sizeof(struct at91_adc_trigger), | 455 | sizeof(*st->trigger_list), GFP_KERNEL); |
459 | GFP_KERNEL); | ||
460 | if (!st->trigger_list) { | 456 | if (!st->trigger_list) { |
461 | dev_err(&idev->dev, "Could not allocate trigger list memory.\n"); | 457 | dev_err(&idev->dev, "Could not allocate trigger list memory.\n"); |
462 | ret = -ENOMEM; | 458 | ret = -ENOMEM; |