diff options
author | Mathias Kresin <dev@kresin.me> | 2017-04-07 18:01:17 +0200 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2017-07-15 23:13:34 +0200 |
commit | 78cf5eed6edaa38561e9c9c3ff14a36c1eedfadd (patch) | |
tree | 2fcf94f7ad5e69d0ea2ef62a83365f5afd98bb6b /target/linux/ixp4xx | |
parent | ac3e05c5d757334944fbf1f14583164cd1d69172 (diff) | |
download | upstream-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/ixp4xx')
-rw-r--r-- | target/linux/ixp4xx/base-files/lib/ixp4xx.sh | 50 | ||||
-rw-r--r-- | target/linux/ixp4xx/base-files/lib/preinit/01_sysinfo | 9 |
2 files changed, 43 insertions, 16 deletions
diff --git a/target/linux/ixp4xx/base-files/lib/ixp4xx.sh b/target/linux/ixp4xx/base-files/lib/ixp4xx.sh index f7a6b76eda..7486356b9c 100644 --- a/target/linux/ixp4xx/base-files/lib/ixp4xx.sh +++ b/target/linux/ixp4xx/base-files/lib/ixp4xx.sh @@ -3,23 +3,41 @@ # Copyright (C) 2012 OpenWrt.org # -ixp4xx_board_name() { - local machine - local name - - machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /Hardware/ {print $2}' /proc/cpuinfo) - - case "$machine" in - "Gateworks Cambria"*) - name="cambria" - ;; - "Gateworks Avila"*) - name="avila" - ;; - *) - name="generic"; - ;; +IXP4XX_BOARD_NAME= +IXP4XX_MODEL= + +ixp4xx_board_detect() { + local machine + local name + + machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /Hardware/ {print $2}' /proc/cpuinfo) + + case "$machine" in + "Gateworks Cambria"*) + name="cambria" + ;; + "Gateworks Avila"*) + name="avila" + ;; + *) + name="generic"; + ;; esac + [ -z "$IXP4XX_BOARD_NAME" ] && IXP4XX_BOARD_NAME="$name" + [ -z "$IXP4XX_MODEL" ] && IXP4XX_MODEL="$machine" + + [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" + + echo "$IXP4XX_BOARD_NAME" > /tmp/sysinfo/board_name + echo "$IXP4XX_MODEL" > /tmp/sysinfo/model +} + +ixp4xx_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/ixp4xx/base-files/lib/preinit/01_sysinfo b/target/linux/ixp4xx/base-files/lib/preinit/01_sysinfo new file mode 100644 index 0000000000..7699e9a10e --- /dev/null +++ b/target/linux/ixp4xx/base-files/lib/preinit/01_sysinfo @@ -0,0 +1,9 @@ +#!/bin/sh + +do_sysinfo_ixp4xx() { + . /lib/ixp4xx.sh + + ixp4xx_board_detect +} + +boot_hook_add preinit_main do_sysinfo_ixp4xx |