[PATCH 2/3] ALSA: emu10k1: use vmalloc_array() to simplify code

Qianfeng Rong posted 3 patches 1 month, 1 week ago
[PATCH 2/3] ALSA: emu10k1: use vmalloc_array() to simplify code
Posted by Qianfeng Rong 1 month, 1 week ago
Remove array_size() calls and replace vmalloc() with vmalloc_array() to
simplify the code and maintain consistency with existing kmalloc_array()
usage.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 sound/pci/emu10k1/emu10k1_main.c | 8 ++++----
 sound/pci/emu10k1/emufx.c        | 2 +-
 sound/pci/emu10k1/p16v.c         | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index bbe252b8916c..f6ae78956eca 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1579,10 +1579,10 @@ int snd_emu10k1_create(struct snd_card *card,
 		(unsigned long)emu->ptb_pages.addr,
 		(unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes));
 
-	emu->page_ptr_table = vmalloc(array_size(sizeof(void *),
-						 emu->max_cache_pages));
-	emu->page_addr_table = vmalloc(array_size(sizeof(unsigned long),
-						  emu->max_cache_pages));
+	emu->page_ptr_table = vmalloc_array(emu->max_cache_pages,
+					    sizeof(void *));
+	emu->page_addr_table = vmalloc_array(emu->max_cache_pages,
+					     sizeof(unsigned long));
 	if (!emu->page_ptr_table || !emu->page_addr_table)
 		return -ENOMEM;
 
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 7db0660e6b61..130e713fe248 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -2648,7 +2648,7 @@ int snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu)
 	if (! emu->tram_val_saved || ! emu->tram_addr_saved)
 		return -ENOMEM;
 	len = emu->audigy ? 2 * 1024 : 2 * 512;
-	emu->saved_icode = vmalloc(array_size(len, 4));
+	emu->saved_icode = vmalloc_array(len, 4);
 	if (! emu->saved_icode)
 		return -ENOMEM;
 	return 0;
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index e774174d10de..ca732e6464ec 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -795,7 +795,7 @@ int snd_p16v_mixer(struct snd_emu10k1 *emu)
 
 int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu)
 {
-	emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80));
+	emu->p16v_saved = vmalloc_array(NUM_CHS * 4, 0x80);
 	if (! emu->p16v_saved)
 		return -ENOMEM;
 	return 0;
-- 
2.34.1