lkml.org 
[lkml]   [2020]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/5] iio: adc: xilinx: use devm_krealloc() instead of kfree() + kcalloc()
Date
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now have devm_krealloc() in the kernel Use it indstead of calling
kfree() and kcalloc() separately.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/iio/adc/xilinx-xadc-core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 8494eb424b33..b516280ccbd4 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -589,8 +589,9 @@ static int xadc_update_scan_mode(struct iio_dev *indio_dev,

n = bitmap_weight(mask, indio_dev->masklength);

- kfree(xadc->data);
- xadc->data = kcalloc(n, sizeof(*xadc->data), GFP_KERNEL);
+ xadc->data = devm_krealloc(indio_dev->dev.parent, xadc->data,
+ n * sizeof(*xadc->data),
+ GFP_KERNEL | __GFP_ZERO);
if (!xadc->data)
return -ENOMEM;

@@ -1372,7 +1373,6 @@ static int xadc_remove(struct platform_device *pdev)
free_irq(xadc->irq, indio_dev);
cancel_delayed_work_sync(&xadc->zynq_unmask_work);
clk_disable_unprepare(xadc->clk);
- kfree(xadc->data);

return 0;
}
--
2.29.1
\
 
 \ /
  Last update: 2020-10-26 14:37    [W:0.089 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site