lantiq: do not "local" variables outside of a function
[openwrt/openwrt.git] / target / linux / lantiq / base-files / etc / hotplug.d / firmware / 11-ath10k-caldata
1 #!/bin/sh
2 # Based on ar71xx 11-ath10k-caldata and 10-rt2x00-eeprom
3
4 ath10k_caldata_die() {
5 echo "ath10k caldata: " "$*"
6 exit 1
7 }
8
9 ath10k_caldata_extract() {
10 local part=$1
11 local offset=$2
12 local mtd
13
14 . /lib/functions.sh
15
16 mtd=$(find_mtd_part $part)
17 [ -n "$mtd" ] || \
18 ath10k_caldata_die "no mtd device found for partition $part"
19
20 dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=2116 || \
21 ath10k_caldata_die "failed to extract from $mtd"
22 }
23
24 ath10k_caldata_set_macaddr() {
25 local macaddr=$1
26
27 macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \
28 conv=notrunc bs=1 seek=6 count=6
29 }
30
31 [ -e /lib/firmware/$FIRMWARE ] && exit 0
32 . /lib/functions.sh
33 . /lib/functions/system.sh
34 . /lib/functions/lantiq.sh
35
36 case "$FIRMWARE" in
37 "ath10k/cal-pci-0000:02:00.0.bin")
38 board=$(lantiq_board_name)
39 case $board in
40 BTHOMEHUBV5A)
41 lan_mac=$(mtd_get_mac_binary caldata 4364)
42 wifi_mac=$(macaddr_add "$lan_mac" 3)
43 ath10k_caldata_extract "caldata" 20480
44 ath10k_caldata_set_macaddr $wifi_mac
45 ;;
46 *)
47 ath10k_caldata_die "board $board is not supported yet"
48 ;;
49 esac
50 ;;
51 esac