summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShiji Yang2025-06-17 23:39:57 +0000
committerHauke Mehrtens2025-07-14 20:30:20 +0000
commit2f944ecd3eabc78d428a122b9ff00e26af1a9d01 (patch)
tree5b058b7799e1f45f480064be725da752a412c5d4
parenta0fe3cfb62fbf0b5f599c90e488727f493223429 (diff)
downloadopenwrt-2f944ecd3eabc78d428a122b9ff00e26af1a9d01.tar.gz
treewide: simplify kernel version number comparisons
Directly call the function "get_linux_version()" to get the integer kernel version number. Signed-off-by: Shiji Yang <yangshiji66@outlook.com> Link: https://github.com/openwrt/openwrt/pull/19172 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--target/linux/armsr/base-files/etc/board.d/03_gpio_switches6
-rw-r--r--target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio4
-rw-r--r--target/linux/bmips/bcm63268/base-files/etc/board.d/03_gpio_switches6
-rw-r--r--target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate11
4 files changed, 8 insertions, 19 deletions
diff --git a/target/linux/armsr/base-files/etc/board.d/03_gpio_switches b/target/linux/armsr/base-files/etc/board.d/03_gpio_switches
index 72f310277a..10c24a4201 100644
--- a/target/linux/armsr/base-files/etc/board.d/03_gpio_switches
+++ b/target/linux/armsr/base-files/etc/board.d/03_gpio_switches
@@ -1,18 +1,16 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
+. /lib/functions/system.sh
. /lib/functions/uci-defaults.sh
-KERNEL_MAJOR=$(uname -r | awk -F '.' '{print $1}')
-KERNEL_MINOR=$(uname -r | awk -F '.' '{print $2}')
-
board_config_update
board=$(board_name)
case "$board" in
traverse,ten64)
- if [ "${KERNEL_MAJOR}" -ge "6" ] && [ "${KERNEL_MINOR}" -ge "6" ]; then
+ if [ "$(get_linux_version)" -ge "606000" ]; then
I2C_GPIO_BASE=640
else
I2C_GPIO_BASE=368
diff --git a/target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio b/target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio
index dc8648e570..649b14061c 100644
--- a/target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio
+++ b/target/linux/armsr/base-files/etc/uci-defaults/05-migrate-ten64-gpio
@@ -6,6 +6,7 @@
# See https://lists.openwrt.org/pipermail/openwrt-devel/2024-March/042448.html
. /lib/functions.sh
+. /lib/functions/system.sh
ten64_update_gpioswitch_num() {
local section="$1"
@@ -26,8 +27,7 @@ if [ "${board}" != "traverse,ten64" ]; then
exit 0
fi
-KERNEL_MINOR=$(uname -r | awk -F '.' '{print $2}')
-if [ "${KERNEL_MINOR}" -lt "6" ]; then
+if [ "$(get_linux_version)" -lt "60600" ]; then
exit 0
fi
diff --git a/target/linux/bmips/bcm63268/base-files/etc/board.d/03_gpio_switches b/target/linux/bmips/bcm63268/base-files/etc/board.d/03_gpio_switches
index 2e754ad498..97a25e15dc 100644
--- a/target/linux/bmips/bcm63268/base-files/etc/board.d/03_gpio_switches
+++ b/target/linux/bmips/bcm63268/base-files/etc/board.d/03_gpio_switches
@@ -1,13 +1,11 @@
# SPDX-License-Identifier: GPL-2.0-or-later
+. /lib/functions/system.sh
. /lib/functions/uci-defaults.sh
-KERNEL_MAJOR=$(uname -r | awk -F '.' '{print $1}')
-KERNEL_MINOR=$(uname -r | awk -F '.' '{print $2}')
-
board_config_update
-if [ "${KERNEL_MAJOR}" -ge "6" ] && [ "${KERNEL_MINOR}" -ge "12" ]; then
+if [ "$(get_linux_version)" -ge "612000" ]; then
GPIO_BASE=512
else
GPIO_BASE=460
diff --git a/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate b/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate
index aa0069410a..9e8879905a 100644
--- a/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate
+++ b/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate
@@ -5,14 +5,7 @@
[ "${ACTION}" = "add" ] || return
. /lib/functions.sh
-
-check_kernel()
-{
- local kernel_current=$(uname -r)
- if [ ${kernel_current//./} -lt "6600" ]; then
- return 1
- fi
-}
+. /lib/functions/system.sh
do_migrate_radio()
{
@@ -40,7 +33,7 @@ check_path()
# Checks if kernel version is less than 6.6.0, if it is and the path is using the new format,
# then path should be migrated to the old format. This would allow users on platforms with two partitions,
# to test 6.1 and 6.6.
- check_kernel || to=${path/soc@0\//soc\/}
+ [ "$(get_linux_version)" -lt "606000" ] && to=${path/soc@0\//soc\/}
[ "$path" = "$to" ] || do_migrate_radio "$config" "$path" "$to"
}