summaryrefslogtreecommitdiff
path: root/board/toradex/common/tdx-cfg-block.c
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2018-08-06 09:19:18 +0200
committerStefano Babic <sbabic@denx.de>2018-09-04 08:47:23 +0200
commitbc53fb19fef1afbd7b328ea72de5be313016f585 (patch)
treec89fddc0ba5fba517e12f7b056c77df06701baef /board/toradex/common/tdx-cfg-block.c
parent57b620255e726fae38e5e2ac5c7dec4b9011ffca (diff)
board: toradex: common: fail gracefully on missing NAND chip
If the NAND chip is missing get_nand_dev_by_index() returns NULL. Fail gracefully in this case. Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Diffstat (limited to 'board/toradex/common/tdx-cfg-block.c')
-rw-r--r--board/toradex/common/tdx-cfg-block.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 57edb6c5c9..d4f5b1803a 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -156,10 +156,13 @@ out:
static int read_tdx_cfg_block_from_nand(unsigned char *config_block)
{
size_t size = TDX_CFG_BLOCK_MAX_SIZE;
+ struct mtd_info *mtd = get_nand_dev_by_index(0);
+
+ if (!mtd)
+ return -ENODEV;
/* Read production parameter config block from NAND page */
- return nand_read_skip_bad(get_nand_dev_by_index(0),
- CONFIG_TDX_CFG_BLOCK_OFFSET,
+ return nand_read_skip_bad(mtd, CONFIG_TDX_CFG_BLOCK_OFFSET,
&size, NULL, TDX_CFG_BLOCK_MAX_SIZE,
config_block);
}