ramips: mt7621: add migration script for WLAN PCI paths
[openwrt/staging/dedeckeh.git] / target / linux / ramips / mt7621 / base-files / etc / hotplug.d / ieee80211 / 05-wifi-migrate
1 #!/bin/sh
2
3 # This must run before 10-wifi-detect
4
5
6 [ "${ACTION}" = "add" ] || return
7
8
9 . /lib/functions.sh
10
11
12 check_radio()
13 {
14 local cfg="$1" to="$2"
15
16 config_get path "$cfg" path
17
18 [ "$path" = "$to" ] && PATH_EXISTS=true
19 }
20
21 do_migrate_radio()
22 {
23 local cfg="$1" from="$2" to="$3"
24
25 config_get path "$cfg" path
26
27 [ "$path" = "$from" ] || return
28
29 uci set "wireless.${cfg}.path=${to}"
30 WIRELESS_CHANGED=true
31
32 logger -t wifi-migrate "Updated path of wireless.${cfg} from '${from}' to '${to}'"
33 }
34
35 migrate_radio()
36 {
37 local from="$1" to="$2"
38
39 config_load wireless
40
41 # Check if there is already a section with the target path: In this case, the system
42 # was already upgraded to a version without this migration script before; better bail out,
43 # as we can't be sure we don't break more than we fix.
44 PATH_EXISTS=false
45 config_foreach check_radio wifi-device "$to"
46 $PATH_EXISTS && return
47
48 config_foreach do_migrate_radio wifi-device "$from" "$to"
49 }
50
51
52 WIRELESS_CHANGED=false
53
54 case "$(board_name)" in
55 arcadyan,we420223-99|\
56 beeline,smartbox-flash|\
57 mts,wg430223)
58 migrate_radio '1e140000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0' '1e140000.pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
59 migrate_radio '1e140000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0+1' '1e140000.pcie/pci0000:00/0000:00:01.0/0000:01:00.0+1'
60 ;;
61 netgear,r6220|\
62 netgear,wac104|\
63 netgear,wndr3700-v5)
64 migrate_radio '1e140000.pcie/pci0000:00/0000:00:01.0/0000:02:00.0' '1e140000.pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
65 ;;
66 zbtlink,zbt-we1326)
67 migrate_radio '1e140000.pcie/pci0000:00/0000:00:01.0/0000:02:00.0' '1e140000.pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
68 migrate_radio '1e140000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0' '1e140000.pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
69 ;;
70
71 esac
72
73 $WIRELESS_CHANGED && uci commit wireless
74
75 exit 0