aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-09-28 15:12:55 +0200
committerDavid Bauer <mail@david-bauer.net>2019-10-13 19:03:57 +0200
commitc1388a2deb00b65ee4a06c0a1d4c461f2194ef38 (patch)
treecb5d3c0aec1212d942d41b0315674110d37db528
parentbba6646b5cba591946b3fd0caaad79cb6ec78043 (diff)
downloadupstream-c1388a2deb00b65ee4a06c0a1d4c461f2194ef38.tar.gz
upstream-c1388a2deb00b65ee4a06c0a1d4c461f2194ef38.tar.bz2
upstream-c1388a2deb00b65ee4a06c0a1d4c461f2194ef38.zip
base-files: move xor() from caldata extraction to functions.sh
The xor() function is defined in each of the caldata extraction scripts for several targets. Move it to functions.sh to reduce duplicate code. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
-rwxr-xr-xpackage/base-files/files/lib/functions.sh16
-rw-r--r--target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom15
-rw-r--r--target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata18
-rw-r--r--target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata17
-rw-r--r--target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata17
-rw-r--r--target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom16
6 files changed, 19 insertions, 80 deletions
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 860fc04510..81176431d1 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -17,6 +17,22 @@ NO_EXPORT=1
LOAD_STATE=1
LIST_SEP=" "
+# xor multiple hex values of the same length
+xor() {
+ local val
+ local ret="0x$1"
+ local retlen=${#1}
+
+ shift
+ while [ -n "$1" ]; do
+ val="0x$1"
+ ret=$((ret ^ val))
+ shift
+ done
+
+ printf "%0${retlen}x" "$ret"
+}
+
append() {
local var="$1"
local value="$2"
diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 7911d0aa1e..0cdd783315 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -42,21 +42,6 @@ ath9k_eeprom_extract_reverse() {
printf "%b" "$caldata" > /lib/firmware/$FIRMWARE
}
-xor() {
- local val
- local ret="0x$1"
- local retlen=${#1}
-
- shift
- while [ -n "$1" ]; do
- val="0x$1"
- ret=$((ret ^ val))
- shift
- done
-
- printf "%0${retlen}x" "$ret"
-}
-
ath9k_patch_fw_mac() {
local mac=$1
local mac_offset=$(($2))
diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 0aa8f3d918..3844481f5a 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -1,23 +1,8 @@
#!/bin/sh
+. /lib/functions.sh
. /lib/functions/k2t.sh
-# xor multiple hex values of the same length
-xor() {
- local val
- local ret="0x$1"
- local retlen=${#1}
-
- shift
- while [ -n "$1" ]; do
- val="0x$1"
- ret=$((ret ^ val))
- shift
- done
-
- printf "%0${retlen}x" "$ret"
-}
-
ath10kcal_die() {
echo "ath10cal: " "$*"
exit 1
@@ -79,7 +64,6 @@ ath10kcal_patch_mac_crc() {
[ -e /lib/firmware/$FIRMWARE ] && exit 0
-. /lib/functions.sh
. /lib/functions/system.sh
board=$(board_name)
diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index be57646128..dfb0a0cf76 100644
--- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -1,20 +1,6 @@
#!/bin/sh
-# xor multiple hex values of the same length
-xor() {
- local val
- local ret="0x$1"
- local retlen=${#1}
-
- shift
- while [ -n "$1" ]; do
- val="0x$1"
- ret=$((ret ^ val))
- shift
- done
-
- printf "%0${retlen}x" "$ret"
-}
+. /lib/functions.sh
ath10kcal_die() {
echo "ath10cal: " "$*"
@@ -88,7 +74,6 @@ ath10kcal_is_caldata_valid() {
[ -e /lib/firmware/$FIRMWARE ] && exit 0
-. /lib/functions.sh
. /lib/functions/system.sh
board=$(board_name)
diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index bdc36070f2..c0fb1db16d 100644
--- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -1,20 +1,6 @@
#!/bin/sh
-# xor multiple hex values of the same length
-xor() {
- local val
- local ret="0x$1"
- local retlen=${#1}
-
- shift
- while [ -n "$1" ]; do
- val="0x$1"
- ret=$((ret ^ val))
- shift
- done
-
- printf "%0${retlen}x" "$ret"
-}
+. /lib/functions.sh
ath10kcal_die() {
echo "ath10cal: " "$*"
@@ -71,7 +57,6 @@ ath10kcal_patch_mac_crc() {
[ -e /lib/firmware/$FIRMWARE ] && exit 0
-. /lib/functions.sh
. /lib/functions/system.sh
board=$(board_name)
diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
index 6f133c82a7..2c4a5a1799 100644
--- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
+++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
@@ -7,22 +7,6 @@
. /lib/functions/system.sh
. /lib/upgrade/nand.sh
-# xor multiple hex values of the same length
-xor() {
- local val
- local ret="0x$1"
- local retlen=${#1}
-
- shift
- while [ -n "$1" ]; do
- val="0x$1"
- ret=$((ret ^ val))
- shift
- done
-
- printf "%0${retlen}x" "$ret"
-}
-
ath9k_eeprom_die() {
echo "ath9k eeprom: $*"
exit 1