[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251022092738.552700-1-tanze@kylinos.cn>
Date: Wed, 22 Oct 2025 17:27:38 +0800
From: tanze <tanze@...inos.cn>
To: perex@...ex.cz,
tiwai@...e.com,
phasta@...nel.org,
andriy.shevchenko@...ux.intel.com,
linux-sound@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
tanze <tanze@...inos.cn>
Subject: [PATCH] ALSA: emu10k1: using vmalloc_array() to handle the code
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@...inos.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
Powered by blists - more mailing lists