[LEDE-DEV] [PATCH 5/5] ipq806x: migrate to generic board detect infrastructure

Roman Yeryomin leroi.lists at gmail.com
Fri Apr 28 05:57:46 PDT 2017


Signed-off-by: Roman Yeryomin <roman at advem.lv>
---
 .../linux/ipq806x/base-files/etc/board.d/01_leds   |  4 +-
 .../ipq806x/base-files/etc/board.d/02_network      |  4 +-
 target/linux/ipq806x/base-files/etc/diag.sh        | 13 +++-
 .../etc/hotplug.d/firmware/11-ath10k-caldata       |  3 +-
 .../etc/hotplug.d/ieee80211/10_fix_wifi_mac        |  4 +-
 .../ipq806x/base-files/etc/init.d/linksys_recovery |  3 +-
 .../linux/ipq806x/base-files/lib/board_detect.sh   | 60 ++++++++++++++++
 target/linux/ipq806x/base-files/lib/ipq806x.sh     | 82 ----------------------
 .../lib/preinit/03_preinit_do_ipq806x.sh           | 12 ----
 .../ipq806x/base-files/lib/upgrade/platform.sh     |  8 +--
 10 files changed, 84 insertions(+), 109 deletions(-)
 create mode 100644 target/linux/ipq806x/base-files/lib/board_detect.sh
 delete mode 100644 target/linux/ipq806x/base-files/lib/ipq806x.sh
 delete mode 100644 target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh

diff --git a/target/linux/ipq806x/base-files/etc/board.d/01_leds b/target/linux/ipq806x/base-files/etc/board.d/01_leds
index 1371767..85c94f0 100755
--- a/target/linux/ipq806x/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq806x/base-files/etc/board.d/01_leds
@@ -4,11 +4,11 @@
 #
 
 . /lib/functions/uci-defaults.sh
-. /lib/ipq806x.sh
+. /lib/functions/board.sh
 
 board_config_update
 
-board=$(ipq806x_board_name)
+board=$(board_name)
 
 case "$board" in
 c2600)
diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network
index 36e0fb3..b95bd22 100755
--- a/target/linux/ipq806x/base-files/etc/board.d/02_network
+++ b/target/linux/ipq806x/base-files/etc/board.d/02_network
@@ -5,12 +5,12 @@
 #
 
 . /lib/functions/uci-defaults.sh
-. /lib/ipq806x.sh
+. /lib/functions/board.sh
 . /lib/functions/system.sh
 
 board_config_update
 
-board=$(ipq806x_board_name)
+board=$(board_name)
 
 case "$board" in
 ap148 |\
diff --git a/target/linux/ipq806x/base-files/etc/diag.sh b/target/linux/ipq806x/base-files/etc/diag.sh
index 7c9a9d0..0d3c6b0 100755
--- a/target/linux/ipq806x/base-files/etc/diag.sh
+++ b/target/linux/ipq806x/base-files/etc/diag.sh
@@ -2,7 +2,18 @@
 # Copyright (C) 2016 Henryk Heisig hyniu at o2.pl
 
 . /lib/functions/leds.sh
