diff mbox

[U-Boot,2/2] ARM: rpi: consolidate board rev error checking

Message ID 1419390104-15590-2-git-send-email-swarren@wwwdotorg.org
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Stephen Warren Dec. 24, 2014, 3:01 a.m. UTC
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 <swarren@wwwdotorg.org>
---
 board/raspberrypi/rpi/rpi.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Tom Rini Dec. 30, 2014, 2:27 a.m. UTC | #1
On Tue, Dec 23, 2014 at 08:01:44PM -0700, Stephen Warren wrote:

> 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 <swarren@wwwdotorg.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

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);
 }