[PATCH 3/3] media: pt1: Optimize the code using vmalloc_array

tanze posted 3 patches 3 months, 3 weeks ago
There is a newer version of this series
[PATCH 3/3] media: pt1: Optimize the code using vmalloc_array
Posted by tanze 3 months, 3 weeks ago
Change array_size() to vmalloc_array(), Due to vmalloc_array() is optimized better,
uses fewer instructions, and handles overflow more concisely

Signed-off-by: tanze <tanze@kylinos.cn>
---
 drivers/media/pci/pt1/pt1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index 121a4a92ea10..963fa5e13d33 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -639,7 +639,7 @@ static int pt1_init_tables(struct pt1 *pt1)
 	if (!pt1_nr_tables)
 		return 0;
 
-	tables = vmalloc(array_size(pt1_nr_tables, sizeof(struct pt1_table)));
+	tables = vmalloc_array(sizeof(struct pt1_table), pt1_nr_tables);
 	if (tables == NULL)
 		return -ENOMEM;
 
-- 
2.25.1