rockchip:iommu:define function use inline instead of #define when iommu disabled
authorxxm <xxm@rock-chips.com>
Thu, 31 Jul 2014 03:32:35 +0000 (11:32 +0800)
committerxxm <xxm@rock-chips.com>
Thu, 31 Jul 2014 03:32:35 +0000 (11:32 +0800)
include/linux/rockchip/iovmm.h
include/linux/rockchip/sysmmu.h

index d67454fb74dae85507ee8154171e7fe06554bd5d..6a6bde4d25eb181d057e79b48740f262b2db8955 100755 (executable)
@@ -60,16 +60,15 @@ void iovmm_unmap_oto(struct device *dev, phys_addr_t phys);
 
 struct device *rockchip_get_sysmmu_device_by_compatible(const char *compt);
 
-
 #else
-#define iovmm_activate(dev)            (-ENOSYS)
-#define iovmm_deactivate(dev)          do { } while (0)
-#define iovmm_map(dev, sg, offset, size) (-ENOSYS)
-#define iovmm_unmap(dev, iova)         do { } while (0)
-#define iovmm_map_oto(dev, phys, size) (-ENOSYS)
-#define iovmm_unmap_oto(dev, phys)     do { } while (0)
-#define rockchip_get_sysmmu_device_by_compatible(compt) (NULL)
-
+static inline int iovmm_activate(struct device *dev) {return -ENOSYS; }
+static inline void iovmm_deactivate(struct device *dev) { }
+static inline dma_addr_t iovmm_map(struct device *dev, struct scatterlist *sg, off_t offset,
+                                  size_t size) { return -ENOSYS; }
+static inline void iovmm_unmap(struct device *dev, dma_addr_t iova) { }
+static inline int iovmm_map_oto(struct device *dev, phys_addr_t phys, size_t size) {return -ENOSYS; }
+static inline void iovmm_unmap_oto(struct device *dev, phys_addr_t phys) { }
+static inline struct device *rockchip_get_sysmmu_device_by_compatible(const char *compt) {return NULL; }
 #endif /* CONFIG_ROCKCHIP_IOVMM */
 
 #endif /*__ASM_PLAT_IOVMM_H*/
index bb0f60660f1a7ca378daf397b0af7f21fc94e0a1..93f41c6ee99d855c588a38230df872a70d9343d3 100755 (executable)
@@ -41,11 +41,10 @@ struct sysmmu_drvdata;
  *                        translated. This is 0 if @itype is SYSMMU_BUSERROR.
  */
 typedef int (*sysmmu_fault_handler_t)(struct device *dev,
-                                         enum rk_sysmmu_inttype itype,
-                                         unsigned long pgtable_base,
-                                         unsigned long fault_addr,
-                                         unsigned int statu
-                                         );
+                                     enum rk_sysmmu_inttype itype,
+                                     unsigned long pgtable_base,
+                                     unsigned long fault_addr,
+                                     unsigned int statu);
        
 #ifdef CONFIG_ROCKCHIP_IOMMU
 /**
@@ -105,11 +104,25 @@ void rockchip_sysmmu_set_prefbuf(struct device *owner,
                                unsigned long base0, unsigned long size0,
                                unsigned long base1, unsigned long size1);
 #else /* CONFIG_ROCKCHIP_IOMMU */
-#define rockchip_sysmmu_enable(owner, pgd) do { } while (0)
-#define rockchip_sysmmu_disable(owner) do { } while (0)
-#define rockchip_sysmmu_tlb_invalidate(owner) do { } while (0)
-#define rockchip_sysmmu_set_fault_handler(sysmmu, handler) do { } while (0)
-#define rockchip_sysmmu_set_prefbuf(owner, b0, s0, b1, s1) do { } while (0)
+static inline int rockchip_sysmmu_enable(struct device *owner, unsigned long pgd)
+{
+       return -ENOSYS;
+}
+static inline bool rockchip_sysmmu_disable(struct device *owner)
+{
+       return false;
+}
+static inline void rockchip_sysmmu_tlb_invalidate(struct device *owner)
+{
+}
+static inline void rockchip_sysmmu_set_fault_handler(struct device *dev,sysmmu_fault_handler_t handler)
+{
+}
+static inline void rockchip_sysmmu_set_prefbuf(struct device *owner,
+                                              unsigned long base0, unsigned long size0,
+                                              unsigned long base1, unsigned long size1)
+{
+}
 #endif
 
 #ifdef CONFIG_IOMMU_API
@@ -119,7 +132,9 @@ static inline void platform_set_sysmmu(struct device *sysmmu, struct device *dev
        dev->archdata.iommu = sysmmu;
 }
 #else
-#define platform_set_sysmmu(dev, sysmmu) do { } while (0)
+static inline void platform_set_sysmmu(struct device *sysmmu, struct device *dev)
+{
+}
 #endif
 
 #endif /* _ARM_MACH_RK_SYSMMU_H_ */