[U-Boot] [PATCH 4/4] cmd: fpga: Return values of type command_ret_t only

Michal Simek michal.simek at xilinx.com
Tue Apr 16 10:59:29 UTC 2019


On 11. 04. 19 12:18, Alexander Dahl wrote:
> Passing on a return value of -1 from a called function leads to printing
> out usage text. In case of actually correct usage with correctly
> specified parameters but some fail at runtime printing out that usage
> text is distracting.
> 
> The reason is most 'fpga_' functions return either FPGA_SUCCESS or
> FPGA_FAIL, the latter is equal to -1 which is the same value as
> CMD_RET_USAGE. So just passing on FPGA_FAIL leads to printing out usage.
> 
> We should only return CMD_RET_USAGE in cases, where the user sent wrong
> input. Every other case should return CMD_RET_SUCCESS or
> CMD_RET_FAILURE, and not simply pass an error code.
> 
> Signed-off-by: Alexander Dahl <ada at thorsis.com>

This should be enough to ensure the same. Please test.

M

diff --git a/include/fpga.h b/include/fpga.h
index 51de5c55f830..ec5144334df1 100644
--- a/include/fpga.h
+++ b/include/fpga.h
@@ -15,7 +15,7 @@

 /* fpga_xxxx function return value definitions */
 #define FPGA_SUCCESS           0
-#define FPGA_FAIL              -1
+#define FPGA_FAIL              1

 /* device numbers must be non-negative */
 #define FPGA_INVALID_DEVICE    -1



More information about the U-Boot mailing list