On Wed, 2010-07-14 at 07:05 +0100, John Rigby wrote:
Here is an update. First, I am still getting errors of the form:
/home/jcrigby/work/git-trees/kernelbuild/linux/drivers/mtd/onenand/onenand_sim.c:142: error: expected expression before 'do'
The 'do' here is from arch/arm/include/asm/io.h: #define writew(v,c) do { wmb(); writew_relaxed(v,c); } while (0)
That looks ok until you find out how it is used in drivers/mtd/onenand/onenand_sim.c:
#define ONENAND_SET_WP_STATUS(v, this) \ (writew(v, this->base + ONENAND_REG_WP_STATUS))
The parens around it make the valid statement into an invalid expression.
This was discussed recently on the ARM Linux list. The conclusion was that using brackets around writew() is dangerous as it gives writew() a type and the compiler may generate code which forces a read back from the register being written. Using inline functions for writew() has some performance impact (it seems to add around 78K in size to the Linux kernel).
So we could change the driver above to remove the brackets but any other suggestion is welcome.