All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: Use flexible allocation for Scarlett2 packets
@ 2026-05-19  0:49 Rosen Penev
  2026-05-19  6:07 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-05-19  0:49 UTC (permalink / raw)
  To: linux-sound; +Cc: Geoffrey D. Bennett, Jaroslav Kysela, Takashi Iwai, open list

Allocate Scarlett2 USB packets and request buffers with the flex
allocation helpers for their trailing data arrays.

Keep the computed packet sizes where they are still needed for USB
transfer lengths.

Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 sound/usb/mixer_scarlett2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c
index 7ab3c0dd4755..2bdeb537a983 100644
--- a/sound/usb/mixer_scarlett2.c
+++ b/sound/usb/mixer_scarlett2.c
@@ -2614,13 +2614,13 @@ static int scarlett2_usb(
 
 	struct scarlett2_usb_packet *req __free(kfree) = NULL;
 	size_t req_buf_size = struct_size(req, data, req_size);
-	req = kmalloc(req_buf_size, GFP_KERNEL);
+	req = kmalloc_flex(*req, data, req_size);
 	if (!req)
 		return -ENOMEM;
 
 	struct scarlett2_usb_packet *resp __free(kfree) = NULL;
 	size_t resp_buf_size = struct_size(resp, data, resp_size);
-	resp = kmalloc(resp_buf_size, GFP_KERNEL);
+	resp = kmalloc_flex(*resp, data, resp_size);
 	if (!resp)
 		return -ENOMEM;
 
@@ -2830,9 +2830,9 @@ static int scarlett2_usb_set_data_buf(
 		u8 data[];
 	} __packed *req;
 	int err;
-	int buf_size = struct_size(req, data, bytes);
+	size_t buf_size = struct_size(req, data, bytes);
 
-	req = kmalloc(buf_size, GFP_KERNEL);
+	req = kmalloc_flex(*req, data, bytes);
 	if (!req)
 		return -ENOMEM;
 
@@ -9646,7 +9646,7 @@ static long scarlett2_hwdep_write(struct snd_hwdep *hw,
 
 	/* Create and send the request */
 	len = struct_size(req, data, count);
-	req = kzalloc(len, GFP_KERNEL);
+	req = kzalloc_flex(*req, data, count);
 	if (!req)
 		return -ENOMEM;
 
-- 
2.54.0


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

* Re: [PATCH] ALSA: usb-audio: Use flexible allocation for Scarlett2 packets
  2026-05-19  0:49 [PATCH] ALSA: usb-audio: Use flexible allocation for Scarlett2 packets Rosen Penev
@ 2026-05-19  6:07 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-05-19  6:07 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-sound, Geoffrey D. Bennett, Jaroslav Kysela, Takashi Iwai,
	open list

On Tue, 19 May 2026 02:49:35 +0200,
Rosen Penev wrote:
> 
> Allocate Scarlett2 USB packets and request buffers with the flex
> allocation helpers for their trailing data arrays.
> 
> Keep the computed packet sizes where they are still needed for USB
> transfer lengths.
> 
> Assisted-by: Codex:GPT-5.5
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Applied to for-next branch.  Thanks.


Takashi

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

end of thread, other threads:[~2026-05-19  6:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19  0:49 [PATCH] ALSA: usb-audio: Use flexible allocation for Scarlett2 packets Rosen Penev
2026-05-19  6:07 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.