From nobody Sun May 10 06:27:04 2026 Received: from mail-10624.protonmail.ch (mail-10624.protonmail.ch [79.135.106.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BCD2382 for ; Mon, 30 Dec 2024 15:33:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.135.106.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735572794; cv=none; b=E1ki/L89pW++pquLj5cHw3zOEYjnq5tHfEB49mOSB9q+D+3zGbtAwSmntdvC4Fv3mnKdxKrEUOCfs6wDhhIsrCw1bSzICWp36ipkX6EUK8BkJww9UG+ViTM9ydGxpTm50QSmj8jmlRxnqkoGCGU/hgaykCedymAoYGO4ktq5ync= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735572794; c=relaxed/simple; bh=BiwcDEI2vECSei2cw+UtETBJRtoS+pSaYPD5QT/HKEw=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=d25a1aT7xzPb+ITAEWr/uGBWWTegJZiWdxmUY8YxM/B0C1twMuOM+Rv6pbJ9/YyI1eUT4FHJHv2UXLaAquRSphKa1vvLYVeKIPCnlWuHwq+eFxL+fxQFOlUPP1JOs49/F7VerRbUjagcX5y1r3mP6uAfr2zktU+jDTmEiF8nKoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ethancedwards.com; spf=pass smtp.mailfrom=ethancedwards.com; dkim=pass (2048-bit key) header.d=ethancedwards.com header.i=@ethancedwards.com header.b=j4mmJMHO; arc=none smtp.client-ip=79.135.106.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ethancedwards.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ethancedwards.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ethancedwards.com header.i=@ethancedwards.com header.b="j4mmJMHO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ethancedwards.com; s=protonmail3; t=1735572784; x=1735831984; bh=BiwcDEI2vECSei2cw+UtETBJRtoS+pSaYPD5QT/HKEw=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=j4mmJMHOjOjYRZlx9iBUEXQsaiZ0fXqpGa2EaS+e68Ic4bqWCEhV4iFSdJIY1noEK gbk4v58se2urPdE1ce7rXtu1CzxkZG+i+404+mub1rcMsGe/exynC5ybowq7m8un3+ t4H1j8m1RpPmffH5U8PihtA6xP3wMLrHJdJyrxM/cxHmbSN+WTVPdC4RwXCoqi0uA6 BsMqENkeh4ogdGqIPLZvw92YaTqrmtIN/Wl/zeLhsiOEo+eGckPptWLMGPbPeUzSn+ mNz20kv6AcCSTIHvs593bcyhKPq/cP88sPfDV0gVREMDPgVbrZd2t6+GkKiG38DhdX +z6EVMrrXrNgQ== Date: Mon, 30 Dec 2024 15:32:58 +0000 To: tiwai@suse.de From: Ethan Carter Edwards Cc: tiwai@suse.com, perex@perex.cz, arnd@arndb.de, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, ryan_richards@creativelabs.com, wychay@ctl.creative.com, Ethan Carter Edwards , David Laight Subject: [PATCH v2] ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions Message-ID: <20241230153243.2874102-1-ethan@ethancedwards.com> Feedback-ID: 28410670:user:proton X-Pm-Message-ID: 9cf0945da37f615659ee72242c50eb6ef575ce11 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_AC2f2j4eAvnD= 9uRPtb50i2AruCLOp6mHxsGiyYJ0Tgd3Z50Oy1JTi5gPhjd2WQM2skrv7asp3fLl8HU=3D@etha= ncedwards.com/ Signed-off-by: Ethan Carter Edwards Co-developed-by: David Laight --- Changes in V2: Fixed formatting caused by email client. Sorry! sound/pci/ctxfi/ctdaio.c | 50 ++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 83aaf9441ef3..d46542d0b454 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -211,52 +211,36 @@ static int dao_set_right_input(struct dao *dao, struc= t rsc *input) return 0; } =20 -static int dao_clear_left_input(struct dao *dao) +static int dao_clear_input(struct dao *dao, unsigned int start, unsigned i= nt end) { - struct imapper *entry; - struct daio *daio =3D &dao->daio; - int i; + struct imapper *to_free =3D dao->imappers[start]; + unsigned int i; =20 - if (!dao->imappers[0]) + if (!to_free) return 0; - - entry =3D dao->imappers[0]; - dao->mgr->imap_delete(dao->mgr, entry); - /* Program conjugate resources */ - for (i =3D 1; i < daio->rscl.msr; i++) { - entry =3D dao->imappers[i]; - dao->mgr->imap_delete(dao->mgr, entry); + for (i =3D start; i < end; i++) { + dao->mgr->imap_delete(dao->mgr, dao->imappers[i]); dao->imappers[i] =3D NULL; } =20 - kfree(dao->imappers[0]); - dao->imappers[0] =3D NULL; - + kfree(to_free); return 0; } =20 -static int dao_clear_right_input(struct dao *dao) -{ - struct imapper *entry; - struct daio *daio =3D &dao->daio; - int i; =20 - if (!dao->imappers[daio->rscl.msr]) - return 0; +static int dao_clear_left_input(struct dao *dao) +{ + u32 offset =3D dao->daio.rscl.msr; =20 - entry =3D dao->imappers[daio->rscl.msr]; - dao->mgr->imap_delete(dao->mgr, entry); - /* Program conjugate resources */ - for (i =3D 1; i < daio->rscr.msr; i++) { - entry =3D dao->imappers[daio->rscl.msr + i]; - dao->mgr->imap_delete(dao->mgr, entry); - dao->imappers[daio->rscl.msr + i] =3D NULL; - } + return dao_clear_input(dao, 0, 0 + offset); +} =20 - kfree(dao->imappers[daio->rscl.msr]); - dao->imappers[daio->rscl.msr] =3D NULL; +static int dao_clear_right_input(struct dao *dao) +{ + u32 start =3D dao->daio.rscl.msr; + u32 offset =3D dao->daio.rscr.msr; =20 - return 0; + return dao_clear_input(dao, start, start + offset); } =20 static const struct dao_rsc_ops dao_ops =3D { --=20 2.47.1