ALSA: ctxfi: Use flexible array for SRCIMP imappers
PATCH 1/1 ALSA: ctxfi: Use flexible array for SRCIMP imappers
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 <[email protected]>
--- sound/pci/ctxfi/ctsrc.c | 15 +-------------- sound/pci/ctxfi/ctsrc.h | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-)
sound/pci/ctxfi/ctsrc.c +1 -14
@@ -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 ;
sound/pci/ctxfi/ctsrc.h +1 -1
@@ -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 {
Signature · 1 line
2.54.0
Takashi Iwai
AppliedQuoted 9 lines · Rosen Penev
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.5Signed-off-by Rosen Penev <[email protected]>
Applied to for-next branch. Thanks.
Takashi