qualcommax: ipq807x: add WLAN device path migration

Kernel 6.6 has changed the path of WLAN devices as the soc node was updated
to include an adress as well because according to spec it needed one:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/arch/arm64/boot/dts/qcom/ipq8074.dtsi?h=v6.6.21&id=da6aa1111a17db11367817ddc10c5a6c188cdc44

So, this will break existing configuration as device path was changed for
example:
"platform/soc/c000000.wifi" to "platform/soc@0/c000000.wifi"
"platform/soc/c000000.wifi+1" to "platform/soc@0/c000000.wifi+1"

PCIe attached devices also have their path changed, so lets add a script
that will migrate the paths based on the detected running kernel version
so returning to kernel 6.1 will work as well.

Co-developed-by: Sean Khan <datapronix@protonmail.com>
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Robert Marko 2024-03-09 11:22:05 +01:00
parent d9a2886263
commit 4989556a53
1 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,68 @@
#!/bin/sh
# This must run before 10-wifi-detect
[ "${ACTION}" = "add" ] || return
. /lib/functions.sh
check_kernel()
{
local kernel_current=$(uname -r)
if [ ${kernel_current//./} -lt "6600" ]; then
return 1
fi
}
do_migrate_radio()
{
local cfg="$1" from="$2" to="$3"
config_get path "$cfg" path
[ "$path" = "$from" ] || return
uci set "wireless.${cfg}.path=${to}"
WIRELESS_CHANGED=true
logger -t wifi-migrate "Updated path of wireless.${cfg} from '${from}' to '${to}'"
}
check_path()
{
local config
config="$1"
config_get path "$config" path
to=${path/soc\//soc@0\/}
# 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\/}
[ "$path" = "$to" ] || do_migrate_radio "$config" "$path" "$to"
}
migrate_radio()
{
config_load wireless
# Check if there is already a section with the target path: In this case, the system
# was already upgraded to a version without this migration script before; better bail out,
# as we can't be sure we don't break more than we fix.
config_foreach check_path wifi-device
}
WIRELESS_CHANGED=false
case "$(board_name)" in
*)
migrate_radio
;;
esac
$WIRELESS_CHANGED && uci commit wireless
exit 0