Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: Richard Henderson <r...@twiddle.net>
Cc: Ivan Kokshaysky <i...@jurassic.park.msu.ru>
Cc: Matt Turner <matt...@gmail.com>
---
arch/alpha/include/asm/pci.h | 14 ++------------
1 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index dd8dcab..6d2a8cc 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -120,18 +120,8 @@ extern void pci_unmap_single(struct pci_dev *, dma_addr_t, size_t, int);
extern void pci_unmap_page(struct pci_dev *, dma_addr_t, size_t, int);
/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
- dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
- __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) \
- ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
- (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) \
- ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- (((PTR)->LEN_NAME) = (VAL))
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
/* Map a set of buffers described by scatterlist in streaming mode for
PCI DMA. This is the scatter-gather version of the above
--
1.5.6.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: David Howells <dhow...@redhat.com>
---
arch/frv/include/asm/pci.h | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/arch/frv/include/asm/pci.h b/arch/frv/include/asm/pci.h
index 8c7260a..030a190 100644
--- a/arch/frv/include/asm/pci.h
+++ b/arch/frv/include/asm/pci.h
@@ -44,12 +44,7 @@ extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
#define pci_controller_num(PDEV) (0)
/* pci_unmap_{page,single} is a nop so... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME) (0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME) (0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
+#include <asm-generic/pci-dma-common.h>
#ifdef CONFIG_PCI
static inline void pci_dma_burst_advice(struct pci_dev *pdev,
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: Ralf Baechle <ra...@linux-mips.org>
---
arch/mips/include/asm/pci.h | 23 +++--------------------
1 files changed, 3 insertions(+), 20 deletions(-)
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 5ebf825..76c6e98 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -103,26 +103,9 @@ struct pci_dev;
extern unsigned int PCI_DMA_BUS_IS_PHYS;
#ifdef CONFIG_DMA_NEED_PCI_MAP_STATE
-
-/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
-
-#else /* CONFIG_DMA_NEED_PCI_MAP_STATE */
-
-/* pci_unmap_{page,single} is a nop so... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME) (0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME) (0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
-
-#endif /* CONFIG_DMA_NEED_PCI_MAP_STATE */
+#define HAVE_ARCH_PCI_UNMAP
+#endif
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: Chris Zankel <ch...@zankel.net>
---
arch/xtensa/include/asm/pci.h | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/arch/xtensa/include/asm/pci.h b/arch/xtensa/include/asm/pci.h
index 66410ac..32828f8 100644
--- a/arch/xtensa/include/asm/pci.h
+++ b/arch/xtensa/include/asm/pci.h
@@ -57,12 +57,7 @@ struct pci_dev;
#define PCI_DMA_BUS_IS_PHYS (1)
/* pci_unmap_{page,single} is a no-op, so */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME) (0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
-#define pci_ubnmap_len(PTR, LEN_NAME) (0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
+#include <asm-generic/pci-dma-common.h>
/* Map a range of PCI memory or I/O space for a device into user space */
int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: Kyle McMartin <ky...@mcmartin.ca>
Cc: Helge Deller <del...@gmx.de>
Cc: James Bottomley <James.B...@suse.de>
---
arch/parisc/include/asm/pci.h | 14 ++------------
1 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 64c7aa5..e397277 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -184,18 +184,8 @@ struct pci_bios_ops {
};
/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
- dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
- __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) \
- ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
- (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) \
- ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- (((PTR)->LEN_NAME) = (VAL))
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
/*
** Stuff declared in arch/parisc/kernel/pci.c
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: Paul Mundt <let...@linux-sh.org>
---
arch/sh/include/asm/pci.h | 15 ++-------------
1 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 1042f7f..3106018 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -87,20 +87,9 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
* configuration.
*/
#ifdef CONFIG_DMA_NONCOHERENT
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
-#else
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME) (0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME) (0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
+#define HAVE_ARCH_PCI_UNMAP
#endif
+#include <asm-generic/pci-dma-common.h>
#ifdef CONFIG_PCI
/*
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: Russell King <li...@arm.linux.org.uk>
---
arch/arm/include/asm/pci.h | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
index 226cddd..27f4103 100644
--- a/arch/arm/include/asm/pci.h
+++ b/arch/arm/include/asm/pci.h
@@ -34,12 +34,8 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
* Whether pci_unmap_{single,page} is a nop depends upon the
* configuration.
*/
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
#ifdef CONFIG_PCI
static inline void pci_dma_burst_advice(struct pci_dev *pdev,
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: Benjamin Herrenschmidt <be...@kernel.crashing.org>
---
arch/powerpc/include/asm/pci.h | 33 +++------------------------------
1 files changed, 3 insertions(+), 30 deletions(-)
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index b5ea626..089c8d3 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -142,36 +142,9 @@ extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
#define HAVE_PCI_LEGACY 1
#if defined(CONFIG_PPC64) || defined(CONFIG_NOT_COHERENT_CACHE)
-/*
- * For 64-bit kernels, pci_unmap_{single,page} is not a nop.
- * For 32-bit non-coherent kernels, pci_dma_sync_single_for_cpu() and
- * so on are not nops.
- * and thus...
- */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
- dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
- __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) \
- ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
- (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) \
- ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- (((PTR)->LEN_NAME) = (VAL))
-
-#else /* 32-bit && coherent */
-
-/* pci_unmap_{page,single} is a nop so... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME) (0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME) (0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
-
-#endif /* CONFIG_PPC64 || CONFIG_NOT_COHERENT_CACHE */
+#define HAVE_ARCH_PCI_UNMAP
+#endif
+#include <asm-generic/pci-dma-common.h>
#ifdef CONFIG_PPC64
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: David S. Miller <da...@davemloft.net>
---
arch/sparc/include/asm/pci.h | 3 +++
arch/sparc/include/asm/pci_32.h | 14 --------------
arch/sparc/include/asm/pci_64.h | 14 --------------
3 files changed, 3 insertions(+), 28 deletions(-)
diff --git a/arch/sparc/include/asm/pci.h b/arch/sparc/include/asm/pci.h
index d9c031f..4fd2d17 100644
--- a/arch/sparc/include/asm/pci.h
+++ b/arch/sparc/include/asm/pci.h
@@ -6,6 +6,9 @@
#include <asm/pci_32.h>
#endif
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
+
#include <asm-generic/pci-dma-compat.h>
#endif
diff --git a/arch/sparc/include/asm/pci_32.h b/arch/sparc/include/asm/pci_32.h
index e769f66..332ac9a 100644
--- a/arch/sparc/include/asm/pci_32.h
+++ b/arch/sparc/include/asm/pci_32.h
@@ -32,20 +32,6 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
struct pci_dev;
-/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
- dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
- __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) \
- ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
- (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) \
- ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- (((PTR)->LEN_NAME) = (VAL))
-
#ifdef CONFIG_PCI
static inline void pci_dma_burst_advice(struct pci_dev *pdev,
enum pci_dma_burst_strategy *strat,
diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h
index b0576df..5312782 100644
--- a/arch/sparc/include/asm/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -32,20 +32,6 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
*/
#define PCI_DMA_BUS_IS_PHYS (0)
-/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
- dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
- __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) \
- ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
- (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) \
- ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- (((PTR)->LEN_NAME) = (VAL))
-
/* PCI IOMMU mapping bypass support. */
/* PCI 64-bit addressing works for all slots on all controller
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: Tony Luck <tony...@intel.com>
---
arch/ia64/include/asm/pci.h | 14 ++------------
1 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 55281aa..56df0b5 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -57,18 +57,8 @@ pcibios_penalize_isa_irq (int irq, int active)
#include <asm-generic/pci-dma-compat.h>
/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
- dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
- __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) \
- ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
- (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) \
- ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- (((PTR)->LEN_NAME) = (VAL))
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
#ifdef CONFIG_PCI
static inline void pci_dma_burst_advice(struct pci_dev *pdev,
This patch adds include/asm-generic/pci-dma-common.h that defines the
pci_unmap state API:
DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
DECLARE_PCI_UNMAP_LEN(LEN_NAME)
pci_unmap_addr(PTR, ADDR_NAME)
pci_unmap_addr_set(PTR, ADDR_NAME, VAL)
pci_unmap_len(PTR, LEN_NAME)
pci_unmap_len_set(PTR, LEN_NAME, VAL)
This enables us to remove lots of the duplication in architecture
implementations since there are only two ways to define the API.
If architectures define HAVE_ARCH_PCI_UNMAP, they get the real
definition of pci_unmap state API. If not, they get the noop
definition.
In the long term, it's better to replace the API with the generic
device model API such as DECLARE_DMA_UNMAP_ADDR. We can map the API to
the generic one (like dma-mapping-compat.h does). This patch also
makes the migration process easier.
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: x...@kernel.org
Cc: Richard Henderson <r...@twiddle.net>
Cc: Ivan Kokshaysky <i...@jurassic.park.msu.ru>
Cc: Matt Turner <matt...@gmail.com>
Cc: Russell King <li...@arm.linux.org.uk>
Cc: David Howells <dhow...@redhat.com>
Cc: Tony Luck <tony...@intel.com>
Cc: Ralf Baechle <ra...@linux-mips.org>
Cc: Kyle McMartin <ky...@mcmartin.ca>
Cc: Helge Deller <del...@gmx.de>
Cc: James Bottomley <James.B...@suse.de>
Cc: Benjamin Herrenschmidt <be...@kernel.crashing.org>
Cc: Paul Mundt <let...@linux-sh.org>
Cc: David S. Miller <da...@davemloft.net>
Cc: Chris Zankel <ch...@zankel.net>
---
include/asm-generic/pci-dma-common.h | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
create mode 100644 include/asm-generic/pci-dma-common.h
diff --git a/include/asm-generic/pci-dma-common.h b/include/asm-generic/pci-dma-common.h
new file mode 100644
index 0000000..f688bff
--- /dev/null
+++ b/include/asm-generic/pci-dma-common.h
@@ -0,0 +1,20 @@
+#ifndef _ASM_GENERIC_PCI_DMA_COMMON_H
+#define _ASM_GENERIC_PCI_DMA_COMMON_H
+
+#ifdef HAVE_ARCH_PCI_UNMAP
+#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME;
+#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME;
+#define pci_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
+#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
+#define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
+#define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
+#else
+#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
+#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
+#define pci_unmap_addr(PTR, ADDR_NAME) (0)
+#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
+#define pci_unmap_len(PTR, LEN_NAME) (0)
+#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
+#endif
+
+#endif
Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Cc: x...@kernel.org
---
arch/x86/include/asm/pci.h | 27 ++-------------------------
1 files changed, 2 insertions(+), 25 deletions(-)
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index ada8c20..441e94a 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -91,32 +91,9 @@ extern void pci_iommu_alloc(void);
#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
#if defined(CONFIG_X86_64) || defined(CONFIG_DMAR) || defined(CONFIG_DMA_API_DEBUG)
-
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
- dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
- __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME) \
- ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
- (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME) \
- ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- (((PTR)->LEN_NAME) = (VAL))
-
-#else
-
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME[0];
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) unsigned LEN_NAME[0];
-#define pci_unmap_addr(PTR, ADDR_NAME) sizeof((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
- do { break; } while (pci_unmap_addr(PTR, ADDR_NAME))
-#define pci_unmap_len(PTR, LEN_NAME) sizeof((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- do { break; } while (pci_unmap_len(PTR, LEN_NAME))
-
+#define HAVE_ARCH_PCI_UNMAP
#endif
+#include <asm-generic/pci-dma-common.h>
#endif /* __KERNEL__ */
Good stuff, moving this code to a common location is certainly
a step in the right direction.
A few general comments though:
* It seems you left out arch/cris for no good reason.
* The general tendency nowadays is to avoid new HAVE_ARCH_*
macros and instead using either a Kconfig symbol or
checking the presence of the macros themselves. In this case,
the macro would always be present, so CONFIG_PCI_UNMAP
would be reasonable.
* AFAICT, there are no architectures left doing the
non-generic version, so the code could be moved to
a global file in include/linux instead of include/asm-generic.
While include/linux/pci.h is already a bit overloaded, it's
probably the right place for this. Alternatively,
include/linux/pci-dma.h, included from include/linux/pci.h.
> In the long term, it's better to replace the API with the generic
> device model API such as DECLARE_DMA_UNMAP_ADDR. We can map the API to
> the generic one (like dma-mapping-compat.h does). This patch also
> makes the migration process easier.
Agreed.
Arnd
> From: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
>
> Signed-off-by: FUJITA Tomonori <fujita....@lab.ntt.co.jp>
Acked-by: David S. Miller <da...@davemloft.net>
> On Tuesday 09 February 2010, e...@lab.ntt.co.jp wrote:
> > This patchset adds include/asm-generic/pci-dma-common.h that defines
> > the pci_unmap state API:
> >
> > DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
> > DECLARE_PCI_UNMAP_LEN(LEN_NAME)
> > pci_unmap_addr(PTR, ADDR_NAME)
> > pci_unmap_addr_set(PTR, ADDR_NAME, VAL)
> > pci_unmap_len(PTR, LEN_NAME)
> > pci_unmap_len_set(PTR, LEN_NAME, VAL)
> >
> > This enables us to remove lots of the duplication in architecture
> > implementations since there are only two ways to define the API.
>
> Good stuff, moving this code to a common location is certainly
> a step in the right direction.
>
> A few general comments though:
>
> * It seems you left out arch/cris for no good reason.
Yeah, somehow I missed it. I'll do next time.
> * The general tendency nowadays is to avoid new HAVE_ARCH_*
> macros and instead using either a Kconfig symbol or
> checking the presence of the macros themselves. In this case,
> the macro would always be present, so CONFIG_PCI_UNMAP
> would be reasonable.
I see. I go with CONFIG_NEED_DMA_MAP_STATE (it's a bit explanatory and
mips already uses CONFIG_DMA_NEED_PCI_MAP_STATE for the same purpose).
> * AFAICT, there are no architectures left doing the
> non-generic version, so the code could be moved to
> a global file in include/linux instead of include/asm-generic.
> While include/linux/pci.h is already a bit overloaded, it's
> probably the right place for this. Alternatively,
> include/linux/pci-dma.h, included from include/linux/pci.h.
Ok, I go with linux/pci-dma.h. I prefer linux/pci.h but as you said,
looks like already too big. We'll remove this file after moving to the
generic device model. So the name shouldn't matter much.
Thanks!