if (count) { do { ... } while (--count); } can be rewritten as while (count-- > 0) { ... } Drop useless variables while I'm at it. Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx> --- include/asm-generic/io.h | 68 ++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 44 deletions(-) --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -317,13 +317,10 @@ static inline void writeq_relaxed(u64 value, volatile void __iomem *addr) static inline void readsb(const volatile void __iomem *addr, void *buffer, unsigned int count) { - if (count) { - u8 *buf = buffer; + u8 *buf = buffer; - do { - u8 x = __raw_readb(addr); - *buf++ = x; - } while (--count); + while (count-- > 0) { + *buf++ = __raw_readb(addr); } } #endif @@ -333,13 +330,10 @@ static inline void readsb(const volatile void __iomem *addr, void *buffer, static inline void readsw(const volatile void __iomem *addr, void *buffer, unsigned int count) { - if (count) { - u16 *buf = buffer; + u16 *buf = buffer; - do { - u16 x = __raw_readw(addr); - *buf++ = x; - } while (--count); + while (count-- > 0) { + *buf++ = __raw_readw(addr); } } #endif @@ -349,13 +343,10 @@ static inline void readsw(const volatile void __iomem *addr, void *buffer, static inline void readsl(const volatile void __iomem *addr, void *buffer, unsigned int count) { - if (count) { - u32 *buf = buffer; + u32 *buf = buffer; - do { - u32 x = __raw_readl(addr); - *buf++ = x; - } while (--count); + while (count-- > 0) { + *buf++ = __raw_readl(addr); } } #endif @@ -366,13 +357,10 @@ static inline void readsl(const volatile void __iomem *addr, void *buffer, static inline void readsq(const volatile void __iomem *addr, void *buffer, unsigned int count) { - if (count) { - u64 *buf = buffer; + u64 *buf = buffer; - do { - u64 x = __raw_readq(addr); - *buf++ = x; - } while (--count); + while (count-- > 0) { + *buf++ = __raw_readq(addr); } } #endif @@ -383,12 +371,10 @@ static inline void readsq(const volatile void __iomem *addr, void *buffer, static inline void writesb(volatile void __iomem *addr, const void *buffer, unsigned int count) { - if (count) { - const u8 *buf = buffer; + const u8 *buf = buffer; - do { - __raw_writeb(*buf++, addr); - } while (--count); + while (count-- > 0) { + __raw_writeb(*buf++, addr); } } #endif @@ -398,12 +384,10 @@ static inline void writesb(volatile void __iomem *addr, const void *buffer, static inline void writesw(volatile void __iomem *addr, const void *buffer, unsigned int count) { - if (count) { - const u16 *buf = buffer; + const u16 *buf = buffer; - do { - __raw_writew(*buf++, addr); - } while (--count); + while (count-- > 0) { + __raw_writew(*buf++, addr); } } #endif @@ -413,12 +397,10 @@ static inline void writesw(volatile void __iomem *addr, const void *buffer, static inline void writesl(volatile void __iomem *addr, const void *buffer, unsigned int count) { - if (count) { - const u32 *buf = buffer; + const u32 *buf = buffer; - do { - __raw_writel(*buf++, addr); - } while (--count); + while (count-- > 0) { + __raw_writel(*buf++, addr); } } #endif @@ -429,12 +411,10 @@ static inline void writesl(volatile void __iomem *addr, const void *buffer, static inline void writesq(volatile void __iomem *addr, const void *buffer, unsigned int count) { - if (count) { - const u64 *buf = buffer; + const u64 *buf = buffer; - do { - __raw_writeq(*buf++, addr); - } while (--count); + while (count-- > 0) { + __raw_writeq(*buf++, addr); } } #endif