NAND/TCL: prepare for common "target" reference
authorAntonio Borneo <borneo.antonio@gmail.com>
Fri, 31 Dec 2010 11:46:01 +0000 (19:46 +0800)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Sun, 2 Jan 2011 18:56:59 +0000 (19:56 +0100)
Every NAND driver keeps private copy of "target"
structure.
Prepare infostructure to move private "target"
copy in common/shared struct nand_device.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
src/flash/nand/core.h
src/flash/nand/tcl.c

index 709c37b389142b9c5c48356b3a0e50a79762ddd7..73fd0edd118703179c3a687811086249ef726db3 100644 (file)
@@ -60,6 +60,7 @@ struct nand_ecclayout {
 struct nand_device
 {
        const char *name;
+       struct target *target;
        struct nand_flash_controller *controller;
        void *controller_priv;
        struct nand_manufacturer *manufacturer;
index 70584fff52c35b439da849b42fe78c709e79bff2..e4bfb4d1c9f21c8c89d96a50010041a3c2ce4ae0 100644 (file)
@@ -27,6 +27,7 @@
 #include "core.h"
 #include "imp.h"
 #include "fileio.h"
+#include <target/target.h>
 
 // to be removed
 extern struct nand_device *nand_devices;
@@ -537,16 +538,37 @@ COMMAND_HANDLER(handle_nand_list_drivers)
 static COMMAND_HELPER(create_nand_device, const char *bank_name,
                struct nand_flash_controller *controller)
 {
+       struct nand_device *c;
+       struct target *target;
+       int retval;
+
+       if (CMD_ARGC < 2)
+       {
+               LOG_ERROR("missing target");
+               return ERROR_COMMAND_ARGUMENT_INVALID;
+       }
+       target = get_target(CMD_ARGV[1]);
+       if (!target) {
+               LOG_ERROR("invalid target %s", CMD_ARGV[1]);
+               return ERROR_COMMAND_ARGUMENT_INVALID;
+       }
+
        if (NULL != controller->commands)
        {
-               int retval = register_commands(CMD_CTX, NULL,
+               retval = register_commands(CMD_CTX, NULL,
                                controller->commands);
                if (ERROR_OK != retval)
                        return retval;
        }
-       struct nand_device *c = malloc(sizeof(struct nand_device));
+       c = malloc(sizeof(struct nand_device));
+       if (c == NULL)
+       {
+               LOG_ERROR("End of memory");
+               return ERROR_FAIL;
+       }
 
        c->name = strdup(bank_name);
+       c->target = target;
        c->controller = controller;
        c->controller_priv = NULL;
        c->manufacturer = NULL;
@@ -557,7 +579,7 @@ static COMMAND_HELPER(create_nand_device, const char *bank_name,
        c->use_raw = 0;
        c->next = NULL;
 
-       int retval = CALL_COMMAND_HANDLER(controller->nand_device_command, c);
+       retval = CALL_COMMAND_HANDLER(controller->nand_device_command, c);
        if (ERROR_OK != retval)
        {
                LOG_ERROR("'%s' driver rejected nand flash", controller->name);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)