openwrt/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
Adrian Schmutzler 5b6a809092 treewide: move calibration data extraction function to library
This moves the almost identical calibration data extraction
functions present multiple times in several targets to a single
library file /lib/functions/caldata.sh.

Functions are renamed with more generic names to merge different
variants that only differ in their names.

Most of the targets used find_mtd_chardev, while some used
find_mtd_part inside the extraction code. To merge them, the more
abundant version with find_mtd_chardev is used in the common code.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
[rebase on latest master; add mpc85xx]
Signed-off-by: David Bauer <mail@david-bauer.net>
2019-10-13 21:48:58 +02:00

54 lines
1.0 KiB
Bash

#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
ath9k_patch_firmware_mac() {
local mac=$1
[ -z "$mac" ] && return
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6
}
board=$(board_name)
case "$FIRMWARE" in
"pci_wmac0.eeprom")
case $board in
netgear,wndr4700)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
caldata_extract_ubi "caldata" 0x5000 0x1000
else
caldata_extract "wifi_data" 0x5000 0x1000
ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0xc)
fi
;;
*)
caldata_die "board $board is not supported yet"
;;
esac
;;
"pci_wmac1.eeprom")
case $board in
netgear,wndr4700)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
caldata_extract_ubi "caldata" 0x1000 0x1000
else
caldata_extract "wifi_data" 0x1000 0x1000
ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0x0)
fi
;;
*)
caldata_die "board $board is not supported yet"
;;
esac
;;
esac