diff options
| author | Logan Gunthorpe <logang@deltatee.com> | 2019-01-16 13:25:21 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-22 07:39:59 -0500 |
| commit | c81d64d3dc1f2decf8f3a9354416b7496b5c389b (patch) | |
| tree | 3890b9573d45b8ae231b55530040a6d10366b820 | |
| parent | 79bf0cbd86ac4887a7ac897fec8f011a763e23ba (diff) | |
io-64-nonatomic: add io{read|write}64[be]{_lo_hi|_hi_lo} macros
This patch adds generic io{read|write}64[be]{_lo_hi|_hi_lo} macros if
they are not already defined by the architecture. (As they are provided
by the generic iomap library).
The patch also points io{read|write}64[be] to the variant specified by the
header name.
This is because new drivers are encouraged to use ioreadXX, et al instead
of readX[1], et al -- and mixing ioreadXX with readq is pretty ugly.
[1] LDD3: section 9.4.2
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | include/linux/io-64-nonatomic-hi-lo.h | 64 | ||||
| -rw-r--r-- | include/linux/io-64-nonatomic-lo-hi.h | 64 |
2 files changed, 128 insertions, 0 deletions
diff --git a/include/linux/io-64-nonatomic-hi-lo.h b/include/linux/io-64-nonatomic-hi-lo.h index 862d786a904f..ae21b72cce85 100644 --- a/include/linux/io-64-nonatomic-hi-lo.h +++ b/include/linux/io-64-nonatomic-hi-lo.h | |||
| @@ -55,4 +55,68 @@ static inline void hi_lo_writeq_relaxed(__u64 val, volatile void __iomem *addr) | |||
| 55 | #define writeq_relaxed hi_lo_writeq_relaxed | 55 | #define writeq_relaxed hi_lo_writeq_relaxed |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | #ifndef ioread64_hi_lo | ||
| 59 | #define ioread64_hi_lo ioread64_hi_lo | ||
| 60 | static inline u64 ioread64_hi_lo(void __iomem *addr) | ||
| 61 | { | ||
| 62 | u32 low, high; | ||
| 63 | |||
| 64 | high = ioread32(addr + sizeof(u32)); | ||
| 65 | low = ioread32(addr); | ||
| 66 | |||
| 67 | return low + ((u64)high << 32); | ||
| 68 | } | ||
| 69 | #endif | ||
| 70 | |||
| 71 | #ifndef iowrite64_hi_lo | ||
| 72 | #define iowrite64_hi_lo iowrite64_hi_lo | ||
| 73 | static inline void iowrite64_hi_lo(u64 val, void __iomem *addr) | ||
| 74 | { | ||
| 75 | iowrite32(val >> 32, addr + sizeof(u32)); | ||
| 76 | iowrite32(val, addr); | ||
| 77 | } | ||
| 78 | #endif | ||
| 79 | |||
| 80 | #ifndef ioread64be_hi_lo | ||
| 81 | #define ioread64be_hi_lo ioread64be_hi_lo | ||
| 82 | static inline u64 ioread64be_hi_lo(void __iomem *addr) | ||
| 83 | { | ||
| 84 | u32 low, high; | ||
| 85 | |||
| 86 | high = ioread32be(addr); | ||
| 87 | low = ioread32be(addr + sizeof(u32)); | ||
| 88 | |||
| 89 | return low + ((u64)high << 32); | ||
| 90 | } | ||
| 91 | #endif | ||
| 92 | |||
| 93 | #ifndef iowrite64be_hi_lo | ||
| 94 | #define iowrite64be_hi_lo iowrite64be_hi_lo | ||
| 95 | static inline void iowrite64be_hi_lo(u64 val, void __iomem *addr) | ||
| 96 | { | ||
| 97 | iowrite32be(val >> 32, addr); | ||
| 98 | iowrite32be(val, addr + sizeof(u32)); | ||
| 99 | } | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef ioread64 | ||
| 103 | #define ioread64_is_nonatomic | ||
| 104 | #define ioread64 ioread64_hi_lo | ||
| 105 | #endif | ||
| 106 | |||
| 107 | #ifndef iowrite64 | ||
| 108 | #define iowrite64_is_nonatomic | ||
| 109 | #define iowrite64 iowrite64_hi_lo | ||
| 110 | #endif | ||
| 111 | |||
| 112 | #ifndef ioread64be | ||
| 113 | #define ioread64be_is_nonatomic | ||
| 114 | #define ioread64be ioread64be_hi_lo | ||
| 115 | #endif | ||
| 116 | |||
| 117 | #ifndef iowrite64be | ||
| 118 | #define iowrite64be_is_nonatomic | ||
| 119 | #define iowrite64be iowrite64be_hi_lo | ||
| 120 | #endif | ||
| 121 | |||
| 58 | #endif /* _LINUX_IO_64_NONATOMIC_HI_LO_H_ */ | 122 | #endif /* _LINUX_IO_64_NONATOMIC_HI_LO_H_ */ |
diff --git a/include/linux/io-64-nonatomic-lo-hi.h b/include/linux/io-64-nonatomic-lo-hi.h index d042e7bb5adb..faaa842dbdb9 100644 --- a/include/linux/io-64-nonatomic-lo-hi.h +++ b/include/linux/io-64-nonatomic-lo-hi.h | |||
| @@ -55,4 +55,68 @@ static inline void lo_hi_writeq_relaxed(__u64 val, volatile void __iomem *addr) | |||
| 55 | #define writeq_relaxed lo_hi_writeq_relaxed | 55 | #define writeq_relaxed lo_hi_writeq_relaxed |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | #ifndef ioread64_lo_hi | ||
| 59 | #define ioread64_lo_hi ioread64_lo_hi | ||
| 60 | static inline u64 ioread64_lo_hi(void __iomem *addr) | ||
| 61 | { | ||
| 62 | u32 low, high; | ||
| 63 | |||
| 64 | low = ioread32(addr); | ||
| 65 | high = ioread32(addr + sizeof(u32)); | ||
| 66 | |||
| 67 | return low + ((u64)high << 32); | ||
| 68 | } | ||
| 69 | #endif | ||
| 70 | |||
| 71 | #ifndef iowrite64_lo_hi | ||
| 72 | #define iowrite64_lo_hi iowrite64_lo_hi | ||
| 73 | static inline void iowrite64_lo_hi(u64 val, void __iomem *addr) | ||
| 74 | { | ||
| 75 | iowrite32(val, addr); | ||
| 76 | iowrite32(val >> 32, addr + sizeof(u32)); | ||
| 77 | } | ||
| 78 | #endif | ||
| 79 | |||
| 80 | #ifndef ioread64be_lo_hi | ||
| 81 | #define ioread64be_lo_hi ioread64be_lo_hi | ||
| 82 | static inline u64 ioread64be_lo_hi(void __iomem *addr) | ||
| 83 | { | ||
| 84 | u32 low, high; | ||
| 85 | |||
| 86 | low = ioread32be(addr + sizeof(u32)); | ||
| 87 | high = ioread32be(addr); | ||
| 88 | |||
| 89 | return low + ((u64)high << 32); | ||
| 90 | } | ||
| 91 | #endif | ||
| 92 | |||
| 93 | #ifndef iowrite64be_lo_hi | ||
| 94 | #define iowrite64be_lo_hi iowrite64be_lo_hi | ||
| 95 | static inline void iowrite64be_lo_hi(u64 val, void __iomem *addr) | ||
| 96 | { | ||
| 97 | iowrite32be(val, addr + sizeof(u32)); | ||
| 98 | iowrite32be(val >> 32, addr); | ||
| 99 | } | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifndef ioread64 | ||
| 103 | #define ioread64_is_nonatomic | ||
| 104 | #define ioread64 ioread64_lo_hi | ||
| 105 | #endif | ||
| 106 | |||
| 107 | #ifndef iowrite64 | ||
| 108 | #define iowrite64_is_nonatomic | ||
| 109 | #define iowrite64 iowrite64_lo_hi | ||
| 110 | #endif | ||
| 111 | |||
| 112 | #ifndef ioread64be | ||
| 113 | #define ioread64be_is_nonatomic | ||
| 114 | #define ioread64be ioread64be_lo_hi | ||
| 115 | #endif | ||
| 116 | |||
| 117 | #ifndef iowrite64be | ||
| 118 | #define iowrite64be_is_nonatomic | ||
| 119 | #define iowrite64be iowrite64be_lo_hi | ||
| 120 | #endif | ||
| 121 | |||
| 58 | #endif /* _LINUX_IO_64_NONATOMIC_LO_HI_H_ */ | 122 | #endif /* _LINUX_IO_64_NONATOMIC_LO_HI_H_ */ |
