From nobody Sun May 10 06:31:16 2026 Received: from mail-10627.protonmail.ch (mail-10627.protonmail.ch [79.135.106.27]) (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 4254DA59 for ; Mon, 30 Dec 2024 05:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.135.106.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735535221; cv=none; b=MHlXNIJUbSxFX6vOcyBxHNM5uS3hiLP5mMnxCoW515tG4DNzqueTfosFkVPOpy2pd+aZZyQgaumoPYOyfJMEyWzjXiR/Gdvq8MbGpMsQUQX5Njcig5a1NekiEGdjjyJMIVNOIR3IH1uZdpJQqaDaayLeOoOlEL6HnAPB/bNnf10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735535221; c=relaxed/simple; bh=5+Zs7PAC/Sq/9+SqtfPStEN8kzJl369O2vRSi9YYIZ4=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=RjefD3+W61e8dF7hn9zUiVaUFVhbFOFVgHDZgBs8Af15uaYrLJwtfl8aqYsGqOZOD6vA25cm53vtsBebpXKZT2giKHH6kTxS6q4A9x4EKEGB2G/f2LlKk8J3q9u3FbriSvVyEnC54hHVPmmEUYcLn/dLNDV64LgoKgeyd/M1QNk= 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=YJ5mTYvN; arc=none smtp.client-ip=79.135.106.27 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="YJ5mTYvN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ethancedwards.com; s=protonmail3; t=1735535211; x=1735794411; bh=5+Zs7PAC/Sq/9+SqtfPStEN8kzJl369O2vRSi9YYIZ4=; 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=YJ5mTYvNiioGhpDbIHkM0RYf7kfvHZ5gMpUXok8l9VuK07QEXOA+iExkenlj9+59Y 6VTvAHDNRhjDSiCpT4hcHrDCGFA6OPM7F4ALKKCwlwWUeiEtuESIE/6/lWATc29Ji/ 7aEd/nKQa5D7Djl00Ydy4s6PCAwY8aaVdmens7LPRE/8QJfGbZ4KU5rC6H3l0hLyyv m6021VMn8dUYUV7kahiYkwY4kwJQe+aDn9MKrWLESfExgofNww2rvLrgvj+JQpRUTL mKiVHDMLcBJ4KfUF1ptCHeKYb+CW+B6Hdd45fG+gqm3cHPXf8L7+lxN9PP0Np2dWqF LdkxXGQodoSqA== Date: Mon, 30 Dec 2024 05:06:47 +0000 To: perex@perex.cz From: Ethan Carter Edwards Cc: tiwai@suse.com, arnd@arndb.de, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, ryan_richards@creativelabs.com, wychay@ctl.creative.com Subject: [PATCH] ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions Message-ID: Feedback-ID: 28410670:user:proton X-Pm-Message-ID: 0a033f8720ff3cef809a72c98d79dec388f48051 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 --- sound/pci/ctxfi/ctdaio.c | 52 +++++++++++++--------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 83aaf9441ef3..882afe451dc1 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -211,52 +211,34 @@ 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; - - 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; - } - - kfree(dao->imappers[daio->rscl.msr]); - dao->imappers[daio->rscl.msr] =3D NULL; +static int dao_clear_left_input(struct dao *dao) +{ + u32 offset =3D dao->daio.rscl.msr; + + return dao_clear_input(dao, 0, 0 + offset); +} =20 - return 0; +static int dao_clear_right_input(struct dao *dao) +{ + u32 start =3D dao->daio.rscl.msr; + u32 offset =3D dao->daio.rscr.msr; + + return dao_clear_input(dao, start, start + offset); } =20 static const struct dao_rsc_ops dao_ops =3D { --=20 2.47.1