summaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/base-files/etc/hotplug.d/ieee80211/00-wifi-migration
blob: b1824303e62374c53188a7c341b9fb9ba3aec9af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

WIFI_PATH_CHANGED=0

. /lib/functions.sh

migrate_wifi_path() {
	local section="$1"
	local path

	config_get path ${section} path
	case ${path} in
		"pci0000:01/0000:01:00.0")
			board=$(board_name)

			case "$board" in
				tplink,archer-c7-v1|\
				tplink,archer-c7-v2)
					path="pci0000:00/0000:00:00.0"
					WIFI_PATH_CHANGED=1
				;;
				*)
					return 0
				;;
			esac
		;;
		"platform/qca955x_wmac")
			path="platform/ahb/ahb:apb/18100000.wmac"
			WIFI_PATH_CHANGED=1
		;;
		"platform/ar933x_wmac")
			path="platform/ahb/18100000.wmac"
			WIFI_PATH_CHANGED=1
		;;
		*)
			return 0
		;;
	esac

	uci set wireless.${section}.path=${path}
}

[ "${ACTION}" = "add" ] && {
	[ ! -e /etc/config/wireless ] && return 0

	config_load wireless
	config_foreach migrate_wifi_path wifi-device

	[ "${WIFI_PATH_CHANGED}" = "1" ] && uci commit wireless
}