ath79: add WiFi migration for AR913x
[openwrt/staging/rmilecki.git] / target / linux / ath79 / base-files / etc / hotplug.d / ieee80211 / 00-wifi-migration
1 #!/bin/sh
2
3 WIFI_PATH_CHANGED=0
4
5 . /lib/functions.sh
6
7 migrate_wifi_path() {
8 local section="$1"
9 local path
10
11 config_get path ${section} path
12 case ${path} in
13 "pci0000:01/0000:01:00.0")
14 board=$(board_name)
15
16 case "$board" in
17 tplink,archer-c7-v1|\
18 tplink,archer-c7-v2|\
19 zyxel,nbg6716)
20 path="pci0000:00/0000:00:00.0"
21 WIFI_PATH_CHANGED=1
22 ;;
23 *)
24 return 0
25 ;;
26 esac
27 ;;
28 "platform/ahb/ahb:apb/18100000.wmac"|\
29 "platform/ar933x_wmac"|\
30 "platform/ar934x_wmac"|\
31 "platform/qca953x_wmac"|\
32 "platform/qca955x_wmac"|\
33 "platform/qca956x_wmac")
34 path="platform/ahb/18100000.wmac"
35 WIFI_PATH_CHANGED=1
36 ;;
37 "platform/ath9k")
38 path="platform/ahb/180c0000.wmac"
39 WIFI_PATH_CHANGED=1
40 ;;
41 *)
42 return 0
43 ;;
44 esac
45
46 uci set wireless.${section}.path=${path}
47 }
48
49 [ "${ACTION}" = "add" ] && {
50 [ ! -e /etc/config/wireless ] && return 0
51
52 config_load wireless
53 config_foreach migrate_wifi_path wifi-device
54
55 [ "${WIFI_PATH_CHANGED}" = "1" ] && uci commit wireless
56 }