[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1424797916.2340.19.camel@mm-sol.com>
Date: Tue, 24 Feb 2015 19:11:56 +0200
From: "Ivan T. Ivanov" <iivanov@...sol.com>
To: Stanimir Varbanov <stanimir.varbanov@...aro.org>
Cc: Mark Brown <broonie@...nel.org>, linux-kernel@...r.kernel.org,
linux-arm-msm@...r.kernel.org, devicetree@...r.kernel.org,
linux-spi@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Kumar Gala <galak@...eaurora.org>,
Andy Gross <agross@...eaurora.org>,
Sagar Dharia <sdharia@...eaurora.org>,
Daniel Sneddon <dsneddon@...eaurora.org>
Subject: Re: [PATCH v2] spi: qup: Add DMA capabilities
Hi Stan,
Sorry I didn't saw this first look.
On Tue, 2015-02-24 at 15:00 +0200, Stanimir Varbanov wrote:
<snip>
>
> +static bool spi_qup_can_dma(struct spi_master *master, struct spi_device *spi,
> + struct spi_transfer *xfer)
> +{
> + struct spi_qup *qup = spi_master_get_devdata(master);
> + size_t dma_align = dma_get_cache_alignment();
> + int n_words, w_size;
> +
> + qup->dma_available = 0;
> +
> + if (xfer->rx_buf && xfer->len % qup->in_blk_sz)
> + return false;
> +
> + if (xfer->tx_buf && xfer->len % qup->out_blk_sz)
> + return false;
> +
Actually we can end up here with tx_buf or rx_buf to be NULL.
Which voids my previous comments about these pointers.
It will be simpler if you just check transfer length.
And better return false if both are NULL.
> + if (IS_ERR_OR_NULL(master->dma_rx) || IS_ERR_OR_NULL(master->dma_tx))
> + return false;
> +
> + if (!IS_ALIGNED((size_t)xfer->tx_buf, dma_align) ||
> + !IS_ALIGNED((size_t)xfer->rx_buf, dma_align))
> + return false;
Testing NULL for alignment is fine, right?
> + w_size = spi_qup_get_word_sz(xfer);
> + n_words = xfer->len / w_size;
> +
> + /* will use fifo mode */
> + if (n_words <= (qup->in_fifo_sz / sizeof(u32)))
> + return false;
> +
> + qup->dma_available = 1;
> +
> + return true;
> +}
> +
Regards,
Ivan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists