From: Rosen Penev <rosenp@gmail.com>
To: linux-sound@vger.kernel.org
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ALSA: ctxfi: Use flexible array for SRCIMP imappers
Date: Mon, 11 May 2026 16:00:26 -0700 [thread overview]
Message-ID: <20260511230026.28488-1-rosenp@gmail.com> (raw)
Store the SRCIMP imapper entries in the SRCIMP resource allocation
instead of allocating a separate array.
This keeps the mapper table tied to the SRCIMP lifetime and removes
the extra allocation and cleanup paths.
Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
sound/pci/ctxfi/ctsrc.c | 15 +--------------
sound/pci/ctxfi/ctsrc.h | 2 +-
2 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
index 326997bb885d..46dc1f509234 100644
--- a/sound/pci/ctxfi/ctsrc.c
+++ b/sound/pci/ctxfi/ctsrc.c
@@ -668,13 +668,6 @@ static int srcimp_rsc_init(struct srcimp *srcimp,
if (err)
return err;
- /* Reserve memory for imapper nodes */
- srcimp->imappers = kzalloc_objs(struct imapper, desc->msr);
- if (!srcimp->imappers) {
- err = -ENOMEM;
- goto error1;
- }
-
/* Set srcimp specific operations */
srcimp->rsc.ops = &srcimp_basic_rsc_ops;
srcimp->ops = &srcimp_ops;
@@ -683,16 +676,10 @@ static int srcimp_rsc_init(struct srcimp *srcimp,
srcimp->rsc.ops->master(&srcimp->rsc);
return 0;
-
-error1:
- rsc_uninit(&srcimp->rsc);
- return err;
}
static int srcimp_rsc_uninit(struct srcimp *srcimp)
{
- kfree(srcimp->imappers);
- srcimp->imappers = NULL;
srcimp->ops = NULL;
srcimp->mgr = NULL;
rsc_uninit(&srcimp->rsc);
@@ -711,7 +698,7 @@ static int get_srcimp_rsc(struct srcimp_mgr *mgr,
*rsrcimp = NULL;
/* Allocate mem for SRCIMP resource */
- srcimp = kzalloc(sizeof(*srcimp), GFP_KERNEL);
+ srcimp = kzalloc_flex(*srcimp, imappers, desc->msr);
if (!srcimp)
return -ENOMEM;
diff --git a/sound/pci/ctxfi/ctsrc.h b/sound/pci/ctxfi/ctsrc.h
index e6366cc6a7ae..7ba94adde920 100644
--- a/sound/pci/ctxfi/ctsrc.h
+++ b/sound/pci/ctxfi/ctsrc.h
@@ -103,10 +103,10 @@ struct srcimp_rsc_ops;
struct srcimp {
struct rsc rsc;
unsigned char idx[8];
- struct imapper *imappers;
unsigned int mapped; /* A bit-map indicating which conj rsc is mapped */
struct srcimp_mgr *mgr;
const struct srcimp_rsc_ops *ops;
+ struct imapper imappers[];
};
struct srcimp_rsc_ops {
--
2.54.0
next reply other threads:[~2026-05-11 23:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 23:00 Rosen Penev [this message]
2026-05-15 6:56 ` [PATCH] ALSA: ctxfi: Use flexible array for SRCIMP imappers Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260511230026.28488-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.