From 7d804a3b5316cc048892b7cee921b6d67f278cba Mon Sep 17 00:00:00 2001 From: "Jason D. McCormick" Date: Fri, 17 Jan 2025 18:03:50 -0500 Subject: [PATCH 1/2] backport upstream patches for linux 6.11 builds --- Makefile | 2 +- debian/changelog | 6 ++ debian/patches/58_rhel_guard | 124 +++++++++++++++++++++++++++++++ debian/patches/66_empty_if | 32 ++++++++ debian/patches/kernel_6_11_sysfs | 76 +++++++++++++++++++ debian/patches/series | 3 + 6 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 debian/patches/58_rhel_guard create mode 100644 debian/patches/66_empty_if create mode 100644 debian/patches/kernel_6_11_sysfs diff --git a/Makefile b/Makefile index adea1af..0dfaf9d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ EPOCHVER = 1: RELVER = 3.4.0 -DEBVER = 5+asl +DEBVER = 6+asl PKGNAME = dahdi-linux ifndef ${RELPLAT} RELPLAT = deb$(shell lsb_release -rs 2> /dev/null) diff --git a/debian/changelog b/debian/changelog index 8887a8d..fe9f140 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +dahdi-linux (1:3.4.0-6+asl) unstable; urgency=medium + + * Backport PRs 58, 64, 66 for kernel 6.11 support + + -- Jason McCormick Fri, 17 Jan 2025 18:03:44 -0500 + dahdi-linux (1:3.4.0-5+asl) unstable; urgency=medium * Remove BUILD_EXCLUSIVE_CONFIG for PCI/USB diff --git a/debian/patches/58_rhel_guard b/debian/patches/58_rhel_guard new file mode 100644 index 0000000..b3d8f64 --- /dev/null +++ b/debian/patches/58_rhel_guard @@ -0,0 +1,124 @@ +From cff5c1487e59b07407377fc009c1620261d1d926 Mon Sep 17 00:00:00 2001 +From: InterLinked1 <24227567+InterLinked1@users.noreply.github.com> +Date: Thu, 19 Sep 2024 20:03:28 -0400 +Subject: [PATCH] dahdi-sysfs, xbus-sysfs: Fix RHEL conditional compilation + checks. + +Commit d7bbc8a96fe767bc4eee15dd43170f298282a4c3 introduced +a regression for non-RHEL distros using kernels older than +6.3.0 by not properly guarding usage of the RHEL macros. +Even though the logic short-circuits, undefined macros can +still be used this way, so add another #if block to prevent +using undefined macros. + +Resolves: #51 +--- + drivers/dahdi/dahdi-sysfs-chan.c | 11 +++++++---- + drivers/dahdi/dahdi-sysfs.c | 22 ++++++++++++++-------- + drivers/dahdi/xpp/xbus-sysfs.c | 11 +++++++---- + 3 files changed, 28 insertions(+), 16 deletions(-) + +diff --git a/drivers/dahdi/dahdi-sysfs-chan.c b/drivers/dahdi/dahdi-sysfs-chan.c +index 09d73172..f4d287b3 100644 +--- a/drivers/dahdi/dahdi-sysfs-chan.c ++++ b/drivers/dahdi/dahdi-sysfs-chan.c +@@ -484,15 +484,18 @@ int __init dahdi_sysfs_chan_init(const struct file_operations *fops) + should_cleanup.channel_driver = 1; + + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) +-#if defined RHEL_RELEASE_VERSION && (RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) && \ +- RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,4) ++#if defined(RHEL_RELEASE_VERSION) && defined(RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) ++#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 4) + dahdi_class = class_create("dahdi"); + #else + dahdi_class = class_create(THIS_MODULE, "dahdi"); +-#endif ++#endif /* RHEL_RELEASE_CODE */ ++#else ++ dahdi_class = class_create(THIS_MODULE, "dahdi"); ++#endif /* RHEL_RELEASE_VERSION */ + #else + dahdi_class = class_create("dahdi"); +-#endif ++#endif /* LINUX_VERSION_CODE */ + if (IS_ERR(dahdi_class)) { + res = PTR_ERR(dahdi_class); + dahdi_err("%s: class_create(dahi_chan) failed. Error: %d\n", +diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c +index 7477ebc9..7b302c6f 100644 +--- a/drivers/dahdi/dahdi-sysfs.c ++++ b/drivers/dahdi/dahdi-sysfs.c +@@ -69,15 +69,18 @@ static inline struct dahdi_span *dev_to_span(const struct device *dev) + } while (0) + + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) +-#if defined RHEL_RELEASE_VERSION && (RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) && \ +- RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,4) ++#if defined(RHEL_RELEASE_VERSION) && defined(RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) ++#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 4) + static int span_uevent(const struct device *dev, struct kobj_uevent_env *kenv) + #else + static int span_uevent(struct device *dev, struct kobj_uevent_env *kenv) +-#endif ++#endif /* RHEL_RELEASE_CODE */ ++#else ++static int span_uevent(struct device *dev, struct kobj_uevent_env *kenv) ++#endif /* RHEL_RELEASE_VERSION */ + #else + static int span_uevent(const struct device *dev, struct kobj_uevent_env *kenv) +-#endif ++#endif /* LINUX_VERSION_CODE */ + { + struct dahdi_span *span; + +@@ -448,15 +451,18 @@ static inline struct dahdi_device *to_ddev(const struct device *dev) + } while (0) + + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) +-#if defined RHEL_RELEASE_VERSION && (RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) && \ +- RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,4) ++#if defined(RHEL_RELEASE_VERSION) && defined(RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) ++#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 4) + static int device_uevent(const struct device *dev, struct kobj_uevent_env *kenv) + #else + static int device_uevent(struct device *dev, struct kobj_uevent_env *kenv) +-#endif ++#endif /* RHEL_RELEASE_CODE */ ++#else ++static int device_uevent(struct device *dev, struct kobj_uevent_env *kenv) ++#endif /* RHEL_RELEASE_VERSION */ + #else + static int device_uevent(const struct device *dev, struct kobj_uevent_env *kenv) +-#endif ++#endif /* LINUX_VERSION_CODE */ + { + struct dahdi_device *ddev; + +diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c +index 177048b2..897c86d8 100644 +--- a/drivers/dahdi/xpp/xbus-sysfs.c ++++ b/drivers/dahdi/xpp/xbus-sysfs.c +@@ -420,15 +420,18 @@ static int astribank_match(struct device *dev, struct device_driver *driver) + + + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) +-#if defined RHEL_RELEASE_VERSION && (RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) && \ +- RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,4) ++#if defined(RHEL_RELEASE_VERSION) && defined(RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) ++#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 4) + static int astribank_uevent(const struct device *dev, struct kobj_uevent_env *kenv) + #else + static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv) +-#endif ++#endif /* RHEL_RELEASE_CODE */ ++#else ++static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv) ++#endif /* RHEL_RELEASE_VERSION */ + #else + static int astribank_uevent(const struct device *dev, struct kobj_uevent_env *kenv) +-#endif ++#endif /* LINUX_VERSION_CODE */ + { + xbus_t *xbus; + extern char *initdir; diff --git a/debian/patches/66_empty_if b/debian/patches/66_empty_if new file mode 100644 index 0000000..ded53f1 --- /dev/null +++ b/debian/patches/66_empty_if @@ -0,0 +1,32 @@ +From a1f6aa718e587481a3998642aed7a1246f114583 Mon Sep 17 00:00:00 2001 +From: InterLinked1 <24227567+InterLinked1@users.noreply.github.com> +Date: Mon, 23 Sep 2024 19:14:44 -0400 +Subject: [PATCH] xpp: Add braces around empty if statements. + +Avoid compilation failure on modern kernels by adding braces +around empty if body. + +Resolves: #65 +--- + drivers/dahdi/xpp/card_fxs.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c +index bb1c169f3..d4383aa4e 100644 +--- a/drivers/dahdi/xpp/card_fxs.c ++++ b/drivers/dahdi/xpp/card_fxs.c +@@ -1169,10 +1169,12 @@ static int set_vmwi(xpd_t *xpd, int pos, unsigned long arg) + "%s: VMWI(hvdc) is not implemented yet. Ignored.\n", + __func__); + } +- if (VMWI_TYPE(priv, pos, HVAC)) ++ if (VMWI_TYPE(priv, pos, HVAC)) { + ; /* VMWI_NEON */ +- if (priv->vmwisetting[pos].vmwi_type == 0) ++ } ++ if (priv->vmwisetting[pos].vmwi_type == 0) { + ; /* Disable VMWI */ ++ } + priv->vmwisetting[pos] = vmwisetting; + set_vm_led_mode(xpd->xbus, xpd, pos, PHONEDEV(xpd).msg_waiting[pos]); + return 0; diff --git a/debian/patches/kernel_6_11_sysfs b/debian/patches/kernel_6_11_sysfs new file mode 100644 index 0000000..e26b73b --- /dev/null +++ b/debian/patches/kernel_6_11_sysfs @@ -0,0 +1,76 @@ +From ce9de5d1bf9d21c088b01ce9da6f7ff02b0d863d Mon Sep 17 00:00:00 2001 +From: InterLinked1 <24227567+InterLinked1@users.noreply.github.com> +Date: Mon, 23 Sep 2024 08:04:54 -0400 +Subject: [PATCH] xpp, sysfs: Use const struct device_device if needed. + +Kernel commit d69d804845985c29ab5be5a4b3b1f4787893daf8 +changed struct device_driver to be const, so make the +arguments const on kernels 6.11 and newer. + +Resolves: #63 +--- + drivers/dahdi/dahdi-sysfs-chan.c | 4 ++++ + drivers/dahdi/dahdi-sysfs.c | 4 ++++ + drivers/dahdi/xpp/xbus-sysfs.c | 8 ++++++++ + 3 files changed, 16 insertions(+) + +diff --git a/drivers/dahdi/dahdi-sysfs-chan.c b/drivers/dahdi/dahdi-sysfs-chan.c +index 09d73172..35b7bd41 100644 +--- a/drivers/dahdi/dahdi-sysfs-chan.c ++++ b/drivers/dahdi/dahdi-sysfs-chan.c +@@ -220,7 +220,11 @@ static void chan_release(struct device *dev) + chan_dbg(DEVICES, chan, "SYSFS\n"); + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) ++static int chan_match(struct device *dev, const struct device_driver *driver) ++#else + static int chan_match(struct device *dev, struct device_driver *driver) ++#endif /* LINUX_VERSION_CODE */ + { + struct dahdi_chan *chan; + +diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c +index 7477ebc9..246514cc 100644 +--- a/drivers/dahdi/dahdi-sysfs.c ++++ b/drivers/dahdi/dahdi-sysfs.c +@@ -42,7 +42,11 @@ module_param(tools_rootdir, charp, 0444); + MODULE_PARM_DESC(tools_rootdir, + "root directory of all tools paths (default /)"); + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) ++static int span_match(struct device *dev, const struct device_driver *driver) ++#else + static int span_match(struct device *dev, struct device_driver *driver) ++#endif /* LINUX_VERSION_CODE */ + { + return 1; + } +diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c +index 177048b2..f78a15ec 100644 +--- a/drivers/dahdi/xpp/xbus-sysfs.c ++++ b/drivers/dahdi/xpp/xbus-sysfs.c +@@ -397,7 +397,11 @@ static struct attribute *xbus_dev_attrs[] = { + ATTRIBUTE_GROUPS(xbus_dev); + #endif + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) ++static int astribank_match(struct device *dev, const struct device_driver *driver) ++#else + static int astribank_match(struct device *dev, struct device_driver *driver) ++#endif /* LINUX_VERSION_CODE */ + { + DBG(DEVICES, "SYSFS MATCH: dev->bus_id = %s, driver->name = %s\n", + dev_name(dev), driver->name); +@@ -771,7 +775,11 @@ static DEVICE_ATTR_READER(refcount_xpd_show, dev, buf) + return len; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) ++static int xpd_match(struct device *dev, const struct device_driver *driver) ++#else + static int xpd_match(struct device *dev, struct device_driver *driver) ++#endif /* LINUX_VERSION_CODE */ + { + struct xpd_driver *xpd_driver; + xpd_t *xpd; diff --git a/debian/patches/series b/debian/patches/series index 164eff1..c258eba 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,3 +2,6 @@ no_firmware_download minimize-modules autop_vox +58_rhel_guard +kernel_6_11_sysfs +66_empty_if From 053c030288d9db019f999a966a1d291976509e67 Mon Sep 17 00:00:00 2001 From: "Jason D. McCormick" Date: Fri, 17 Jan 2025 18:06:57 -0500 Subject: [PATCH 2/2] remove 58_rhel_guard --- debian/changelog | 4 +- debian/patches/58_rhel_guard | 124 ----------------------------------- debian/patches/series | 1 - 3 files changed, 2 insertions(+), 127 deletions(-) delete mode 100644 debian/patches/58_rhel_guard diff --git a/debian/changelog b/debian/changelog index fe9f140..407c94b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ dahdi-linux (1:3.4.0-6+asl) unstable; urgency=medium - * Backport PRs 58, 64, 66 for kernel 6.11 support + * Backport PRs 64, 66 for kernel 6.11 support - -- Jason McCormick Fri, 17 Jan 2025 18:03:44 -0500 + -- Jason McCormick Fri, 17 Jan 2025 18:06:53 -0500 dahdi-linux (1:3.4.0-5+asl) unstable; urgency=medium diff --git a/debian/patches/58_rhel_guard b/debian/patches/58_rhel_guard deleted file mode 100644 index b3d8f64..0000000 --- a/debian/patches/58_rhel_guard +++ /dev/null @@ -1,124 +0,0 @@ -From cff5c1487e59b07407377fc009c1620261d1d926 Mon Sep 17 00:00:00 2001 -From: InterLinked1 <24227567+InterLinked1@users.noreply.github.com> -Date: Thu, 19 Sep 2024 20:03:28 -0400 -Subject: [PATCH] dahdi-sysfs, xbus-sysfs: Fix RHEL conditional compilation - checks. - -Commit d7bbc8a96fe767bc4eee15dd43170f298282a4c3 introduced -a regression for non-RHEL distros using kernels older than -6.3.0 by not properly guarding usage of the RHEL macros. -Even though the logic short-circuits, undefined macros can -still be used this way, so add another #if block to prevent -using undefined macros. - -Resolves: #51 ---- - drivers/dahdi/dahdi-sysfs-chan.c | 11 +++++++---- - drivers/dahdi/dahdi-sysfs.c | 22 ++++++++++++++-------- - drivers/dahdi/xpp/xbus-sysfs.c | 11 +++++++---- - 3 files changed, 28 insertions(+), 16 deletions(-) - -diff --git a/drivers/dahdi/dahdi-sysfs-chan.c b/drivers/dahdi/dahdi-sysfs-chan.c -index 09d73172..f4d287b3 100644 ---- a/drivers/dahdi/dahdi-sysfs-chan.c -+++ b/drivers/dahdi/dahdi-sysfs-chan.c -@@ -484,15 +484,18 @@ int __init dahdi_sysfs_chan_init(const struct file_operations *fops) - should_cleanup.channel_driver = 1; - - #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) --#if defined RHEL_RELEASE_VERSION && (RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) && \ -- RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,4) -+#if defined(RHEL_RELEASE_VERSION) && defined(RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) -+#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 4) - dahdi_class = class_create("dahdi"); - #else - dahdi_class = class_create(THIS_MODULE, "dahdi"); --#endif -+#endif /* RHEL_RELEASE_CODE */ -+#else -+ dahdi_class = class_create(THIS_MODULE, "dahdi"); -+#endif /* RHEL_RELEASE_VERSION */ - #else - dahdi_class = class_create("dahdi"); --#endif -+#endif /* LINUX_VERSION_CODE */ - if (IS_ERR(dahdi_class)) { - res = PTR_ERR(dahdi_class); - dahdi_err("%s: class_create(dahi_chan) failed. Error: %d\n", -diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c -index 7477ebc9..7b302c6f 100644 ---- a/drivers/dahdi/dahdi-sysfs.c -+++ b/drivers/dahdi/dahdi-sysfs.c -@@ -69,15 +69,18 @@ static inline struct dahdi_span *dev_to_span(const struct device *dev) - } while (0) - - #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) --#if defined RHEL_RELEASE_VERSION && (RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) && \ -- RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,4) -+#if defined(RHEL_RELEASE_VERSION) && defined(RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) -+#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 4) - static int span_uevent(const struct device *dev, struct kobj_uevent_env *kenv) - #else - static int span_uevent(struct device *dev, struct kobj_uevent_env *kenv) --#endif -+#endif /* RHEL_RELEASE_CODE */ -+#else -+static int span_uevent(struct device *dev, struct kobj_uevent_env *kenv) -+#endif /* RHEL_RELEASE_VERSION */ - #else - static int span_uevent(const struct device *dev, struct kobj_uevent_env *kenv) --#endif -+#endif /* LINUX_VERSION_CODE */ - { - struct dahdi_span *span; - -@@ -448,15 +451,18 @@ static inline struct dahdi_device *to_ddev(const struct device *dev) - } while (0) - - #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) --#if defined RHEL_RELEASE_VERSION && (RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) && \ -- RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,4) -+#if defined(RHEL_RELEASE_VERSION) && defined(RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) -+#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 4) - static int device_uevent(const struct device *dev, struct kobj_uevent_env *kenv) - #else - static int device_uevent(struct device *dev, struct kobj_uevent_env *kenv) --#endif -+#endif /* RHEL_RELEASE_CODE */ -+#else -+static int device_uevent(struct device *dev, struct kobj_uevent_env *kenv) -+#endif /* RHEL_RELEASE_VERSION */ - #else - static int device_uevent(const struct device *dev, struct kobj_uevent_env *kenv) --#endif -+#endif /* LINUX_VERSION_CODE */ - { - struct dahdi_device *ddev; - -diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c -index 177048b2..897c86d8 100644 ---- a/drivers/dahdi/xpp/xbus-sysfs.c -+++ b/drivers/dahdi/xpp/xbus-sysfs.c -@@ -420,15 +420,18 @@ static int astribank_match(struct device *dev, struct device_driver *driver) - - - #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) --#if defined RHEL_RELEASE_VERSION && (RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) && \ -- RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,4) -+#if defined(RHEL_RELEASE_VERSION) && defined(RHEL_RELEASE_CODE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) -+#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 4) - static int astribank_uevent(const struct device *dev, struct kobj_uevent_env *kenv) - #else - static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv) --#endif -+#endif /* RHEL_RELEASE_CODE */ -+#else -+static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv) -+#endif /* RHEL_RELEASE_VERSION */ - #else - static int astribank_uevent(const struct device *dev, struct kobj_uevent_env *kenv) --#endif -+#endif /* LINUX_VERSION_CODE */ - { - xbus_t *xbus; - extern char *initdir; diff --git a/debian/patches/series b/debian/patches/series index c258eba..5abb70f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,6 +2,5 @@ no_firmware_download minimize-modules autop_vox -58_rhel_guard kernel_6_11_sysfs 66_empty_if