diff mbox series

ASoC: SOF: ipc4-pcm: Move out be_rate initialization from for loop in fixup

Message ID 20250206094914.21135-1-peter.ujfalusi@linux.intel.com (mailing list archive)
State Accepted
Commit 5ea46b4360791345bd0bf4c7bf8fff5151374ea1
Headers show
Series ASoC: SOF: ipc4-pcm: Move out be_rate initialization from for loop in fixup | expand

Commit Message

Peter Ujfalusi Feb. 6, 2025, 9:49 a.m. UTC
Instead of initializing the be_rate within the loop by checking i == 0 at
each iteration, move the be_rate reference initialization from the loop.
For BE single rate check we will have single comparison done at each
iteration compared to two in case the num_input_formats were higher than 1.

We still need to run the loop from index 0 to check for FE-BE rate match.

The patch also fixes bogus reports from gcc static analyzer thinking that
be_rate is used uninitialized later in the function (which was not true).

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 sound/soc/sof/ipc4-pcm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Mark Brown Feb. 6, 2025, 8:44 p.m. UTC | #1
On Thu, 06 Feb 2025 11:49:14 +0200, Peter Ujfalusi wrote:
> Instead of initializing the be_rate within the loop by checking i == 0 at
> each iteration, move the be_rate reference initialization from the loop.
> For BE single rate check we will have single comparison done at each
> iteration compared to two in case the num_input_formats were higher than 1.
> 
> We still need to run the loop from index 0 to check for FE-BE rate match.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: SOF: ipc4-pcm: Move out be_rate initialization from for loop in fixup
      commit: 5ea46b4360791345bd0bf4c7bf8fff5151374ea1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/sof/ipc4-pcm.c b/sound/soc/sof/ipc4-pcm.c
index 18fff2df76f9..dc05e7490e6d 100644
--- a/sound/soc/sof/ipc4-pcm.c
+++ b/sound/soc/sof/ipc4-pcm.c
@@ -610,12 +610,11 @@  static int sof_ipc4_pcm_dai_link_fixup_rate(struct snd_sof_dev *sdev,
 	 * Copier does not change sampling rate, so we
 	 * need to only consider the input pin information.
 	 */
+	be_rate = pin_fmts[0].audio_fmt.sampling_frequency;
 	for (i = 0; i < num_input_formats; i++) {
 		unsigned int val = pin_fmts[i].audio_fmt.sampling_frequency;
 
-		if (i == 0)
-			be_rate = val;
-		else if (val != be_rate)
+		if (val != be_rate)
 			single_be_rate = false;
 
 		if (val == fe_rate) {