mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Purna Chandra Mandal <purna.mandal@microchip.com>
Cc: linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org
Subject: Re: [PATCH v2 2/2] spi: pic32-sqi: add SPI driver for PIC32 SQI controller.
Date: Thu, 14 Apr 2016 06:55:46 +0100	[thread overview]
Message-ID: <20160414055546.GA18024@sirena.org.uk> (raw)
In-Reply-To: <1460553778-1662-2-git-send-email-purna.mandal@microchip.com>

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

On Wed, Apr 13, 2016 at 06:52:58PM +0530, Purna Chandra Mandal wrote:

> +	enable = readl(sqi->regs + PESQI_INT_ENABLE_REG);
> +	status = readl(sqi->regs + PESQI_INT_STAT_REG);
> +	if (!status)
> +		return IRQ_NONE;
> +

For robustness the check should be if there was anything handled, not if
there was anything set.

> +static dma_addr_t pic32_sqi_map_transfer(struct pic32_sqi *sqi,
> +					 struct spi_transfer *transfer)
> +{
> +	struct device *dev = &sqi->master->dev;

Don't open code DMA mapping of the buffers, use the core support.

> +	reg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	sqi->regs = devm_ioremap_resource(&pdev->dev, reg);
> +	if (!sqi->regs) {
> +		dev_err(&pdev->dev, "mem map failed\n");

devm_ioremap_resource() will log for you.

> +	clk_prepare_enable(sqi->sys_clk);
> +	clk_prepare_enable(sqi->base_clk);

Check the return value please.

> +	/* install irq handlers */
> +	ret = devm_request_irq(&pdev->dev, sqi->irq, pic32_sqi_isr,
> +			       0, dev_name(&pdev->dev), sqi);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "request-irq %d, failed ?\n", sqi->irq);
> +		goto err_free_ring;
> +	}

This will free before the clocks are disabled.  Are you sure that's
safe?  It's generally not good to mix devm_ and non-devm operations
especially things like these that aren't simple frees of data.  It is
safer to use a normal request_irq().

> +static int pic32_sqi_remove(struct platform_device *pdev)
> +{
> +	struct pic32_sqi *sqi = platform_get_drvdata(pdev);
> +
> +	clk_disable_unprepare(sqi->base_clk);
> +	clk_disable_unprepare(sqi->sys_clk);
> +
> +	/* release memory */
> +	ring_desc_ring_free(sqi);

This will free the descriptor ring before the interrupt...

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

  reply	other threads:[~2016-04-14  5:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13 13:22 [PATCH v2 1/2] spi: pic32-sqi: add binding document for PIC32 Quad-SPI driver Purna Chandra Mandal
2016-04-13 13:22 ` [PATCH v2 2/2] spi: pic32-sqi: add SPI driver for PIC32 SQI controller Purna Chandra Mandal
2016-04-14  5:55   ` Mark Brown [this message]
2016-04-15  6:29     ` Purna Chandra Mandal
2016-04-15  9:35       ` 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=20160414055546.GA18024@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=purna.mandal@microchip.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

Powered by JetHome