Re: [PATCH v2] spi: qup: Add DMA capabilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux