From 78cf5eed6edaa38561e9c9c3ff14a36c1eedfadd Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Fri, 7 Apr 2017 18:01:17 +0200 Subject: treewide: do board detection during preinit Do the board detection during preinit to unify it across all targets. Signed-off-by: Mathias Kresin --- target/linux/cns3xxx/base-files/lib/cns3xxx.sh | 27 +++++++++++++++++----- .../cns3xxx/base-files/lib/preinit/01_sysinfo | 9 ++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 target/linux/cns3xxx/base-files/lib/preinit/01_sysinfo (limited to 'target/linux/cns3xxx/base-files') 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 -- cgit v1.2.3