ar71xx: change user-space board detection
authorGabor Juhos <juhosg@openwrt.org>
Mon, 5 Dec 2011 12:56:20 +0000 (12:56 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Mon, 5 Dec 2011 12:56:20 +0000 (12:56 +0000)
SVN-Revision: 29432

target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/preinit/03_preinit_do_ar71xx.sh

index 314b44e4728cfbe138def3203f7a898b76a3fcf8..02286e9aabe10ca08f43616cd1192f78c31c1bc0 100755 (executable)
@@ -1,9 +1,12 @@
 #!/bin/sh
 #
-# Copyright (C) 2009 OpenWrt.org
+# Copyright (C) 2009-2011 OpenWrt.org
 #
 
-ar71xx_board_name() {
+AR71XX_BOARD_NAME=
+AR71XX_MODEL=
+
+ar71xx_board_detect() {
        local machine
        local name
 
@@ -199,10 +202,24 @@ ar71xx_board_name() {
        *ZCN-1523H-5)
                name="zcn-1523h-5"
                ;;
-       *)
-               name="generic"
-               ;;
        esac
 
-       echo $name
+       [ -z "$name" ] && name="unknown"
+
+       [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
+       [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
+
+       [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
+
+       echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
+       echo "$AR71XX_MODEL" > /tmp/sysinfo/model
+}
+
+ar71xx_board_name() {
+       local name
+
+       [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
+       [ -z "$name" ] && name="unknown"
+
+       echo "$name"
 }
index 367648929b3c0c071b9797f92f63605c49037326..ff5407a0d4041a2eada93f7904f176f138665107 100644 (file)
@@ -2,6 +2,8 @@
 
 do_ar71xx() {
        . /lib/ar71xx.sh
+
+       ar71xx_board_detect
 }
 
 boot_hook_add preinit_main do_ar71xx