mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: emu10k1: using vmalloc_array() to handle the code
@ 2025-10-22  9:27 tanze
  2025-10-23  6:35 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: tanze @ 2025-10-22  9:27 UTC (permalink / raw)
  To: perex, tiwai, phasta, andriy.shevchenko, linux-sound; +Cc: linux-kernel, tanze

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>
---
 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 b2fe2d164ba8..bdbd2dea1c4a 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1574,10 +1574,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 37af7bf76347..091f6accfc44 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -2629,7 +2629,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 b74128e61254..79b097ada22b 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -791,7 +791,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.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-23  6:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-22  9:27 [PATCH] ALSA: emu10k1: using vmalloc_array() to handle the code tanze
2025-10-23  6:35 ` Andy Shevchenko
2025-10-23  6:51   ` tanze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®