* [PATCH v3] ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions
@ 2025-01-20 1:10 Ethan Carter Edwards
2025-01-20 8:27 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Ethan Carter Edwards @ 2025-01-20 1:10 UTC (permalink / raw)
To: David Laight
Cc: tiwai, perex, arnd, linux-sound, linux-kernel, ryan_richards,
wychay, Kuan-Wei Chiu
There was a lote of code duplication in the dao_clear_left_input() and
dao_clear_right_input() functions. A new function, dao_clear_input(),
was created and now the left and right functions call it instead of
repeating themselves.
Link: https://lore.kernel.org/lkml/NyKCr2VHK_xCQDwNxFKKx2LVd2d_AC2f2j4eAvnD9uRPtb50i2AruCLOp6mHxsGiyYJ0Tgd3Z50Oy1JTi5gPhjd2WQM2skrv7asp3fLl8HU=@ethancedwards.com/
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
v3: remove temp variables
v2: email client woes
sound/pci/ctxfi/ctdaio.c | 48 +++++++++++-----------------------------
1 file changed, 13 insertions(+), 35 deletions(-)
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index 83aaf9441ef3..9993b02d2968 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -211,52 +211,30 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input)
return 0;
}
-static int dao_clear_left_input(struct dao *dao)
+static int dao_clear_input(struct dao *dao, unsigned int start, unsigned int end)
{
- struct imapper *entry;
- struct daio *daio = &dao->daio;
- int i;
+ unsigned int i;
- if (!dao->imappers[0])
+ if (!dao->imappers[start])
return 0;
-
- entry = dao->imappers[0];
- dao->mgr->imap_delete(dao->mgr, entry);
- /* Program conjugate resources */
- for (i = 1; i < daio->rscl.msr; i++) {
- entry = dao->imappers[i];
- dao->mgr->imap_delete(dao->mgr, entry);
+ for (i = start; i < end; i++) {
+ dao->mgr->imap_delete(dao->mgr, dao->imappers[i]);
dao->imappers[i] = NULL;
}
- kfree(dao->imappers[0]);
- dao->imappers[0] = NULL;
-
return 0;
}
-static int dao_clear_right_input(struct dao *dao)
-{
- struct imapper *entry;
- struct daio *daio = &dao->daio;
- int i;
- if (!dao->imappers[daio->rscl.msr])
- return 0;
-
- entry = dao->imappers[daio->rscl.msr];
- dao->mgr->imap_delete(dao->mgr, entry);
- /* Program conjugate resources */
- for (i = 1; i < daio->rscr.msr; i++) {
- entry = dao->imappers[daio->rscl.msr + i];
- dao->mgr->imap_delete(dao->mgr, entry);
- dao->imappers[daio->rscl.msr + i] = NULL;
- }
-
- kfree(dao->imappers[daio->rscl.msr]);
- dao->imappers[daio->rscl.msr] = NULL;
+static int dao_clear_left_input(struct dao *dao)
+{
+ return dao_clear_input(dao, 0, dao->daio.rscl.msr);
+}
- return 0;
+static int dao_clear_right_input(struct dao *dao)
+{
+ return dao_clear_input(dao, dao->daio.rscl.msr,
+ dao->daio.rscl.msr + dao->daio.rscr.msr);
}
static const struct dao_rsc_ops dao_ops = {
--
2.48.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v3] ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions
2025-01-20 1:10 [PATCH v3] ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions Ethan Carter Edwards
@ 2025-01-20 8:27 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2025-01-20 8:27 UTC (permalink / raw)
To: Ethan Carter Edwards
Cc: David Laight, tiwai, perex, arnd, linux-sound, linux-kernel,
ryan_richards, wychay, Kuan-Wei Chiu
On Mon, 20 Jan 2025 02:10:30 +0100,
Ethan Carter Edwards wrote:
>
> There was a lote of code duplication in the dao_clear_left_input() and
> dao_clear_right_input() functions. A new function, dao_clear_input(),
> was created and now the left and right functions call it instead of
> repeating themselves.
>
> Link: https://lore.kernel.org/lkml/NyKCr2VHK_xCQDwNxFKKx2LVd2d_AC2f2j4eAvnD9uRPtb50i2AruCLOp6mHxsGiyYJ0Tgd3Z50Oy1JTi5gPhjd2WQM2skrv7asp3fLl8HU=@ethancedwards.com/
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
Thanks, applied.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-20 8:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20 1:10 [PATCH v3] ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions Ethan Carter Edwards
2025-01-20 8:27 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox