]> git.sur5r.net Git - openocd/commitdiff
flash: introduce .usage field for nand and nor flash driver structure
authorØyvind Harboe <oyvind.harboe@zylin.com>
Wed, 28 Dec 2011 12:10:52 +0000 (13:10 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Wed, 4 Jan 2012 17:15:03 +0000 (17:15 +0000)
Change-Id: I47e7ec8fa8c70d2addc3aa52d7c97e9e1e7bb662
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/301
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/flash/nand/driver.h
src/flash/nand/tcl.c
src/flash/nor/driver.h

index 4edce9fab1d3b75c96111acf982b86a57d1e1689..04ec64fcfbdd2869af213fa31a2e2719fe85b637 100644 (file)
@@ -37,6 +37,9 @@ struct nand_flash_controller
        /** Driver name that is used to select it from configuration files. */
        const char *name;
 
+       /** Usage of flash command registration. */
+       const char *usage;
+
     const struct command_registration *commands;
 
        /** NAND device command called when driver is instantiated during configuration. */
index 5fba1bcc93d61e35852b77b39c2a8c2d0415de5a..c6ea3f3b68af914013dca748a6fd550b3233280c 100644 (file)
@@ -544,8 +544,7 @@ static COMMAND_HELPER(create_nand_device, const char *bank_name,
 
        if (CMD_ARGC < 2)
        {
-               LOG_ERROR("missing target");
-               return ERROR_COMMAND_ARGUMENT_INVALID;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
        target = get_target(CMD_ARGV[1]);
        if (!target) {
@@ -582,9 +581,12 @@ static COMMAND_HELPER(create_nand_device, const char *bank_name,
        retval = CALL_COMMAND_HANDLER(controller->nand_device_command, c);
        if (ERROR_OK != retval)
        {
-               LOG_ERROR("'%s' driver rejected nand flash", controller->name);
+               assert(controller->usage != NULL);
+               LOG_ERROR("'%s' driver rejected nand flash. Usage: %s",
+                       controller->name,
+                       controller->usage);
                free(c);
-               return ERROR_OK;
+               return retval;
        }
 
        nand_device_add(c);
@@ -596,8 +598,7 @@ COMMAND_HANDLER(handle_nand_device_command)
 {
        if (CMD_ARGC < 2)
        {
-               LOG_ERROR("incomplete nand device configuration");
-               return ERROR_FLASH_BANK_INVALID;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        // save name and increment (for compatibility) with drivers
index afd05285a2766fcd9f3e586a1d7338a8740b0fc5..3b8e31a004cee483ec236e41a77203f291d991c3 100644 (file)
@@ -56,6 +56,11 @@ struct flash_driver
         */
        const char *name;
 
+       /**
+        * Gives a human-readable description of arguments.
+        */
+       const char *usage;
+
        /**
         * An array of driver-specific commands to register.  When called
         * during the "flash bank" command, the driver can register addition