diff mbox series

[v5,10/12] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()

Message ID 20250212062513.2254767-11-raag.jadav@intel.com (mailing list archive)
State Handled Elsewhere
Headers show
Series Split devres APIs to device/devres.h and introduce devm_kmemdup_array() | expand

Commit Message

Raag Jadav Feb. 12, 2025, 6:25 a.m. UTC
Convert to use devm_kmemdup_array() and while at it, use source size
instead of destination.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/iio/adc/xilinx-xadc-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Feb. 16, 2025, 4:59 p.m. UTC | #1
On Wed, 12 Feb 2025 11:55:11 +0530
Raag Jadav <raag.jadav@intel.com> wrote:

> Convert to use devm_kmemdup_array() and while at it, use source size
> instead of destination.
> 
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>

Seems fine to me.
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/xilinx-xadc-core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
> index cfbfcaefec0f..e1f8740ae688 100644
> --- a/drivers/iio/adc/xilinx-xadc-core.c
> +++ b/drivers/iio/adc/xilinx-xadc-core.c
> @@ -1245,8 +1245,8 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, unsigned int *conf, int irq)
>  		channel_templates = xadc_us_channels;
>  		max_channels = ARRAY_SIZE(xadc_us_channels);
>  	}
> -	channels = devm_kmemdup(dev, channel_templates,
> -				sizeof(channels[0]) * max_channels, GFP_KERNEL);
> +	channels = devm_kmemdup_array(dev, channel_templates, max_channels,
> +				      sizeof(*channel_templates), GFP_KERNEL);
>  	if (!channels)
>  		return -ENOMEM;
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index cfbfcaefec0f..e1f8740ae688 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -1245,8 +1245,8 @@  static int xadc_parse_dt(struct iio_dev *indio_dev, unsigned int *conf, int irq)
 		channel_templates = xadc_us_channels;
 		max_channels = ARRAY_SIZE(xadc_us_channels);
 	}
-	channels = devm_kmemdup(dev, channel_templates,
-				sizeof(channels[0]) * max_channels, GFP_KERNEL);
+	channels = devm_kmemdup_array(dev, channel_templates, max_channels,
+				      sizeof(*channel_templates), GFP_KERNEL);
 	if (!channels)
 		return -ENOMEM;