From: Mark Brown <broonie@kernel.org>
To: Kenneth Westfield <kwestfie@codeaurora.org>
Cc: ALSA Mailing List <alsa-devel@alsa-project.org>,
Device Tree Mailing List <devicetree@vger.kernel.org>,
MSM Mailing List <linux-arm-msm@vger.kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>, Takashi Iwai <tiwai@suse.de>,
Rob Herring <rob.herring@calxeda.com>,
Greg KH <gregkh@linuxfoundation.org>,
David Brown <davidb@codeaurora.org>,
Bryan Huntsman <bryanh@codeaurora.org>,
Banajit Goswami <bgoswami@codeaurora.org>,
Patrick Lai <plai@codeaurora.org>
Subject: Re: [PATCH 4/9] ASoC: ipq806x: Add LPASS CPU DAI driver
Date: Tue, 25 Nov 2014 21:53:42 +0000 [thread overview]
Message-ID: <20141125215342.GU7712@sirena.org.uk> (raw)
In-Reply-To: <1416423169-21865-5-git-send-email-kwestfie@codeaurora.org>
[-- Attachment #1: Type: text/plain, Size: 3201 bytes --]
On Wed, Nov 19, 2014 at 10:52:44AM -0800, Kenneth Westfield wrote:
> + if (channels == 8) {
> + if (bit_width == 24 &&
> + ((samp_freq != 176400) &&
> + (samp_freq != 192000)))
> + return 2;
> + return 1;
Coding style - there's more brackets than are needed coupled with some
strange indentation (eg, the second samp_freq line being indented to the
outside bracket when it's still within that bracket). Use of switch
statements would probably help, at least on channels.
> +static int lpass_cpu_mi2s_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params,
> + struct snd_soc_dai *dai)
> +{
> + uint32_t ret = 0;
> + uint32_t bit_act;
> + uint16_t bit_div;
> + uint32_t bit_width = params_format(params);
> + uint32_t channels = params_channels(params);
> + uint32_t rate = params_rate(params);
> + struct snd_pcm_runtime *runtime = substream->runtime;
> + struct lpass_runtime_data_t *prtd = runtime->private_data;
> + struct mi2s_hw_params curr_params;
> +
> + bit_act = snd_pcm_format_width(bit_width);
> + if (bit_act == LPASS_INVALID) {
snd_pcm_format_width() returns an error code on error, LPASS_INVALID is
not an error code. Check the return value for error codes...
> + dev_err(dai->dev, "%s: Invalid bit width given\n", __func__);
> + return -EINVAL;
...and just return them.
> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> + /* disable SPKR to make sure it will start in sane state */
> + lpaif_cfg_i2s_playback(0, 0, LPAIF_MI2S);
Shouldn't we be doing this on probe and/or resume if it's required?
> +
> + /*
> + * Set channel info, it will take effect only if SPKR is
> + * enabled
> + */
> + ret = lpaif_cfg_mi2s_playback_hwparams_channels(channels,
> + LPAIF_MI2S, bit_act);
> + } else {
> + dev_err(dai->dev, "%s: Invalid stream direction\n", __func__);
> + return -EINVAL;
> + }
If the device only supports playback no need to have any conditional
code here, the core will prevent capture being started.
> + ret = clk_set_rate(lpaif_mi2s_osr_clk,
> + (rate * bit_act * channels * bit_div));
> + if (ret) {
> + dev_err(dai->dev, "%s: error in setting mi2s osr clk\n",
> + __func__);
> + return ret;
> + }
> + ret = clk_prepare_enable(lpaif_mi2s_osr_clk);
> + if (ret) {
> + dev_err(dai->dev, "%s: error in enabling mi2s osr clk\n",
> + __func__);
> + return ret;
> + }
> + prtd->lpaif_clk.is_osr_clk_enabled = 1;
Coding style, more blank lines between blocks here. Also not clear why
we're tracking if the clock is enabled when we do it unconditonally.
> +static int lpass_cpu_mi2s_prepare(struct snd_pcm_substream *substream,
> + struct snd_soc_dai *dai)
> +{
> + return 0;
> +}
Remove empty functions.
> +static int lpass_cpu_mi2s_startup(struct snd_pcm_substream *substream,
> + struct snd_soc_dai *dai)
> +{
> +
> + lpaif_mi2s_osr_clk = clk_get(dai->dev, "mi2s_osr_clk");
> + if (IS_ERR(lpaif_mi2s_osr_clk)) {
> + dev_err(dai->dev, "%s: Error in getting mi2s_osr_clk\n",
> + __func__);
> + return PTR_ERR(lpaif_mi2s_osr_clk);
> + }
No, request resources in probe(). That way deferred probe works and we
don't get mysterious errors at runtime if things go wrong.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2014-11-25 21:55 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-19 18:52 [PATCH 0/9] ASoC: QCOM: Add support for ipq806x SOC Kenneth Westfield
2014-11-19 18:52 ` [PATCH 1/9] MAINTAINERS: Add QCOM audio ASoC maintainer Kenneth Westfield
2014-11-19 18:52 ` [PATCH 2/9] ASoC: qcom: Add device tree binding docs Kenneth Westfield
2014-11-25 21:26 ` Mark Brown
2014-11-19 18:52 ` [PATCH 3/9] ASoC: ipq806x: add native LPAIF driver Kenneth Westfield
2014-11-20 12:32 ` [alsa-devel] " Lars-Peter Clausen
2014-11-21 20:19 ` Kenneth Westfield
2014-11-25 21:44 ` Mark Brown
2014-11-19 18:52 ` [PATCH 4/9] ASoC: ipq806x: Add LPASS CPU DAI driver Kenneth Westfield
2014-11-19 21:17 ` Pierre-Louis Bossart
2014-11-21 20:23 ` [alsa-devel] " Kenneth Westfield
2014-11-20 0:20 ` Courtney Cavin
2014-11-20 12:36 ` [alsa-devel] " Lars-Peter Clausen
2014-11-25 21:53 ` Mark Brown [this message]
2014-11-19 18:52 ` [PATCH 5/9] ASoC: ipq806x: Add I2S PCM platform driver Kenneth Westfield
2014-11-19 21:10 ` [alsa-devel] " Pierre-Louis Bossart
2014-11-25 22:01 ` Mark Brown
2014-11-19 18:52 ` [PATCH 6/9] ASoC: ipq806x: Add machine driver for IPQ806X SOC Kenneth Westfield
2014-11-25 22:03 ` Mark Brown
2014-11-19 18:52 ` [PATCH 7/9] ASoC: qcom: Add ability to build QCOM drivers Kenneth Westfield
2014-11-25 22:07 ` Mark Brown
2014-11-27 1:26 ` Bryan Huntsman
2014-11-19 18:52 ` [PATCH 8/9] ASoC: Allow for building " Kenneth Westfield
2014-11-19 18:52 ` [PATCH 9/9] ARM: dts: Model IPQ LPASS audio hardware Kenneth Westfield
2014-11-19 22:54 ` Courtney Cavin
2014-11-21 20:17 ` [alsa-devel] " Kenneth Westfield
2014-11-25 22:08 ` Mark Brown
2014-11-19 20:16 ` [PATCH 0/9] ASoC: QCOM: Add support for ipq806x SOC Kumar Gala
2014-11-20 9:51 ` Mark Brown
2014-11-21 20:24 ` [alsa-devel] " Kenneth Westfield
2014-11-24 18:52 ` Mark Brown
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=20141125215342.GU7712@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=rob.herring@calxeda.com \
--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