From patchwork Wed Dec 24 03:01:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 423841 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 963091400B7 for ; Wed, 24 Dec 2014 14:02:07 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DE52A4B69C; Wed, 24 Dec 2014 04:02:02 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q+M2ZAqiFOvo; Wed, 24 Dec 2014 04:02:02 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0477B4B693; Wed, 24 Dec 2014 04:02:02 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 893664B693 for ; Wed, 24 Dec 2014 04:01:57 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ErDGQIra4Q4I for ; Wed, 24 Dec 2014 04:01:57 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id 494354B692 for ; Wed, 24 Dec 2014 04:01:53 +0100 (CET) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 2C8666309; Tue, 23 Dec 2014 20:01:52 -0700 (MST) Received: from dart.wwwdotorg.org (localhost [127.0.0.1]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 2CFB9E4636; Tue, 23 Dec 2014 20:01:51 -0700 (MST) From: Stephen Warren To: Tom Rini Date: Tue, 23 Dec 2014 20:01:44 -0700 Message-Id: <1419390104-15590-2-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1419390104-15590-1-git-send-email-swarren@wwwdotorg.org> References: <1419390104-15590-1-git-send-email-swarren@wwwdotorg.org> X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.98.1 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/2] ARM: rpi: consolidate board rev error checking X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Create a fake model table entry with default values, so we can error check the board rev value once when querying it from the firmware, rather than error-checking for invalid board rev values every time the model table is used. Signed-off-by: Stephen Warren --- board/raspberrypi/rpi/rpi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 6227e9bc12bd..c18271fce823 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -84,6 +84,11 @@ static const struct { const char *fdtfile; bool has_onboard_eth; } models[] = { + [0] = { + "Unknown model", + "bcm2835-rpi-other.dtb", + false, + }, [BCM2835_BOARD_REV_B_I2C0_2] = { "Model B (no P5)", "bcm2835-rpi-b-i2c0.dtb", @@ -185,9 +190,6 @@ static void set_fdtfile(void) return; fdtfile = models[rpi_board_rev].fdtfile; - if (!fdtfile) - fdtfile = "bcm2835-rpi-other.dtb"; - setenv("fdtfile", fdtfile); } @@ -270,12 +272,12 @@ static void get_board_rev(void) rpi_board_rev); rpi_board_rev = 0; } - - name = models[rpi_board_rev].name; - if (!name) { + if (!models[rpi_board_rev].name) { printf("RPI: Board rev %u unknown\n", rpi_board_rev); - name = "Unknown model"; + rpi_board_rev = 0; } + + name = models[rpi_board_rev].name; printf("RPI model: %s\n", name); }