On 11 August 2015 at 11:42, Haojian Zhuang haojian.zhuang@linaro.org wrote:
Both GPIO_PIN_MASK_HIGH_8BIT() and GPIO_PIN_MASK_LOW_8BIT() macro should return a 8-bit value. But it returned a boolean value (0 or 1). So replace "&&" with "&" instead.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Haojian Zhuang haojian.zhuang@linaro.org
ArmPlatformPkg/Include/Drivers/PL061Gpio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ArmPlatformPkg/Include/Drivers/PL061Gpio.h b/ArmPlatformPkg/Include/Drivers/PL061Gpio.h index 38458f4..cafa7b2 100644 --- a/ArmPlatformPkg/Include/Drivers/PL061Gpio.h +++ b/ArmPlatformPkg/Include/Drivers/PL061Gpio.h @@ -47,8 +47,8 @@ // All bits low except one bit high, native bit length #define GPIO_PIN_MASK(Pin) (1UL << ((UINTN)(Pin))) // All bits low except one bit high, restricted to 8 bits (i.e. ensures zeros above 8bits) -#define GPIO_PIN_MASK_HIGH_8BIT(Pin) (GPIO_PIN_MASK(Pin) && 0xFF) +#define GPIO_PIN_MASK_HIGH_8BIT(Pin) (GPIO_PIN_MASK(Pin) & 0xFF) // All bits high except one bit low, restricted to 8 bits (i.e. ensures zeros above 8bits) -#define GPIO_PIN_MASK_LOW_8BIT(Pin) ((~GPIO_PIN_MASK(Pin)) && 0xFF) +#define GPIO_PIN_MASK_LOW_8BIT(Pin) ((~GPIO_PIN_MASK(Pin)) & 0xFF)
#endif // __PL061_GPIO_H__
OK, you were really quick with these patches :-)
I looked at the code and the PL061 documentation myself, and I would like to propose a more thorough way to fix this code.
In this patch, could you please remove the two macros completely? So in the .c file, GPIO_PIN_MASK_HIGH_8BIT() just becomes GPIO_PIN_MASK() and GPIO_PIN_MASK_LOW_8BIT() become ~GPIO_PIN_MASK(). Then, these 2 macros can be dropped. (If you are feeling pedantic, you can add a (UINT8) cast to the definition of GPIO_PIN_MASK(), but I don't think any of the compilers we support for ARM will complain if you don't)
The reason is that a) they are not needed, since they are only used inside MmioXxxx8() functions that ignore the top bits anyway, so they only make the C code more difficult to read b) their names are misleading -> 'mask low 8 bit' means something different to most programmers from what is being done here. c) your next patch will remove a couple of invocations anyway (see my comments there)
Thanks, Ard.