All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Barry Song <21cnbao@gmail.com>
Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com,
	workgroup.linux@csr.com, Rongjun Ying <Rongjun.Ying@csr.com>,
	Barry Song <Baohua.Song@csr.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 2/6] ASoC: sirf: add I2S CPU DAI driver
Date: Mon, 28 Oct 2013 09:21:08 -0700	[thread overview]
Message-ID: <20131028162108.GD13643@sirena.org.uk> (raw)
In-Reply-To: <1382913424-28626-1-git-send-email-Baohua.Song@csr.com>


[-- Attachment #1.1: Type: text/plain, Size: 2253 bytes --]

On Mon, Oct 28, 2013 at 06:37:04AM +0800, Barry Song wrote:

> +static int sirf_i2s_startup(struct snd_pcm_substream *substream,
> +		struct snd_soc_dai *dai)
> +{
> +	pm_runtime_get_sync(dai->dev);
> +	return 0;
> +}

This appears to be duplicating functionality in the core?  It already
holds a runtime PM reference on the device while it's active.

> +	case SND_SOC_DAIFMT_CBM_CFM:
> +		i2s_ctrl |= I2S_SLAVE_MODE;
> +		i2s_tx_rx_ctrl &= ~I2S_MCLK_EN;
> +		break;
> +	case SND_SOC_DAIFMT_CBS_CFS:
> +		i2s_ctrl &= ~I2S_SLAVE_MODE;
> +		i2s_tx_rx_ctrl |= I2S_MCLK_EN;
> +		break;

Why is I2S_MCLK_EN being controlled here?  This looks like a clock
outside the actual DAI and it's possible someone might wnat to use the
AP to generate MCLK but still have the CODEC drive the frame and bit
clocks on the bus.

> +	default:
> +		dev_err(dai->dev, " Only normal bit clock, normal frame clock supported\n");
> +		return -EINVAL;

Extra space at the start of the log message.

> +static int sirf_i2s_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
> +{
> +	struct sirf_i2s *si2s = snd_soc_dai_get_drvdata(dai);
> +	u32 val;
> +	u32 bclk_div_coefficient;
> +
> +	if (div < 2 || div % 2) {
> +		dev_err(dai->dev, "BITCLK divider must greater than 1,"
> +			"And must is a multiple of 2\n");
> +		return -EINVAL;
> +	}

Why must the user manually configure the bitclock divider?  I would
expect the driver to be able to configure this automatically.

> +static struct snd_soc_dai_driver sirf_i2s_dai = {
> +	.probe = sirf_i2s_dai_probe,
> +	.name		= "sirf-i2s",
> +	.id			= 0,

The indentation here is pretty inconsistent.

> +static int sirf_i2s_runtime_resume(struct device *dev)
> +{
> +	struct sirf_i2s *si2s = dev_get_drvdata(dev);
> +	clk_prepare_enable(si2s->clk);
> +	device_reset(dev);
> +	return 0;

You should be checking the return value here.

> +	ret = snd_soc_register_component(&pdev->dev, &sirf_i2s_component,
> +			&sirf_i2s_dai, 1);

devm_snd_soc_register_component().

> +	if (ret) {
> +		dev_err(&pdev->dev, "Register Audio SoC dai failed.\n");
> +		goto err;
> +	}
> +
> +	pm_runtime_enable(&pdev->dev);

You need to enable runtime PM prior to registering otherwise something
may try to use the driver prior to it being enabled.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



WARNING: multiple messages have this Message-ID (diff)
From: broonie@kernel.org (Mark Brown)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/6] ASoC: sirf: add I2S CPU DAI driver
Date: Mon, 28 Oct 2013 09:21:08 -0700	[thread overview]
Message-ID: <20131028162108.GD13643@sirena.org.uk> (raw)
In-Reply-To: <1382913424-28626-1-git-send-email-Baohua.Song@csr.com>

On Mon, Oct 28, 2013 at 06:37:04AM +0800, Barry Song wrote:

> +static int sirf_i2s_startup(struct snd_pcm_substream *substream,
> +		struct snd_soc_dai *dai)
> +{
> +	pm_runtime_get_sync(dai->dev);
> +	return 0;
> +}

This appears to be duplicating functionality in the core?  It already
holds a runtime PM reference on the device while it's active.

> +	case SND_SOC_DAIFMT_CBM_CFM:
> +		i2s_ctrl |= I2S_SLAVE_MODE;
> +		i2s_tx_rx_ctrl &= ~I2S_MCLK_EN;
> +		break;
> +	case SND_SOC_DAIFMT_CBS_CFS:
> +		i2s_ctrl &= ~I2S_SLAVE_MODE;
> +		i2s_tx_rx_ctrl |= I2S_MCLK_EN;
> +		break;

Why is I2S_MCLK_EN being controlled here?  This looks like a clock
outside the actual DAI and it's possible someone might wnat to use the
AP to generate MCLK but still have the CODEC drive the frame and bit
clocks on the bus.

> +	default:
> +		dev_err(dai->dev, " Only normal bit clock, normal frame clock supported\n");
> +		return -EINVAL;

Extra space at the start of the log message.

> +static int sirf_i2s_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
> +{
> +	struct sirf_i2s *si2s = snd_soc_dai_get_drvdata(dai);
> +	u32 val;
> +	u32 bclk_div_coefficient;
> +
> +	if (div < 2 || div % 2) {
> +		dev_err(dai->dev, "BITCLK divider must greater than 1,"
> +			"And must is a multiple of 2\n");
> +		return -EINVAL;
> +	}

Why must the user manually configure the bitclock divider?  I would
expect the driver to be able to configure this automatically.

> +static struct snd_soc_dai_driver sirf_i2s_dai = {
> +	.probe = sirf_i2s_dai_probe,
> +	.name		= "sirf-i2s",
> +	.id			= 0,

The indentation here is pretty inconsistent.

> +static int sirf_i2s_runtime_resume(struct device *dev)
> +{
> +	struct sirf_i2s *si2s = dev_get_drvdata(dev);
> +	clk_prepare_enable(si2s->clk);
> +	device_reset(dev);
> +	return 0;

You should be checking the return value here.

> +	ret = snd_soc_register_component(&pdev->dev, &sirf_i2s_component,
> +			&sirf_i2s_dai, 1);

devm_snd_soc_register_component().

> +	if (ret) {
> +		dev_err(&pdev->dev, "Register Audio SoC dai failed.\n");
> +		goto err;
> +	}
> +
> +	pm_runtime_enable(&pdev->dev);

You need to enable runtime PM prior to registering otherwise something
may try to use the driver prior to it being enabled.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131028/66c112eb/attachment.sig>

  parent reply	other threads:[~2013-10-28 16:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-27 22:37 [PATCH v2 2/6] ASoC: sirf: add I2S CPU DAI driver Barry Song
2013-10-27 22:37 ` Barry Song
2013-10-28  3:41 ` Timur Tabi
2013-10-28  3:41   ` [alsa-devel] " Timur Tabi
2013-10-28  6:48 ` Lars-Peter Clausen
2013-10-28  6:48   ` [alsa-devel] " Lars-Peter Clausen
2013-10-28  8:32   ` Barry Song
2013-10-28  8:32     ` [alsa-devel] " Barry Song
2013-10-28  8:48     ` Lars-Peter Clausen
2013-10-28  8:48       ` [alsa-devel] " Lars-Peter Clausen
2013-10-28  8:58       ` Barry Song
2013-10-28  8:58         ` [alsa-devel] " Barry Song
2013-10-28 16:21 ` Mark Brown [this message]
2013-10-28 16:21   ` 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=20131028162108.GD13643@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=21cnbao@gmail.com \
    --cc=Baohua.Song@csr.com \
    --cc=Rongjun.Ying@csr.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=workgroup.linux@csr.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.