public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Harsha Priya <harshapriya.n@intel.com>,
	alsa-devel@alsa-project.org, broonie@kernel.org
Cc: yang.jie@linux.intel.com, rad@semihalf.com, zwisler@google.com,
	linux-kernel@vger.kernel.org, liam.r.girdwood@linux.intel.com,
	Vamshi Krishna Gopal <vamshi.krishna.gopal@intel.com>,
	sathya.prakash.m.r@intel.com, brndt@google.com, mw@semihalf.com,
	levinale@chromium.org, lma@semihalf.com
Subject: Re: [PATCH v7] ASoC: Intel: kbl_rt5663_rt5514_max98927: Fix kabylake_ssp_fixup function
Date: Tue, 21 Jul 2020 16:32:18 -0500	[thread overview]
Message-ID: <d72ea889-9820-880d-0207-6d2f0dc23bcc@linux.intel.com> (raw)
In-Reply-To: <1595365649-8019-1-git-send-email-harshapriya.n@intel.com>

Hi Harsha,
this looks mostly good to me, only have a couple of nit-picks below.
Thanks!

> kabylake_ssp_fixup function uses snd_soc_dpcm to identify the codecs DAIs.
> The hw parameters are changed based on the codec DAI,
> the stream is intended for. The earlier approach to get
> snd_soc_dpcm was using container_of() macro on snd_pcm_hw_params.
> The structures have been modified over time and snd_soc_dpcm does
> not have snd_pcm_hw_params as a reference but as a copy.
> This causes the current driver to crash when used.
> This patch changes the way snd_soc_dpcm is extracted.
> The snd_soc_pcm_runtime holds 2 dpcm
> instances (one for playback and one for capture).
> The 2 codecs on this SSP are dmic and speakers.
> One is for capture and one is for playback respectively.
> Based on the direction of the stream,
> the snd_soc_dpcm is extracted from the snd_soc_pcm_runtime structure.
> Tested for all use cases of the driver.

Maybe reformat a bit and add newlines, this is difficult to read.

> Signed-off-by: Harsha Priya <harshapriya.n@intel.com>
> Signed-off-by: Vamshi Krishna Gopal <vamshi.krishna.gopal@intel.com>
> Tested-by: Lukasz Majczak <lma@semihalf.com>

> diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> index 584e4f9cedc2..9f4b949cc39c 100644
> --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> @@ -379,22 +379,42 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
>   	struct snd_interval *chan = hw_param_interval(params,
>   			SNDRV_PCM_HW_PARAM_CHANNELS);
>   	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
> -	struct snd_soc_dpcm *dpcm = container_of(
> -			params, struct snd_soc_dpcm, hw_params);
> -	struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
> -	struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
> +	struct snd_soc_dpcm *dpcm, *rtd_dpcm = NULL;

The idea of initializing was also to test before dereferencing this 
pointer. Without the test, this is somewhat useless, tools may still 
complain about dereferencing a NULL pointer?

> +
> +	/*
> +	 * The following loop will be called only for playback stream
> +	 * In this platform, there is only one playback device on every SSP
> +	 */
> +	for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) {
> +		rtd_dpcm = dpcm;
> +		break;
> +	}
> +
> +	/*
> +	 * This following loop will be called only for capture stream
> +	 * In this platform, there is only one capture device on every SSP
> +	 */
> +	for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) {
> +		rtd_dpcm = dpcm;
> +		break;
> +	}

add if (!rtd_dpcm) return -EINVAL here?

> +	/*
> +	 * The above 2 loops are mutually exclusive based on the strem direction,

typo: stream

> +	 * thus rtd_dpcm variable will never be overwritten
> +	 */


      reply	other threads:[~2020-07-21 21:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 21:07 [PATCH v7] ASoC: Intel: kbl_rt5663_rt5514_max98927: Fix kabylake_ssp_fixup function Harsha Priya
2020-07-21 21:32 ` Pierre-Louis Bossart [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d72ea889-9820-880d-0207-6d2f0dc23bcc@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=brndt@google.com \
    --cc=broonie@kernel.org \
    --cc=harshapriya.n@intel.com \
    --cc=levinale@chromium.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lma@semihalf.com \
    --cc=mw@semihalf.com \
    --cc=rad@semihalf.com \
    --cc=sathya.prakash.m.r@intel.com \
    --cc=vamshi.krishna.gopal@intel.com \
    --cc=yang.jie@linux.intel.com \
    --cc=zwisler@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox