devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolin Chen <b42378@freescale.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: broonie@kernel.org, lars@metafoo.de, p.zabel@pengutronix.de,
	linuxppc-dev@lists.ozlabs.org, alsa-devel@alsa-project.org,
	devicetree@vger.kernel.org, timur@tabi.org,
	rob.herring@calxeda.com, shawn.guo@linaro.org,
	festevam@gmail.com, tomasz.figa@gmail.com, swarren@wwwdotorg.org,
	mark.rutland@arm.com, R65777@freescale.com
Subject: Re: [PATCH v8 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Date: Tue, 20 Aug 2013 10:21:35 +0800	[thread overview]
Message-ID: <20130820022134.GA13169@MrMyself> (raw)
In-Reply-To: <20130819123449.GE31036@pengutronix.de>

Thank you Sascha, I'll revise them all in v9

On Mon, Aug 19, 2013 at 02:34:49PM +0200, Sascha Hauer wrote:
> Hi Nicolas,
> 
> Some misc other comments inline.
> 
> On Mon, Aug 19, 2013 at 08:08:48PM +0800, Nicolin Chen wrote:
> > This patch implements a device-tree-only CPU DAI driver for Freescale
> > +
> > +struct fsl_spdif_priv {
> > +	struct spdif_mixer_control fsl_spdif_control;
> > +	struct snd_soc_dai_driver cpu_dai_drv;
> > +	struct platform_device *pdev;
> > +	struct regmap *regmap;
> > +	atomic_t dpll_locked;
> 
> You don't need an atomic_t to track a bool variable. Use a plain bool or
> int instead.
> 
> > +	u8 txclk_div[SPDIF_TXRATE_MAX];
> > +	u8 txclk_src[SPDIF_TXRATE_MAX];
> > +	u8 rxclk_src;
> > +	struct clk *txclk[SPDIF_TXRATE_MAX];
> > +	struct clk *rxclk;
> > +	struct snd_dmaengine_dai_dma_data dma_params_tx;
> > +	struct snd_dmaengine_dai_dma_data dma_params_rx;
> > +
> > +	/* The name space will be allocated dynamically */
> > +	char name[0];
> > +};
> > +
> > +
> > +#ifdef DEBUG
> > +static void dumpregs(struct fsl_spdif_priv *spdif_priv)
> > +{
> > +	struct regmap *regmap = spdif_priv->regmap;
> > +	struct platform_device *pdev = spdif_priv->pdev;
> > +	u32 val, i;
> > +	int ret;
> > +
> > +	/* Valid address set of SPDIF is {[0x0-0x38], 0x44, 0x50} */
> > +	for (i = 0 ; i <= REG_SPDIF_STC; i += 4) {
> > +		ret = regmap_read(regmap, REG_SPDIF_SCR + i, &val);
> > +		if (!ret)
> > +			dev_dbg(&pdev->dev, "REG 0x%02x = 0x%06x\n", i, val);
> > +	}
> > +}
> > +#else
> > +static void dumpregs(struct fsl_spdif_priv *spdif_priv) {}
> > +#endif
> 
> Is this needed? regmap provides a register dump in debugfs.
> 
> > +
> > +static int spdif_clk_set_rate(struct clk *clk, unsigned long rate)
> > +{
> > +	unsigned long rate_actual;
> > +
> > +	rate_actual = clk_round_rate(clk, rate);
> > +	return clk_set_rate(clk, rate_actual);
> > +}
> 
> clk_round_rate returns the rate which clk_set_rate would set if called
> with the same rate. The clk_round_rate() is unnecessary.
> 
> > +
> > +	dev_dbg(&pdev->dev, "expected clock rate = %d\n",
> > +			(int)(64 * sample_rate * div));
> > +	dev_dbg(&pdev->dev, "acutal clock rate = %d\n",
> > +			(int)clk_get_rate(spdif_priv->txclk[rate]));
> 
> s/acutal/actual/
> 
> Also please use %ld instead of casting the unsigned long to int.
> 
> > +
> > +	dev_dbg(&pdev->dev, "FreqMeas: %d\n", (int)freqmeas);
> > +	dev_dbg(&pdev->dev, "BusclkFreq: %d\n", (int)busclk_freq);
> > +	dev_dbg(&pdev->dev, "RxRate: %d\n", (int)tmpval64);
> 
> Get rid of the casts
> 
> > +
> > +	spdif_priv = devm_kzalloc(&pdev->dev,
> > +			sizeof(struct fsl_spdif_priv) + strlen(np->name) + 1, GFP_KERNEL);
> > +	if (!spdif_priv) {
> > +		dev_err(&pdev->dev, "could not allocate DAI object\n");
> 
> Please drop this message. You'll never see it.
> 
> > +
> > +	for (i = 0; i < SPDIF_TXRATE_MAX; i++) {
> > +		ret = fsl_spdif_probe_txclk(spdif_priv, i);
> > +		if (ret)
> > +			return ret;
> > +	}
> > +
> > +	/* Prepare rx/tx clock */
> > +	clk_prepare(spdif_priv->rxclk);
> > +	for (i = 0; i < SPDIF_TXRATE_MAX; i++)
> > +		clk_prepare(spdif_priv->txclk[i]);
> 
> Why do you prepare all clocks instead of the one you actually use? Also,
> no need to do this here. You can use clk_prepare_enable instead where
> you have clk_enable now.
> 
> > +
> > +/* SPDIF rx clock source */
> > +enum spdif_rxclk_src {
> > +	SRPC_CLKSRC_0 = 0,
> > +	SRPC_CLKSRC_1,
> > +	SRPC_CLKSRC_2,
> > +	SRPC_CLKSRC_3,
> > +	SRPC_CLKSRC_4,
> > +	SRPC_CLKSRC_5,
> > +	SRPC_CLKSRC_6,
> > +	SRPC_CLKSRC_7,
> > +	SRPC_CLKSRC_8,
> > +	SRPC_CLKSRC_9,
> > +	SRPC_CLKSRC_10,
> > +	SRPC_CLKSRC_11,
> > +	SRPC_CLKSRC_12,
> > +	SRPC_CLKSRC_13,
> > +	SRPC_CLKSRC_14,
> > +	SRPC_CLKSRC_15,
> > +};
> 
> These are unused and look unnecessary.
> 
> > +
> > +/* SPDIF tx clksrc */
> > +enum spdif_txclk_src {
> > +	STC_TXCLK_SRC_0 = 0,
> > +	STC_TXCLK_SRC_1,
> > +	STC_TXCLK_SRC_2,
> > +	STC_TXCLK_SRC_3,
> > +	STC_TXCLK_SRC_4,
> > +	STC_TXCLK_SRC_5,
> > +	STC_TXCLK_SRC_6,
> > +	STC_TXCLK_SRC_7,
> > +};
> 
> Also unused.
> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 



  reply	other threads:[~2013-08-20  2:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19 12:08 [PATCH v8 0/2] Add freescale S/PDIF CPU DAI and machine drivers Nicolin Chen
2013-08-19 12:08 ` [PATCH v8 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver Nicolin Chen
2013-08-19 12:34   ` Sascha Hauer
2013-08-20  2:21     ` Nicolin Chen [this message]
2013-08-19 21:35   ` Stephen Warren
2013-08-20  2:28     ` Nicolin Chen
2013-08-20 15:49       ` Stephen Warren
2013-08-19 12:08 ` [PATCH v8 2/2] ASoC: fsl: Add S/PDIF machine driver Nicolin Chen
2013-08-19 21:39   ` Stephen Warren
2013-08-20  0:18     ` Mark Brown
2013-08-20 15:48       ` Stephen Warren
2013-08-20 19:07         ` Mark Brown
2013-08-20 19:53           ` Stephen Warren
2013-08-20 22:28             ` Mark Brown
2013-08-21  2:18               ` [alsa-devel] " Nicolin Chen
2013-08-21 16:08                 ` Stephen Warren

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=20130820022134.GA13169@MrMyself \
    --to=b42378@freescale.com \
    --cc=R65777@freescale.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mark.rutland@arm.com \
    --cc=p.zabel@pengutronix.de \
    --cc=rob.herring@calxeda.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawn.guo@linaro.org \
    --cc=swarren@wwwdotorg.org \
    --cc=timur@tabi.org \
    --cc=tomasz.figa@gmail.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;
as well as URLs for NNTP newsgroup(s).