aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/cns3xxx
diff options
context:
space:
mode:
authorMathias Kresin <dev@kresin.me>2017-04-07 18:01:17 +0200
committerMathias Kresin <dev@kresin.me>2017-07-15 23:13:34 +0200
commit78cf5eed6edaa38561e9c9c3ff14a36c1eedfadd (patch)
tree2fcf94f7ad5e69d0ea2ef62a83365f5afd98bb6b /target/linux/cns3xxx
parentac3e05c5d757334944fbf1f14583164cd1d69172 (diff)
downloadupstream-78cf5eed6edaa38561e9c9c3ff14a36c1eedfadd.tar.gz
upstream-78cf5eed6edaa38561e9c9c3ff14a36c1eedfadd.tar.bz2
upstream-78cf5eed6edaa38561e9c9c3ff14a36c1eedfadd.zip
treewide: do board detection during preinit
Do the board detection during preinit to unify it across all targets. Signed-off-by: Mathias Kresin <dev@kresin.me>
Diffstat (limited to 'target/linux/cns3xxx')
-rw-r--r--target/linux/cns3xxx/base-files/lib/cns3xxx.sh27
-rw-r--r--target/linux/cns3xxx/base-files/lib/preinit/01_sysinfo9
2 files changed, 30 insertions, 6 deletions
diff --git a/target/linux/cns3xxx/base-files/lib/cns3xxx.sh b/target/linux/cns3xxx/base-files/lib/cns3xxx.sh
index 476f9be21d..fb2c1043e1 100644
--- a/target/linux/cns3xxx/base-files/lib/cns3xxx.sh
+++ b/target/linux/cns3xxx/base-files/lib/cns3xxx.sh
@@ -1,9 +1,9 @@
#!/bin/sh
-#
-# Copyright (C) 2012 OpenWrt.org
-#
-cns3xxx_board_name() {
+CNS3XXX_BOARD_NAME=
+CNS3XXX_MODEL=
+
+cns3xxx_board_detect() {
local machine
local name
@@ -17,6 +17,21 @@ cns3xxx_board_name() {
name="generic";
;;
esac
-
- echo $name
+
+ [ -z "$CNS3XXX_BOARD_NAME" ] && CNS3XXX_BOARD_NAME="$name"
+ [ -z "$CNS3XXX_MODEL" ] && CNS3XXX_MODEL="$machine"
+
+ [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
+
+ echo "$CNS3XXX_BOARD_NAME" > /tmp/sysinfo/board_name
+ echo "$CNS3XXX_MODEL" > /tmp/sysinfo/model
+}
+
+cns3xxx_board_name() {
+ local name
+
+ [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
+ [ -z "$name" ] && name="unknown"
+
+ echo "$name"
}
diff --git a/target/linux/cns3xxx/base-files/lib/preinit/01_sysinfo b/target/linux/cns3xxx/base-files/lib/preinit/01_sysinfo
new file mode 100644
index 0000000000..cc7b5551e9
--- /dev/null
+++ b/target/linux/cns3xxx/base-files/lib/preinit/01_sysinfo
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_sysinfo_cns3xxx() {
+ . /lib/cns3xxx.sh
+
+ cns3xxx_board_detect
+}
+
+boot_hook_add preinit_main do_sysinfo_cns3xxx