From 6cd68c811ecb145d4258ce6be99dba3e507b294f Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 16 Jul 2014 10:31:21 +0200 Subject: fpga: xilinx: Check if fpga operations are defined Ensure that operations are correctly setup. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- drivers/fpga/xilinx.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'drivers/fpga') diff --git a/drivers/fpga/xilinx.c b/drivers/fpga/xilinx.c index adb4b8cd25..9c95148b25 100644 --- a/drivers/fpga/xilinx.c +++ b/drivers/fpga/xilinx.c @@ -139,6 +139,11 @@ int xilinx_load(xilinx_desc *desc, const void *buf, size_t bsize, return FPGA_FAIL; } + if (!desc->operations || !desc->operations->load) { + printf("%s: Missing load operation\n", __func__); + return FPGA_FAIL; + } + return desc->operations->load(desc, buf, bsize, bstype); } @@ -151,8 +156,10 @@ int xilinx_loadfs(xilinx_desc *desc, const void *buf, size_t bsize, return FPGA_FAIL; } - if (!desc->operations->loadfs) + if (!desc->operations || !desc->operations->loadfs) { + printf("%s: Missing loadfs operation\n", __func__); return FPGA_FAIL; + } return desc->operations->loadfs(desc, buf, bsize, fpga_fsinfo); } @@ -165,6 +172,11 @@ int xilinx_dump(xilinx_desc *desc, const void *buf, size_t bsize) return FPGA_FAIL; } + if (!desc->operations || !desc->operations->dump) { + printf("%s: Missing dump operation\n", __func__); + return FPGA_FAIL; + } + return desc->operations->dump(desc, buf, bsize); } @@ -228,7 +240,8 @@ int xilinx_info(xilinx_desc *desc) if (desc->iface_fns) { printf ("Device Function Table @ 0x%p\n", desc->iface_fns); - desc->operations->info(desc); + if (desc->operations && desc->operations->info) + desc->operations->info(desc); } else printf ("No Device Function Table.\n"); -- cgit v1.2.1