linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Ardelean <alexandru.ardelean@analog.com>
To: <linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>
Cc: <lars@metafoo.de>, <Michael.Hennerich@analog.com>,
	<jic23@kernel.org>, <nuno.sa@analog.com>,
	<dragos.bogdan@analog.com>,
	Alexandru Ardelean <alexandru.ardelean@analog.com>
Subject: [PATCH v4 4/6] iio: buffer-dma: reduce the type of block.size to u32
Date: Wed, 17 Feb 2021 09:36:36 +0200	[thread overview]
Message-ID: <20210217073638.21681-5-alexandru.ardelean@analog.com> (raw)
In-Reply-To: <20210217073638.21681-1-alexandru.ardelean@analog.com>

The type of the 'size' parameter in the block struct is size_t which is
64 bit wide on 64 bit archs.
When the mmap interface gets introduced, we will use a 32 bit field in the
block descriptor for the block size, which will cause some compiler-checks
to fail.

32 bits (4 GB) block sizes should be enough. The idea is to allocate more
blocks if the size of a block grows to 4 GB.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/buffer/industrialio-buffer-dmaengine.c | 6 +++---
 include/linux/iio/buffer-dma.h                     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
index d76179878ff9..19fbe5d9ef5b 100644
--- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
+++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
@@ -35,8 +35,8 @@ struct dmaengine_buffer {
 	struct dma_chan *chan;
 	struct list_head active;
 
-	size_t align;
-	size_t max_size;
+	u32 align;
+	u32 max_size;
 };
 
 static struct dmaengine_buffer *iio_buffer_to_dmaengine_buffer(
@@ -136,7 +136,7 @@ static ssize_t iio_dmaengine_buffer_get_length_align(struct device *dev,
 	struct dmaengine_buffer *dmaengine_buffer =
 		iio_buffer_to_dmaengine_buffer(buffer);
 
-	return sprintf(buf, "%zu\n", dmaengine_buffer->align);
+	return sprintf(buf, "%u\n", dmaengine_buffer->align);
 }
 
 static IIO_DEVICE_ATTR(length_align_bytes, 0444,
diff --git a/include/linux/iio/buffer-dma.h b/include/linux/iio/buffer-dma.h
index 6564bdcdac66..9de27d23e791 100644
--- a/include/linux/iio/buffer-dma.h
+++ b/include/linux/iio/buffer-dma.h
@@ -55,7 +55,7 @@ struct iio_dma_buffer_block {
 	 */
 	void *vaddr;
 	dma_addr_t phys_addr;
-	size_t size;
+	u32 size;
 	struct iio_dma_buffer_queue *queue;
 
 	/* Must not be accessed outside the core. */
-- 
2.17.1


  parent reply	other threads:[~2021-02-17  7:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17  7:36 [PATCH v4 0/6] iio: core: Add mmap interface infrastructure Alexandru Ardelean
2021-02-17  7:36 ` [PATCH v4 1/6] " Alexandru Ardelean
2021-02-17  7:36 ` [PATCH v4 2/6] Documentation: iio: add doc for high-speed buffer API Alexandru Ardelean
2021-02-17  7:36 ` [PATCH v4 3/6] iio: buffer-dma: split iio_dma_buffer_fileio_free() function Alexandru Ardelean
2021-02-17  7:36 ` Alexandru Ardelean [this message]
2021-02-17  7:36 ` [PATCH v4 5/6] iio: buffer-dma: Add mmap support Alexandru Ardelean
2021-02-17  7:36 ` [PATCH v4 6/6] tools: iio: add example for high-speed buffer support Alexandru Ardelean
2021-02-18 13:10 ` [PATCH v4 0/6] iio: core: Add mmap interface infrastructure Jonathan Cameron
2021-02-27 17:52   ` Jonathan Cameron

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=20210217073638.21681-5-alexandru.ardelean@analog.com \
    --to=alexandru.ardelean@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=dragos.bogdan@analog.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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;
as well as URLs for NNTP newsgroup(s).