[PATCH 1/2] goldfish: Add functions to simplify goldfish related MMIO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Roman Kiryanov <rkir@xxxxxxxxxx>

Add functions
* to read and write u64 to be used in the goldfish sync driver.
* to write integer pointers to remove casting in tty/goldfish.c.

Signed-off-by: Roman Kiryanov <rkir@xxxxxxxxxx>
---
 include/linux/goldfish.h | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/include/linux/goldfish.h b/include/linux/goldfish.h
index 2835c150c3ff..50af2f3d710a 100644
--- a/include/linux/goldfish.h
+++ b/include/linux/goldfish.h
@@ -4,24 +4,43 @@
 
 /* Helpers for Goldfish virtual platform */
 
-static inline void gf_write_ptr(const void *ptr, void __iomem *portl,
-				void __iomem *porth)
+static inline void gf_write_addr(unsigned long addr, void __iomem *portl,
+				 void __iomem *porth)
 {
-	writel((u32)(unsigned long)ptr, portl);
+	writel((u32)addr, portl);
 #ifdef CONFIG_64BIT
-	writel((unsigned long)ptr >> 32, porth);
+	writel((u32)(addr >> 32), porth);
 #endif
 }
 
-static inline void gf_write_dma_addr(const dma_addr_t addr,
-				     void __iomem *portl,
+static inline void gf_write_ptr(const void *ptr, void __iomem *portl,
+				void __iomem *porth)
+{
+	gf_write_addr((unsigned long)ptr, portl, porth);
+}
+
+static inline void gf_write_u64(u64 value, void __iomem *portl,
+				void __iomem *porth)
+{
+	writel((u32)value, portl);
+	writel((u32)(value >> 32), porth);
+}
+
+static inline u64 gf_read_u64(void __iomem *portl, void __iomem *porth)
+{
+	u64 lo = readl(portl);
+	u64 hi = readl(porth);
+
+	return lo | (hi << 32);
+}
+
+static inline void gf_write_dma_addr(const dma_addr_t addr, void __iomem *portl,
 				     void __iomem *porth)
 {
 	writel((u32)addr, portl);
 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
-	writel(addr >> 32, porth);
+	writel((u32)(addr >> 32), porth);
 #endif
 }
 
-
 #endif /* __LINUX_GOLDFISH_H */
-- 
2.18.0.rc2.346.g013aa6912e-goog

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux