|
From: openocd-gerrit <ope...@us...> - 2024-10-05 15:50:51
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 595bb965b745371e07091c96ced478c8cd0b0d82 (commit)
from 8c23e6c1759be497c1328837fb49992d489b0719 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 595bb965b745371e07091c96ced478c8cd0b0d82
Author: Antonio Borneo <bor...@gm...>
Date: Mon Sep 16 10:58:37 2024 +0200
jtag: bcm2835gpio: fix macro definition
The macros trigger few errors with checkpatch:
ERROR:MACRO_ARG_REUSE: Macro argument reuse 'g' - possible
side-effects?
ERROR:TRAILING_STATEMENTS: trailing statements should be
on next line
ERROR:SPACING: spaces preferred around (several cases)
ERROR:SINGLE_STATEMENT_DO_WHILE_MACRO: Single statement
macros should not use a do {} while (0) loop
plus an empty line triggers
ERROR:BRACES: Blank lines aren't necessary before a close
brace '}'
Fix them!
Change-Id: I0690b68b511ed7f45a7e0909a0addd2822ba9fe8
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8499
Tested-by: jenkins
Reviewed-by: Tomas Vanek <va...@fb...>
diff --git a/src/jtag/drivers/bcm2835gpio.c b/src/jtag/drivers/bcm2835gpio.c
index ff10b0a78..b8d91bf38 100644
--- a/src/jtag/drivers/bcm2835gpio.c
+++ b/src/jtag/drivers/bcm2835gpio.c
@@ -31,16 +31,28 @@ static off_t bcm2835_peri_base = 0x20000000;
#define BCM2835_GPIO_MODE_OUTPUT 1
/* GPIO setup macros */
-#define MODE_GPIO(g) (*(pio_base+((g)/10))>>(((g)%10)*3) & 7)
-#define INP_GPIO(g) do { *(pio_base+((g)/10)) &= ~(7<<(((g)%10)*3)); } while (0)
-#define SET_MODE_GPIO(g, m) do { /* clear the mode bits first, then set as necessary */ \
- INP_GPIO(g); \
- *(pio_base+((g)/10)) |= ((m)<<(((g)%10)*3)); } while (0)
+#define MODE_GPIO(_g) ({ \
+ typeof(_g) g = (_g); \
+ *(pio_base + (g / 10)) >> ((g % 10) * 3) & 7; \
+})
+
+#define INP_GPIO(_g) do { \
+ typeof(_g) g1 = (_g); \
+ *(pio_base + (g1 / 10)) &= ~(7 << ((g1 % 10) * 3)); \
+} while (0)
+
+#define SET_MODE_GPIO(_g, m) do { \
+ typeof(_g) g = (_g); \
+ /* clear the mode bits first, then set as necessary */ \
+ INP_GPIO(g); \
+ *(pio_base + (g / 10)) |= ((m) << ((g % 10) * 3)); \
+} while (0)
+
#define OUT_GPIO(g) SET_MODE_GPIO(g, BCM2835_GPIO_MODE_OUTPUT)
-#define GPIO_SET (*(pio_base+7)) /* sets bits which are 1, ignores bits which are 0 */
-#define GPIO_CLR (*(pio_base+10)) /* clears bits which are 1, ignores bits which are 0 */
-#define GPIO_LEV (*(pio_base+13)) /* current level of the pin */
+#define GPIO_SET (*(pio_base + 7)) /* sets bits which are 1, ignores bits which are 0 */
+#define GPIO_CLR (*(pio_base + 10)) /* clears bits which are 1, ignores bits which are 0 */
+#define GPIO_LEV (*(pio_base + 13)) /* current level of the pin */
static int dev_mem_fd;
static volatile uint32_t *pio_base = MAP_FAILED;
@@ -175,7 +187,6 @@ static bb_value_t bcm2835gpio_read(void)
unsigned int shift = adapter_gpio_config[ADAPTER_GPIO_IDX_TDO].gpio_num;
uint32_t value = (GPIO_LEV >> shift) & 1;
return value ^ (adapter_gpio_config[ADAPTER_GPIO_IDX_TDO].active_low ? BB_HIGH : BB_LOW);
-
}
static int bcm2835gpio_write(int tck, int tms, int tdi)
-----------------------------------------------------------------------
Summary of changes:
src/jtag/drivers/bcm2835gpio.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|