summaryrefslogtreecommitdiff
path: root/drivers/iio/adc/xilinx-ams.c
diff options
context:
space:
mode:
authorJames Clark <james.clark@arm.com>2023-05-09 10:49:40 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-30 21:07:15 +0100
commit7c054b2cbac388a86ed6a85b831c044a0325e150 (patch)
tree165edc97c2c2983dc8f87b0a98695e071f2c32e8 /drivers/iio/adc/xilinx-ams.c
parentc5f7548445b6adc48c9076073a6f20b8806e9a87 (diff)
iio: adc: Use devm_krealloc_array
Now that it exists, use it instead of doing the multiplication and checking for overflow manually. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: James Clark <james.clark@arm.com> Link: https://lore.kernel.org/r/20230509094942.396150-4-james.clark@arm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio/adc/xilinx-ams.c')
-rw-r--r--drivers/iio/adc/xilinx-ams.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
index 34cf336b3490..f0b71a1220e0 100644
--- a/drivers/iio/adc/xilinx-ams.c
+++ b/drivers/iio/adc/xilinx-ams.c
@@ -1263,7 +1263,7 @@ static int ams_parse_firmware(struct iio_dev *indio_dev)
struct device *dev = indio_dev->dev.parent;
struct fwnode_handle *child = NULL;
struct fwnode_handle *fwnode = dev_fwnode(dev);
- size_t ams_size, dev_size;
+ size_t ams_size;
int ret, ch_cnt = 0, i, rising_off, falling_off;
unsigned int num_channels = 0;
@@ -1320,11 +1320,8 @@ static int ams_parse_firmware(struct iio_dev *indio_dev)
}
}
- dev_size = array_size(sizeof(*dev_channels), num_channels);
- if (dev_size == SIZE_MAX)
- return -ENOMEM;
-
- dev_channels = devm_krealloc(dev, ams_channels, dev_size, GFP_KERNEL);
+ dev_channels = devm_krealloc_array(dev, ams_channels, num_channels,
+ sizeof(*dev_channels), GFP_KERNEL);
if (!dev_channels)
return -ENOMEM;