From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Sakoman Date: Mon, 16 Aug 2010 14:30:38 -0700 Subject: [U-Boot] [PATCH - RFC] env_nand.c: fail gracefully if no nand is present Message-ID: <1281994238.2052.37.camel@quadra> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Rationale: The upcoming Beagle xM, unlike previous Beagles, has no on-board NAND. I'd like to continue to have a single version of u-boot that works for all version of Beagles. Therefore I need to have env_nand fail gracefully when it runs on the xM. The patch below does the job, but I am not sure that my method of checking for the existence of nand (nand_info[0].type = 0 when no nand detected) is "correct"? Any opinions or advice? Steve --- diff --git a/common/env_nand.c b/common/env_nand.c index a15a950..325f112 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -268,6 +268,10 @@ int readenv (size_t offset, u_char * buf) u_char *char_ptr; + /* fail if no nand detected */ + if (nand_info[0].type == 0) + return 1; + blocksize = nand_info[0].erasesize; len = min(blocksize, CONFIG_ENV_SIZE);