From 4e04735a5f47736c052e2934d898f5c69087842f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= Date: Sun, 30 Aug 2026 19:09:36 +0200 Subject: [PATCH] Fix define macros, was missing the do {} while (0) wrapping --- rtl837x_phy.h | 6 ++++-- rtl837x_port.h | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rtl837x_phy.h b/rtl837x_phy.h index 932516a..c5a1e9d 100644 --- a/rtl837x_phy.h +++ b/rtl837x_phy.h @@ -31,11 +31,13 @@ void rtl8224_write_reg_u16(uint16_t reg, uint16_t val) __banked; void rtl8224_sds_write(uint16_t sds_cmd, uint16_t val) __banked; void phy_config_8261(uint8_t phy, uint8_t sds) __banked; -#define RTL8224_SDS_WRITE(sds_id, page, reg, v) uint16_t _sdscmd = (uint16_t)(sds_id & 0x01) | (1 << 14) | (1 << 15); \ +#define RTL8224_SDS_WRITE(sds_id, page, reg, v) do { \ + uint16_t _sdscmd = (uint16_t)(sds_id & 0x01) | (1 << 14) | (1 << 15); \ _sdscmd |= (page & 0x3F) << 1; \ _sdscmd |= ((uint16_t)(reg & 0x1f)) << 7; \ print_string("CMD: "); print_short(_sdscmd); \ write_char('-'); print_short(v); \ - rtl8224_sds_write(_sdscmd, v); + rtl8224_sds_write(_sdscmd, v); \ + } while (0) #endif diff --git a/rtl837x_port.h b/rtl837x_port.h index b9bc84a..f8d5335 100644 --- a/rtl837x_port.h +++ b/rtl837x_port.h @@ -8,11 +8,12 @@ #define STAT_COUNTER_RX_PKTS 47 #define STAT_COUNTER_ERR_PKTS 48 -#define STAT_GET(cnt, port) \ +#define STAT_GET(cnt, port) do { \ REG_WRITE(RTL837X_STAT_GET, 0x00, 0x00, cnt >> 3, (cnt << 5) | (port << 1) | 1); \ do { \ reg_read_m(RTL837X_STAT_GET); \ - } while (sfr_data[3] & 0x1); + } while (sfr_data[3] & 0x1); \ + } while (0) // Possible values for ingress filter type typedef enum {