[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160809113329.GA9347@sirena.org.uk>
Date: Tue, 9 Aug 2016 12:33:29 +0100
From: Mark Brown <broonie@...nel.org>
To: Vignesh R <vigneshr@...com>
Cc: linux-spi@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-omap@...r.kernel.org
Subject: Re: [PATCH v5] spi: spi-ti-qspi: Add DMA support for QSPI mmap read
On Tue, Aug 09, 2016 at 04:33:11PM +0530, Vignesh R wrote:
> +static int ti_qspi_map_buf(struct ti_qspi *qspi, void *buf,
> + unsigned int len, struct sg_table *sgt)
> +{
> + unsigned int max_seg_size =
> + dma_get_max_seg_size(qspi->rx_chan->device->dev);
> + unsigned int desc_len = min_t(int, max_seg_size, PAGE_SIZE);
> + int sgs = DIV_ROUND_UP(len + offset_in_page(buf), desc_len);
> + struct page *vm_page;
> + size_t min;
> + int i, ret;
> +
> + ret = sg_alloc_table(sgt, sgs, GFP_KERNEL);
> + if (ret)
> + return ret;
> +
> + for (i = 0; i < sgs; i++) {
> + min = min_t(size_t, len, desc_len -
> + offset_in_page(buf));
> + vm_page = kmap_to_page(buf);
> + if (!vm_page) {
> + sg_free_table(sgt);
> + return -ENOMEM;
> + }
> + sg_set_page(&sgt->sgl[i], vm_page, min,
> + offset_in_page(buf));
> + buf += min;
> + len -= min;
This looks a lot like the core code for mapping the buffers - why is
this open coded rather than reused?
Download attachment "signature.asc" of type "application/pgp-signature" (474 bytes)
Powered by blists - more mailing lists