-. /lib/ipq806x.sh
+
+ipq806x_get_dt_led() {
+	local label
+	local ledpath
+	local basepath="/sys/firmware/devicetree/base"
+	local nodepath="$basepath/aliases/led-$1"
+
+	[ -f "$nodepath" ] && ledpath=$(cat "$nodepath")
+	[ -n "$ledpath" ] && label=$(cat "$basepath$ledpath/label")
+
+	echo "$label"
+}
 
 boot="$(ipq806x_get_dt_led boot)"
 failsafe="$(ipq806x_get_dt_led failsafe)"
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 6526212..9d9e21d 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
@@ -38,11 +38,10 @@ ath10kcal_patch_mac() {
 
 [ -e /lib/firmware/$FIRMWARE ] && exit 0
 
-. /lib/ipq806x.sh
 . /lib/functions.sh
 . /lib/functions/system.sh
 
-board=$(ipq806x_board_name)
+board=$(board_name)
 
 
 case "$FIRMWARE" in
diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
index 2ea408d..c24a18f 100644
--- a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
+++ b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
@@ -6,10 +6,10 @@ PHYNBR=${DEVPATH##*/phy}
 
 [ -n $PHYNBR ] || exit 0
 
-. /lib/ipq806x.sh
+. /lib/functions/board.sh
 . /lib/functions/system.sh
 
-board=$(ipq806x_board_name)
+board=$(board_name)
 
 case "$board" in
 	c2600)
diff --git a/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery b/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery
index b9ea004..4d94f1f 100755
--- a/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery
+++ b/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery
@@ -4,9 +4,8 @@
 START=97
 boot() {
 . /lib/functions.sh
-. /lib/ipq806x.sh
 
-case $(ipq806x_board_name) in
+case $(board_name) in
 	ea8500)
 		# make sure auto_recovery in uboot is always on
 		AUTO_RECOVERY_ENA="`fw_printenv -n auto_recovery`"
diff --git a/target/linux/ipq806x/base-files/lib/board_detect.sh b/target/linux/ipq806x/base-files/lib/board_detect.sh
new file mode 100644
index 0000000..eb4100e
--- /dev/null
+++ b/target/linux/ipq806x/base-files/lib/board_detect.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
+# Copyright (C) 2011-2017 OpenWrt.org
+#
+
+board_detect() {
+	local IPQ806X_BOARD_NAME=
+	local IPQ806X_MODEL=
+	local machine
+	local name
+
+	machine=$(cat /proc/device-tree/model)
+
+	case "$machine" in
+	*"AP148")
+		name="ap148"
+		;;
+	*"4040")
+		name="fritz4040"
+		;;
+	*"C2600")
+		name="c2600"
+		;;
+	*"D7800")
+		name="d7800"
+		;;
+	*"DB149")
+		name="db149"
+		;;
+	*"NBG6817")
+		name="nbg6817"
+		;;
+	*"R7500")
+		name="r7500"
+		;;
+	*"R7500v2")
+		name="r7500v2"
+		;;
+	*"Linksys EA8500"*)
+		name="ea8500"
+		;;
+	*"R7800")
+		name="r7800"
+		;;
+	*"VR2600v")
+		name="vr2600v"
+		;;
+	esac
+
+	[ -z "$name" ] && name="unknown"
+
+	[ -z "$IPQ806X_BOARD_NAME" ] && IPQ806X_BOARD_NAME="$name"
+	[ -z "$IPQ806X_MODEL" ] && IPQ806X_MODEL="$machine"
+
+	[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
+
+	echo "$IPQ806X_BOARD_NAME" > /tmp/sysinfo/board_name
+	echo "$IPQ806X_MODEL" > /tmp/sysinfo/model
+}
diff --git a/target/linux/ipq806x/base-files/lib/ipq806x.sh b/target/linux/ipq806x/base-files/lib/ipq806x.sh
deleted file mode 100644
index 348a3a8..0000000
--- a/target/linux/ipq806x/base-files/lib/ipq806x.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2014 The Linux Foundation. All rights reserved.
-# Copyright (C) 2011 OpenWrt.org
-#
-
-IPQ806X_BOARD_NAME=
-IPQ806X_MODEL=
-
-ipq806x_board_detect() {
-	local machine
-	local name
-
-	machine=$(cat /proc/device-tree/model)
-
-	case "$machine" in
-	*"AP148")
-		name="ap148"
-		;;
-	*"4040")
-		name="fritz4040"
-		;;
-	*"C2600")
-		name="c2600"
-		;;
-	*"D7800")
-		name="d7800"
-		;;
-	*"DB149")
-		name="db149"
-		;;
-	*"NBG6817")
-		name="nbg6817"
-		;;
-	*"R7500")
-		name="r7500"
-		;;
-	*"R7500v2")
-		name="r7500v2"
-		;;
-	*"Linksys EA8500"*)
-		name="ea8500"
-		;;
-	*"R7800")
-		name="r7800"
-		;;
-	*"VR2600v")
-		name="vr2600v"
-		;;
-	esac
-
-	[ -z "$name" ] && name="unknown"
-
-	[ -z "$IPQ806X_BOARD_NAME" ] && IPQ806X_BOARD_NAME="$name"
-	[ -z "$IPQ806X_MODEL" ] && IPQ806X_MODEL="$machine"
-
-	[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
-
-	echo "$IPQ806X_BOARD_NAME" > /tmp/sysinfo/board_name
-	echo "$IPQ806X_MODEL" > /tmp/sysinfo/model
-}
-
-ipq806x_board_name() {
-	local name
-
-	[ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
-	[ -z "$name" ] && name="unknown"
-
-	echo "$name"
-}
-
-ipq806x_get_dt_led() {
-	local label
-	local ledpath
-	local basepath="/sys/firmware/devicetree/base"
-	local nodepath="$basepath/aliases/led-$1"
-
-	[ -f "$nodepath" ] && ledpath=$(cat "$nodepath")
-	[ -n "$ledpath" ] && label=$(cat "$basepath$ledpath/label")
-
-	echo "$label"
-}
diff --git a/target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh b/target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh
deleted file mode 100644
index 785f1eb..0000000
--- a/target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2014 The Linux Foundation. All rights reserved.
-#
-
-do_ipq806x() {
-	. /lib/ipq806x.sh
-
-	ipq806x_board_detect
-}
-
-boot_hook_add preinit_main do_ipq806x
diff --git a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
index 8970285..1e4a006 100644
--- a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
@@ -1,4 +1,4 @@
-. /lib/ipq806x.sh
+. /lib/functions/board.sh
 
 PART_NAME=firmware
 REQUIRE_IMAGE_METADATA=1
@@ -8,7 +8,7 @@ platform_check_image() {
 }
 
 platform_pre_upgrade() {
-	local board=$(ipq806x_board_name)
+	local board=$(board_name)
 
 	case "$board" in
 	ap148 |\
@@ -26,7 +26,7 @@ platform_pre_upgrade() {
 }
 
 platform_do_upgrade() {
-	local board=$(ipq806x_board_name)
+	local board=$(board_name)
 
 	case "$board" in
 	c2600)
@@ -49,7 +49,7 @@ platform_do_upgrade() {
 }
 
 platform_nand_pre_upgrade() {
-	local board=$(ipq806x_board_name)
+	local board=$(board_name)
 
 	case "$board" in
 	nbg6817)
-- 
2.7.4




More information about the Lede-dev mailing list