add scripts

This commit is contained in:
2025-11-08 10:28:02 -05:00
parent 718d82aabc
commit 299f39d3f2
7 changed files with 717 additions and 0 deletions

148
apply-dahdi-patches.sh Normal file
View File

@@ -0,0 +1,148 @@
#!/bin/bash
# Apply DAHDI driver patch for OpenWRT 24.10.4
# Fixes MAX macro naming issues in dahdi-linux modules
# Author: ChatGPT (for Zhe Yuan)
set -e
umask 022
PATCH_DIR="package/feeds/telephony/dahdi-linux/patches"
PATCH_FILE="$PATCH_DIR/300-fix-dahdi-max-attempts.patch"
echo "========================================"
echo " DAHDI Linux Patch Applier for OpenWRT"
echo "========================================"
# --- Check if inside OpenWRT source directory ---
if [ ! -f "feeds.conf.default" ] || [ ! -d "package" ]; then
echo "[ERROR] This script must be run inside the OpenWRT root directory."
echo "Please 'cd' to your OpenWRT source root and run again."
exit 1
fi
# --- Check if dahdi patch directory exists ---
if [ ! -d "$PATCH_DIR" ]; then
echo "[ERROR] Patch directory not found:"
echo " $PATCH_DIR"
echo
echo "Please make sure telephony feed is installed:"
echo " ./scripts/feeds update telephony"
echo " ./scripts/feeds install -a"
exit 1
fi
# --- Create patch file ---
echo "[INFO] Writing DAHDI patch to: $PATCH_FILE"
cat > "$PATCH_FILE" <<'EOF'
--- a/drivers/dahdi/wctdm24xxp/base.c
+++ b/drivers/dahdi/wctdm24xxp/base.c
@@ -1516,16 +1516,16 @@ static int wait_access(struct wctdm *wc, struct wctdm_module *const mod)
{
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);
}
--- a/drivers/dahdi/opvxa1200/base.c
+++ b/drivers/dahdi/opvxa1200/base.c
@@ -868,12 +868,12 @@ static int wait_access(struct wctdm *wc, int card)
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 *wc, int card)
}
- 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, struct wcaxx_module *const mod)
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 *wc, int card)
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 *wc, int card)
}
- 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;
}
EOF
echo "[SUCCESS] Patch written successfully!"
echo
echo "========================================"
echo "✅ DAHDI patch applied successfully!"
echo " File: $PATCH_FILE"
echo "========================================"
echo
echo "👉 Next step:"
echo " make package/feeds/telephony/dahdi-linux/{clean,prepare} V=s"
echo " make package/feeds/telephony/dahdi-linux/compile V=s"
echo