Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Kenneth Westfield <kwestfie@codeaurora.org>
Cc: Takashi Iwai <tiwai@suse.de>, Liam Girdwood <lgirdwood@gmail.com>,
	David Brown <davidb@codeaurora.org>,
	Bryan Huntsman <bryanh@codeaurora.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	Banajit Goswami <bgoswami@codeaurora.org>,
	Patrick Lai <plai@codeaurora.org>,
	ALSA Mailing List <alsa-devel@alsa-project.org>,
	MSM Mailing List <linux-arm-msm@vger.kernel.org>,
	Device Tree Mailing List <devicetree@vger.kernel.org>
Subject: Re: [Patch V3 06/10] ASoC: ipq806x: Add LPASS CPU DAI driver
Date: Fri, 26 Dec 2014 16:56:04 +0000	[thread overview]
Message-ID: <20141226165604.GG17800@sirena.org.uk> (raw)
In-Reply-To: <1419439330-2303-7-git-send-email-kwestfie@codeaurora.org>

[-- Attachment #1: Type: text/plain, Size: 3080 bytes --]

On Wed, Dec 24, 2014 at 08:42:06AM -0800, Kenneth Westfield wrote:

> +static inline int lpass_lpaif_mi2s_config(struct snd_soc_dai *dai,
> +		unsigned int channels, unsigned int bitwidth)
> +{

This is *really* big for an inline function and doesn't have any obvious
need to be one if the compiler doesn't decide to do it for itself.
Since it only gets called from hw_params() I'm not even sure why it's a
function at all...  Similarly for some of the other functions, there's
no obvious reason to specify inline.

> +static inline void lpass_lpaif_mi2s_playback_start(struct snd_soc_dai *dai)
> +{
> +	struct lpass_mi2s_data *drvdata = snd_soc_dai_get_drvdata(dai);
> +	u32 mi2s_control_offset = LPAIF_MI2S_CTL_OFFSET(LPAIF_I2S_PORT_MI2S);
> +	u32 value;
> +
> +	value = readl(drvdata->base + mi2s_control_offset);
> +	value |= LPAIF_MI2SCTL_SPKEN;
> +	writel(value, drvdata->base + mi2s_control_offset);
> +}

> +static inline void lpass_lpaif_mi2s_playback_stop(struct snd_soc_dai *dai)
> +{

Defining functions for every read/modify/write operation is going to
make it harder to trace through the code and find out what the actual
operations are.  If the functions took parameters that allowed things to
be factored out that'd be one thing but they're not doing that.  Plus...

> +static int lpass_cpu_mi2s_daiops_hw_free(struct snd_pcm_substream *substream,
> +		struct snd_soc_dai *dai)
> +{
> +	lpass_lpaif_mi2s_playback_stop_clear(dai);
> +
> +	return 0;
> +}

...you're only calling most of these functions from one place which
consists only of a call to that function.  This is all just making
things more complicated than they need to be.

> +static int lpass_cpu_mi2s_daiops_prepare(struct snd_pcm_substream *substream,
> +		struct snd_soc_dai *dai)
> +{
> +	lpass_lpaif_mi2s_playback_start(dai);

Why are we not doing this stuff in the trigger opertaion?  All the start
and stop stuff looks like it's in the wrong place.

> +static int lpass_cpu_mi2s_daiops_set_sysclk(struct snd_soc_dai *dai,
> +		int clk_id, unsigned int freq, int dir)
> +{
> +	struct lpass_mi2s_data *drvdata = snd_soc_dai_get_drvdata(dai);
> +	int ret;
> +
> +	ret = clk_set_rate(drvdata->mi2s_osr_clk, freq);
> +	if (ret) {
> +		dev_err(dai->dev, "%s: error in setting mi2s osr clk: %d\n",
> +				__func__, ret);
> +		return ret;
> +	}

How is this supposed to work - we also set this clock unconditionally in
hw_params()?

> +static int lpass_cpu_mi2s_dai_probe(struct snd_soc_dai *dai)
> +{
> +	struct lpass_mi2s_data *drvdata = snd_soc_dai_get_drvdata(dai);
> +
> +	drvdata->mi2s_osr_clk = devm_clk_get(dai->dev, "mi2s_osr_clk");
> +	if (IS_ERR(drvdata->mi2s_osr_clk)) {
> +		dev_err(dai->dev, "%s: Error in getting mi2s_osr_clk\n",
> +				__func__);
> +		return PTR_ERR(drvdata->mi2s_osr_clk);
> +	}
> +
> +	drvdata->mi2s_bit_clk = devm_clk_get(dai->dev, "mi2s_bit_clk");
> +	if (IS_ERR(drvdata->mi2s_bit_clk)) {
> +		dev_err(dai->dev, "%s: Error in getting mi2s_bit_clk\n",
> +				__func__);
> +		return PTR_ERR(drvdata->mi2s_bit_clk);
> +	}

Why are we acquiring these at the DAI level?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2014-12-26 16:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-24 16:42 [Patch V3 00/10] ASoC: QCOM: Add support for ipq806x SOC Kenneth Westfield
     [not found] ` <1419439330-2303-1-git-send-email-kwestfie-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2014-12-24 16:42   ` [Patch V3 01/10] MAINTAINERS: Add QCOM audio ASoC maintainer Kenneth Westfield
2014-12-24 16:42 ` [Patch V3 02/10] ASoC: qcom: Document MAX98357A bindings Kenneth Westfield
2014-12-29 16:07   ` Mark Brown
2014-12-24 16:42 ` [Patch V3 03/10] ASoC: qcom: Document LPASS CPU bindings Kenneth Westfield
2014-12-26 16:43   ` Mark Brown
2014-12-24 16:42 ` [Patch V3 04/10] ASoC: codec: Add MAX98357A codec driver Kenneth Westfield
2014-12-26 16:44   ` Mark Brown
2014-12-24 16:42 ` [Patch V3 05/10] ASoC: ipq806x: add LPASS header files Kenneth Westfield
2014-12-24 16:42 ` [Patch V3 06/10] ASoC: ipq806x: Add LPASS CPU DAI driver Kenneth Westfield
2014-12-26 16:56   ` Mark Brown [this message]
2014-12-24 16:42 ` [Patch V3 07/10] ASoC: ipq806x: Add I2S PCM platform driver Kenneth Westfield
2014-12-26 17:03   ` Mark Brown
2014-12-24 16:42 ` [Patch V3 08/10] ASoC: qcom: Add ability to build QCOM drivers Kenneth Westfield
2014-12-24 16:42 ` [Patch V3 09/10] ASoC: Allow for building " Kenneth Westfield
2014-12-24 16:42 ` [Patch V3 10/10] ARM: dts: Model IPQ LPASS audio hardware Kenneth Westfield

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=20141226165604.GG17800@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@codeaurora.org \
    --cc=bryanh@codeaurora.org \
    --cc=davidb@codeaurora.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kwestfie@codeaurora.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=plai@codeaurora.org \
    --cc=tiwai@suse.de \
    /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