Skip to content

Commit

Permalink
fix: detect Rockchip kernel and their shenanigans
Browse files Browse the repository at this point in the history
Closes radxa-pkg#3.

Signed-off-by: ZHANG Yuntian <[email protected]>
  • Loading branch information
RadxaYuntian committed Mar 28, 2024
1 parent 94c6331 commit 75f304c
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions debian/patches/fix-linux-6.1-build.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ index 107e151..a8d2e05 100644
"\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n",
__func__);
wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
+ /* From kernel 6.1.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+ /* From kernel 6.5.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU))
wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */
wiphy_apply_custom_regulatory(wiphy, regdomain);
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
memcpy(country_code, default_ccode, sizeof(default_ccode));
Expand All @@ -18,10 +18,10 @@ index 107e151..a8d2e05 100644
__func__);
wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
- wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+ /* From kernel 6.1.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+ /* From kernel 6.5.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU))
+ wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */
wiphy_apply_custom_regulatory(wiphy, &rwnx_regdom);
#endif
// Check if custom channel set shall be enabled. In such case only monitor mode is
Expand All @@ -30,10 +30,10 @@ index 107e151..a8d2e05 100644
return;

- wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+ /* From kernel 6.1.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+ /* From kernel 6.5.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU))
+ wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */
wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED;

rtnl_lock();
Expand All @@ -45,10 +45,10 @@ index 4aa6eba..3d16e63 100644
"\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n",
__func__);
wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
+ /* From kernel 6.1.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+ /* From kernel 6.5.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU))
wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */
wiphy_apply_custom_regulatory(wiphy, regdomain);
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
memcpy(country_code, default_ccode, sizeof(default_ccode));
Expand All @@ -57,10 +57,10 @@ index 4aa6eba..3d16e63 100644
__func__);
wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
- wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+ /* From kernel 6.1.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+ /* From kernel 6.5.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU))
+ wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */
wiphy_apply_custom_regulatory(wiphy, &rwnx_regdom);
#endif
// Check if custom channel set shall be enabled. In such case only monitor mode is
Expand All @@ -71,10 +71,10 @@ index 4aa6eba..3d16e63 100644
-
- wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+
+ /* From kernel 6.1.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+ /* From kernel 6.5.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU))
+ wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */
wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED;

rtnl_lock();
Expand All @@ -86,21 +86,21 @@ index 146bba6..a4befec 100644
"\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n",
__func__);
wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
+ /* From kernel 6.1.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+ /* From kernel 6.5.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU))
wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */
wiphy_apply_custom_regulatory(wiphy, regdomain);
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
memcpy(country_code, default_ccode, sizeof(default_ccode));
@@ -1744,7 +1747,10 @@ void rwnx_custregd(struct rwnx_hw *rwnx_hw, struct wiphy *wiphy)
// registration (in rwnx_set_wiphy_params()), so nothing has to be done here

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
+ /* From kernel 6.1.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
+ /* From kernel 6.5.0, this bit is removed and will be reused later */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU))
wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */
wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED;

if (!rwnx_hw->mod_params->custregd)

0 comments on commit 75f304c

Please sign in to comment.