aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-09-04 21:27:27 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-09-04 21:27:27 +0200
commitb452af23a8602ebf7bfb0eb084383ecd595face5 (patch)
tree81cb472d3c63a03022ac8adf25cd780544078eca /target/linux
parent967d6460c02810c9f4ec6f8c6894057995a03bf9 (diff)
downloadupstream-b452af23a8602ebf7bfb0eb084383ecd595face5.tar.gz
upstream-b452af23a8602ebf7bfb0eb084383ecd595face5.tar.bz2
upstream-b452af23a8602ebf7bfb0eb084383ecd595face5.zip
mpc85xx: add migration script for TP-Link TL-WDR4900 v1 WLAN PCI paths
PCI paths of the WLAN devices have changed between kernel 4.4 and 4.9; migrate config so existing wifi-iface definitions don't break. This is implemented as a hotplug handler rather than a uci-defaults script as the migration script must run before the 10-wifi-detect hotplug handler. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/mpc85xx/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate63
1 files changed, 63 insertions, 0 deletions
diff --git a/target/linux/mpc85xx/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate b/target/linux/mpc85xx/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate
new file mode 100644
index 0000000000..49dde052f2
--- /dev/null
+++ b/target/linux/mpc85xx/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+# This must run before 10-wifi-detect
+
+
+[ "${ACTION}" = "add" ] || return
+
+
+. /lib/functions.sh
+
+
+check_radio()
+{
+ local cfg="$1" to="$2"
+
+ config_get path "$cfg" path
+
+ [ "$path" = "$to" ] && PATH_EXISTS=true
+}
+
+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}'"
+}
+
+migrate_radio()
+{
+ local from="$1" to="$2"
+
+ 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.
+ PATH_EXISTS=false
+ config_foreach check_radio wifi-device "$to"
+ $PATH_EXISTS && return
+
+ config_foreach do_migrate_radio wifi-device "$from" "$to"
+}
+
+
+WIRELESS_CHANGED=false
+
+case "$(board_name)" in
+tplink,tl-wdr4900-v1)
+ migrate_radio 'ffe09000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0' 'ffe09000.pcie/pci9000:00/9000:00:00.0/9000:01:00.0'
+ migrate_radio 'ffe0a000.pcie/pci0001:02/0001:02:00.0/0001:03:00.0' 'ffe0a000.pcie/pcia000:02/a000:02:00.0/a000:03:00.0'
+ ;;
+esac
+
+$WIRELESS_CHANGED && uci commit wireless
+
+exit 0