dahdi-inux: Rename MAX definition to avoid macro naming conflict 923/head
authorLiangbin Lian <[email protected]>
Wed, 22 Oct 2025 06:49:11 +0000 (14:49 +0800)
committerChristian Marangi <[email protected]>
Wed, 22 Oct 2025 08:35:56 +0000 (10:35 +0200)
Partial backport of c80fd2d66d4d ("dahdi-linux: Update version to
3.4.0") where a compilation error for MAX macro is internally fixed.

Fixes: https://github.com/openwrt/telephony/issues/921
Signed-off-by: Liangbin Lian <[email protected]>
[ improve commit description ]
Link: https://github.com/openwrt/telephony/pull/923
Signed-off-by: Christian Marangi <[email protected]>
libs/dahdi-linux/Makefile
libs/dahdi-linux/patches/011-rename-max-definition.patch [new file with mode: 0644]

index 97955d1f50ee250fdefedc91b6491eb70a4b05eb..08d7756f28161eed7b373d51699e1379c5bc7f8b 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=dahdi-linux
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/asterisk/dahdi-linux.git
diff --git a/libs/dahdi-linux/patches/011-rename-max-definition.patch b/libs/dahdi-linux/patches/011-rename-max-definition.patch
new file mode 100644 (file)
index 0000000..1c3e4d6
--- /dev/null
@@ -0,0 +1,107 @@
+commit b821026c73588e927ae882f904642c2103781395
+Author: InterLinked1 <[email protected]>
+Date:   Sun Sep 22 16:34:05 2024 -0400
+
+    drivers: Rename MAX definition to avoid macro naming conflict.
+    
+    MAX can already be defined by the kernel headers and cause
+    compilation failure due to the redefinition, so use
+    MAX_ATTEMPTS to a more descriptive and non-conflicting name.
+    
+    Resolves: #61
+
+--- a/drivers/dahdi/opvxa1200/base.c
++++ b/drivers/dahdi/opvxa1200/base.c
+@@ -868,12 +868,12 @@ static int __wait_access(struct wctdm *w
+     long origjiffies;
+     int count = 0;
+-    #define MAX 6000 /* attempts */
++    #define MAX_ATTEMPTS 6000 /* attempts */
+     origjiffies = jiffies;
+     /* Wait for indirect access */
+-    while (count++ < MAX)
++    while (count++ < MAX_ATTEMPTS)
+        {
+               data = __wctdm_getreg(wc, card, I_STATUS);
+@@ -882,7 +882,7 @@ static int __wait_access(struct wctdm *w
+        }
+-    if(count > (MAX-1)) printk(KERN_NOTICE " ##### Loop error (%02x) #####\n", data);
++    if(count > (MAX_ATTEMPTS-1)) printk(KERN_NOTICE " ##### Loop error (%02x) #####\n", data);
+       return 0;
+ }
+--- a/drivers/dahdi/wcaxx-base.c
++++ b/drivers/dahdi/wcaxx-base.c
+@@ -1066,16 +1066,16 @@ static int wait_access(struct wcaxx *wc,
+       unsigned char data = 0;
+       int count = 0;
+-      #define MAX 10 /* attempts */
++      #define MAX_ATTEMPTS 10 /* attempts */
+       /* Wait for indirect access */
+-      while (count++ < MAX) {
++      while (count++ < MAX_ATTEMPTS) {
+               data = wcaxx_getreg(wc, mod, I_STATUS);
+               if (!data)
+                       return 0;
+       }
+-      if (count > (MAX-1)) {
++      if (count > (MAX_ATTEMPTS-1)) {
+               dev_notice(&wc->xb.pdev->dev,
+                          " ##### Loop error (%02x) #####\n", data);
+       }
+--- a/drivers/dahdi/wctdm.c
++++ b/drivers/dahdi/wctdm.c
+@@ -623,11 +623,11 @@ static int __wait_access(struct wctdm *w
+     unsigned char data = 0;
+     int count = 0;
+-    #define MAX 6000 /* attempts */
++    #define MAX_ATTEMPTS 6000 /* attempts */
+     /* Wait for indirect access */
+-    while (count++ < MAX)
++    while (count++ < MAX_ATTEMPTS)
+        {
+               data = __wctdm_getreg(wc, card, I_STATUS);
+@@ -636,7 +636,7 @@ static int __wait_access(struct wctdm *w
+        }
+-    if(count > (MAX-1)) printk(KERN_NOTICE " ##### Loop error (%02x) #####\n", data);
++    if(count > (MAX_ATTEMPTS-1)) printk(KERN_NOTICE " ##### Loop error (%02x) #####\n", data);
+       return 0;
+ }
+--- a/drivers/dahdi/wctdm24xxp/base.c
++++ b/drivers/dahdi/wctdm24xxp/base.c
+@@ -1516,16 +1516,16 @@ static int wait_access(struct wctdm *wc,
+       unsigned char data = 0;
+       int count = 0;
+-      #define MAX 10 /* attempts */
++      #define MAX_ATTEMPTS 10 /* attempts */
+       /* Wait for indirect access */
+-      while (count++ < MAX) {
++      while (count++ < MAX_ATTEMPTS) {
+               data = wctdm_getreg(wc, mod, I_STATUS);
+               if (!data)
+                       return 0;
+       }
+-      if (count > (MAX-1)) {
++      if (count > (MAX_ATTEMPTS-1)) {
+               dev_notice(&wc->vb.pdev->dev,
+                          " ##### Loop error (%02x) #####\n", data);
+       }