ARM: 9331/1: ARM/dma-mapping: replace kzalloc() and vzalloc() with kvzalloc()
authorChen Haonan <chen.haonan2@zte.com.cn>
Fri, 15 Dec 2023 10:04:40 +0000 (11:04 +0100)
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 5 Jan 2024 13:14:28 +0000 (13:14 +0000)
using kvzalloc() simplifies the code by avoiding the
use of different memory allocation functions for different
situations, making the code more uniform and readable.

Signed-off-by: Chen Haonan <chen.haonan2@zte.com.cn>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
arch/arm/mm/dma-mapping.c

index 5409225b4abc06b425c1483f53e087318c22a080..d688eac6dbc147db837cbffce186fb8c971b4df0 100644 (file)
@@ -859,10 +859,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
        int i = 0;
        int order_idx = 0;
 
-       if (array_size <= PAGE_SIZE)
-               pages = kzalloc(array_size, GFP_KERNEL);
-       else
-               pages = vzalloc(array_size);
+       pages = kvzalloc(array_size, GFP_KERNEL);
        if (!pages)
                return NULL;