From 076b4d5884e2f7615ff8f71f7dfab052d8ebf092 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Wed, 28 Oct 2015 19:56:31 +0100 Subject: [PATCH] kernel/drm: In asm/io.h, improve the iowriteN() macros. The main issue were the trailing semicolons in the definitions. These prevent usage in braceless if/else, for example: if (blah) iowrite32(...); else ... The resulting double semicolons after preprocessing lead to the closing of the if (), resulting in an "'else' without a previous 'if'" error. --- sys/dev/drm/include/asm/io.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sys/dev/drm/include/asm/io.h b/sys/dev/drm/include/asm/io.h index 191df3a833..a4ea7a6f53 100644 --- a/sys/dev/drm/include/asm/io.h +++ b/sys/dev/drm/include/asm/io.h @@ -36,9 +36,20 @@ #define ioread16(addr) *(volatile uint16_t *)((char *)addr) #define ioread32(addr) *(volatile uint32_t *)((char *)addr) -#define iowrite8(data, addr) *(volatile uint8_t *)((char *)addr) = data; -#define iowrite16(data, addr) *(volatile uint16_t *)((char *)addr) = data; -#define iowrite32(data, addr) *(volatile uint32_t *)((char *)addr) = data; +#define iowrite8(data, addr) \ + do { \ + *(volatile uint8_t *)((char *)addr) = data; \ + } while (0) + +#define iowrite16(data, addr) \ + do { \ + *(volatile uint16_t *)((char *)addr) = data; \ + } while (0) + +#define iowrite32(data, addr) \ + do { \ + *(volatile uint32_t *)((char *)addr) = data; \ + } while (0) /* ioremap: map bus memory into CPU space */ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size) -- 2.41.0