All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
To: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] spi: tegra: add spi driver for SLINK controller
Date: Mon, 22 Oct 2012 13:28:26 +0100	[thread overview]
Message-ID: <20121022122825.GD4477@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1350557233-31234-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

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

On Thu, Oct 18, 2012 at 04:17:13PM +0530, Laxman Dewangan wrote:

> +		udelay(1);
> +		wmb();
> +	}
> +	tspi->dma_control_reg = val;
> +	val |= SLINK_DMA_EN;
> +	tegra_slink_writel(tspi, val, SLINK_DMA_CTL);
> +	return 0;
> +}
> +static int tegra_slink_init_dma_param(struct tegra_slink_data *tspi,
> +			bool dma_to_memory)
> +{

Blank line between functions.

> +	tegra_slink_clk_disable(tspi);
> +	pm_runtime_put_sync(tspi->dev);
> +	return 0;

Throughout the code you're using pm_runtime_put_sync() - why does this
need to be _sync()?  Can't we just use a regular put()?  If we can't we
should document why.

> +static int tegra_slink_prepare_transfer(struct spi_master *master)
> +{
> +	struct tegra_slink_data *tspi = spi_master_get_devdata(master);
> +
> +	pm_runtime_get_sync(tspi->dev);
> +	return 0;

Should really check the error code of the pm_runtime call here.

> +static struct tegra_spi_platform_data *tegra_slink_parese_dt(
> +		struct platform_device *pdev)
> +{

There doens't seem to be any binding documentation; binding
documentation is mandatory.

> +	prop = of_get_property(pdev->dev.of_node, "spi_max_frequency", NULL);
> +	if (prop)
> +		pdata->spi_max_frequency = be32_to_cpup(prop);
> +	else
> +		pdata->spi_max_frequency = 25000000; /* 25MHz */

Why is the default not being picked in the general non-OF case?

> +const struct tegra_slink_chip_data tegra30_spi_cdata = {
> +	.cs_hold_time = true,
> +};
> +
> +#ifdef CONFIG_OF
> +const struct tegra_slink_chip_data tegra20_spi_cdata = {
> +	.cs_hold_time = false,
> +};
> +
> +static struct of_device_id tegra_slink_of_match[] __devinitconst = {
> +	{ .compatible = "nvidia,tegra20-slink", .data = &tegra20_spi_cdata, },
> +	{ .compatible = "nvidia,tegra30-slink", .data = &tegra30_spi_cdata, },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, tegra_slink_of_match);
> +#endif

The ifdefs here look misplaced?

> +	spi_irq = platform_get_irq(pdev, 0);
> +	if (unlikely(spi_irq < 0)) {

Putting optimisation hints like unlikely() here is pointless.

> +	ret = devm_request_threaded_irq(&pdev->dev, tspi->irq,
> +			tegra_slink_isr, tegra_slink_isr_thread, IRQF_ONESHOT,
> +			dev_name(&pdev->dev), tspi);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
> +					tspi->irq);
> +		goto exit_free_master;
> +	}

Any use of devm_ IRQ functions is suspicous... why is this safe against
an interrupt firing after the SPI device has started to deallocate?

> +#ifdef CONFIG_PM_SLEEP
> +static int tegra_slink_suspend(struct device *dev)
> +{
> +	struct spi_master *master = dev_get_drvdata(dev);
> +
> +	spi_master_suspend(master);
> +	return 0;

Should use the return code of spi_master_suspend().

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

WARNING: multiple messages have this Message-ID (diff)
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Laxman Dewangan <ldewangan@nvidia.com>
Cc: grant.likely@secretlab.ca, rob.herring@calxeda.com,
	spi-devel-general@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH] spi: tegra: add spi driver for SLINK controller
Date: Mon, 22 Oct 2012 13:28:26 +0100	[thread overview]
Message-ID: <20121022122825.GD4477@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1350557233-31234-1-git-send-email-ldewangan@nvidia.com>

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

On Thu, Oct 18, 2012 at 04:17:13PM +0530, Laxman Dewangan wrote:

> +		udelay(1);
> +		wmb();
> +	}
> +	tspi->dma_control_reg = val;
> +	val |= SLINK_DMA_EN;
> +	tegra_slink_writel(tspi, val, SLINK_DMA_CTL);
> +	return 0;
> +}
> +static int tegra_slink_init_dma_param(struct tegra_slink_data *tspi,
> +			bool dma_to_memory)
> +{

Blank line between functions.

> +	tegra_slink_clk_disable(tspi);
> +	pm_runtime_put_sync(tspi->dev);
> +	return 0;

Throughout the code you're using pm_runtime_put_sync() - why does this
need to be _sync()?  Can't we just use a regular put()?  If we can't we
should document why.

> +static int tegra_slink_prepare_transfer(struct spi_master *master)
> +{
> +	struct tegra_slink_data *tspi = spi_master_get_devdata(master);
> +
> +	pm_runtime_get_sync(tspi->dev);
> +	return 0;

Should really check the error code of the pm_runtime call here.

> +static struct tegra_spi_platform_data *tegra_slink_parese_dt(
> +		struct platform_device *pdev)
> +{

There doens't seem to be any binding documentation; binding
documentation is mandatory.

> +	prop = of_get_property(pdev->dev.of_node, "spi_max_frequency", NULL);
> +	if (prop)
> +		pdata->spi_max_frequency = be32_to_cpup(prop);
> +	else
> +		pdata->spi_max_frequency = 25000000; /* 25MHz */

Why is the default not being picked in the general non-OF case?

> +const struct tegra_slink_chip_data tegra30_spi_cdata = {
> +	.cs_hold_time = true,
> +};
> +
> +#ifdef CONFIG_OF
> +const struct tegra_slink_chip_data tegra20_spi_cdata = {
> +	.cs_hold_time = false,
> +};
> +
> +static struct of_device_id tegra_slink_of_match[] __devinitconst = {
> +	{ .compatible = "nvidia,tegra20-slink", .data = &tegra20_spi_cdata, },
> +	{ .compatible = "nvidia,tegra30-slink", .data = &tegra30_spi_cdata, },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, tegra_slink_of_match);
> +#endif

The ifdefs here look misplaced?

> +	spi_irq = platform_get_irq(pdev, 0);
> +	if (unlikely(spi_irq < 0)) {

Putting optimisation hints like unlikely() here is pointless.

> +	ret = devm_request_threaded_irq(&pdev->dev, tspi->irq,
> +			tegra_slink_isr, tegra_slink_isr_thread, IRQF_ONESHOT,
> +			dev_name(&pdev->dev), tspi);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
> +					tspi->irq);
> +		goto exit_free_master;
> +	}

Any use of devm_ IRQ functions is suspicous... why is this safe against
an interrupt firing after the SPI device has started to deallocate?

> +#ifdef CONFIG_PM_SLEEP
> +static int tegra_slink_suspend(struct device *dev)
> +{
> +	struct spi_master *master = dev_get_drvdata(dev);
> +
> +	spi_master_suspend(master);
> +	return 0;

Should use the return code of spi_master_suspend().

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

  parent reply	other threads:[~2012-10-22 12:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18 10:47 [PATCH] spi: tegra: add spi driver for SLINK controller Laxman Dewangan
2012-10-18 10:47 ` Laxman Dewangan
     [not found] ` <1350557233-31234-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-10-22 12:28   ` Mark Brown [this message]
2012-10-22 12:28     ` Mark Brown
     [not found]     ` <20121022122825.GD4477-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-10-22 18:04       ` Thierry Reding
2012-10-22 18:04         ` Thierry Reding
2012-10-22 20:02   ` Stephen Warren
2012-10-22 20:02     ` Stephen Warren
     [not found]     ` <5085A667.2000100-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-23  9:17       ` Mark Brown
2012-10-23  9:17         ` Mark Brown
2012-10-26 18:49       ` Laxman Dewangan
2012-10-26 18:49         ` Laxman Dewangan
     [not found]         ` <508ADB1C.6040602-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-10-29 15:17           ` Stephen Warren
2012-10-29 15:17             ` Stephen Warren
     [not found]             ` <508E9E22.6030201-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-29 16:18               ` Laxman Dewangan
2012-10-29 16:18                 ` Laxman Dewangan
2012-10-29 18:55                 ` 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=20121022122825.GD4477@opensource.wolfsonmicro.com \
    --to=broonie-yzvpicuk2aatku/dhu1wvuem+bqzidxxqq4iyu8u01e@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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.