public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leonardo Bras <leobras.c@gmail.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Leonardo Bras <leobras.c@gmail.com>,
	Joel Stanley <joel@jms.id.au>,
	Christophe Leroy <christophe.leroy@c-s.fr>,
	Nayna Jain <nayna@linux.ibm.com>,
	Eric Richter <erichte@linux.ibm.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	Hari Bathini <hbathini@linux.ibm.com>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Brian King <brking@linux.vnet.ibm.com>,
	Murilo Fossa Vicentini <muvic@linux.ibm.com>,
	David Dai <zdai@linux.vnet.ibm.com>,
	Matthew Wilcox <willy@infradead.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/2] dma-direction: Add DMA_DIR_COMPAT() macro to test direction compability
Date: Mon, 31 Aug 2020 15:48:58 -0300	[thread overview]
Message-ID: <20200831184859.110660-2-leobras.c@gmail.com> (raw)
In-Reply-To: <20200831184859.110660-1-leobras.c@gmail.com>

Given a existing mapping with 'current' direction, and a 'wanted'
direction for using that mapping, check if 'wanted' is satisfied by
'current'.

current			accepts
DMA_BIDIRECTIONAL	DMA_BIDIRECTIONAL, DMA_TO_DEVICE,
			DMA_FROM_DEVICE, DMA_NONE
DMA_TO_DEVICE		DMA_TO_DEVICE, DMA_NONE
DMA_FROM_DEVICE		DMA_FROM_DEVICE, DMA_NONE
DMA_NONE		DMA_NONE

This macro is useful for checking if a DMA mapping can be reused.

Signed-off-by: Leonardo Bras <leobras.c@gmail.com>
---
 include/linux/dma-direction.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/dma-direction.h b/include/linux/dma-direction.h
index 9c96e30e6a0b..caf3943a21f4 100644
--- a/include/linux/dma-direction.h
+++ b/include/linux/dma-direction.h
@@ -9,4 +9,7 @@ enum dma_data_direction {
 	DMA_NONE = 3,
 };
 
+/* Checks if wanted direction is satisfied by current mapping direction*/
+#define DMA_DIR_COMPAT(current, wanted)	(((current) & ~(wanted)) == 0)
+
 #endif
-- 
2.25.4


  reply	other threads:[~2020-08-31 18:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 18:48 [RFC PATCH 0/2] DMA pagecache Leonardo Bras
2020-08-31 18:48 ` Leonardo Bras [this message]
2020-08-31 18:48 ` [RFC PATCH 2/2] powerpc/kernel/iommu: Introduce IOMMU " Leonardo Bras

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=20200831184859.110660-2-leobras.c@gmail.com \
    --to=leobras.c@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=brking@linux.vnet.ibm.com \
    --cc=christophe.leroy@c-s.fr \
    --cc=erichte@linux.ibm.com \
    --cc=hbathini@linux.ibm.com \
    --cc=joel@jms.id.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=masahiroy@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=muvic@linux.ibm.com \
    --cc=nayna@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=paulus@samba.org \
    --cc=willy@infradead.org \
    --cc=zdai@linux.vnet.ibm.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