s3c24xx: use COMMAND_HANDLER with command helper
authorZachary T Welch <zw@superlucidity.net>
Tue, 10 Nov 2009 13:32:51 +0000 (05:32 -0800)
committerZachary T Welch <zw@superlucidity.net>
Fri, 13 Nov 2009 18:51:46 +0000 (10:51 -0800)
Add S3C24XX_DEVICE_COMMAND macros to abstract common command handler
conventions.

src/flash/s3c2410_nand.c
src/flash/s3c2412_nand.c
src/flash/s3c2440_nand.c
src/flash/s3c2443_nand.c
src/flash/s3c24xx_nand.c
src/flash/s3c24xx_nand.h
src/target/avrt.o.RcaTm5 [new file with mode: 0644]

index e663507ec7969afdfde95a06e58811c8bf21ea40..176a1a416a7be7833b6cf4801df557848221ee03 100644 (file)
@@ -35,11 +35,7 @@ static int s3c2410_nand_device_command(struct command_context_s *cmd_ctx, char *
                                struct nand_device_s *nand)
 {
        s3c24xx_nand_controller_t *info;
-
-       info = s3c24xx_nand_device_command(cmd_ctx, cmd, args, argc, nand);
-       if (info == NULL) {
-               return ERROR_NAND_DEVICE_INVALID;
-       }
+       CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
 
        /* fill in the address fields for the core device */
        info->cmd = S3C2410_NFCMD;
index 5c9d319976e8b0da9c172c12699d4d8abc62c206..7b65f84da5409586394017eb12e15d9ccecde1a0 100644 (file)
@@ -35,11 +35,7 @@ static int s3c2412_nand_device_command(struct command_context_s *cmd_ctx, char *
                                struct nand_device_s *nand)
 {
        s3c24xx_nand_controller_t *info;
-
-       info = s3c24xx_nand_device_command(cmd_ctx, cmd, args, argc, nand);
-       if (info == NULL) {
-               return ERROR_NAND_DEVICE_INVALID;
-       }
+       CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
 
        /* fill in the address fields for the core device */
        info->cmd = S3C2440_NFCMD;
index fd1fbd0acdff5999c168e82c87b94bf1ea36b498..c6d658d45eeae903193e0c0b44f6c9b7c4238bb0 100644 (file)
@@ -36,11 +36,7 @@ static int s3c2440_nand_device_command(struct command_context_s *cmd_ctx, char *
                                struct nand_device_s *nand)
 {
        s3c24xx_nand_controller_t *info;
-
-       info = s3c24xx_nand_device_command(cmd_ctx, cmd, args, argc, nand);
-       if (info == NULL) {
-               return ERROR_NAND_DEVICE_INVALID;
-       }
+       CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
 
        /* fill in the address fields for the core device */
        info->cmd = S3C2440_NFCMD;
index 82d9b8eae7bb743b05f2dc0175eaed22aca6ac5e..6e92021dfd0ea6f6afb267b5f897a8943cc304f2 100644 (file)
@@ -36,11 +36,7 @@ static int s3c2443_nand_device_command(struct command_context_s *cmd_ctx, char *
                                struct nand_device_s *nand)
 {
        s3c24xx_nand_controller_t *info;
-
-       info = s3c24xx_nand_device_command(cmd_ctx, cmd, args, argc, nand);
-       if (info == NULL) {
-               return ERROR_NAND_DEVICE_INVALID;
-       }
+       CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
 
        /* fill in the address fields for the core device */
        info->cmd = S3C2440_NFCMD;
index 59d4d5bba2a1efb8006785836c8cd1003fdae52e..e2bc00532071e900c37b5a6abf4e77dc4ff2c9ca 100644 (file)
 #include "s3c24xx_nand.h"
 
 
-s3c24xx_nand_controller_t *
-s3c24xx_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
-                           char **args, int argc,
-                           struct nand_device_s *nand)
+S3C24XX_DEVICE_COMMAND()
 {
        s3c24xx_nand_controller_t *s3c24xx_info;
 
        s3c24xx_info = malloc(sizeof(s3c24xx_nand_controller_t));
        if (s3c24xx_info == NULL) {
                LOG_ERROR("no memory for nand controller\n");
-               return NULL;
+               return -ENOMEM;
        }
 
        nand->controller_priv = s3c24xx_info;
@@ -49,10 +46,10 @@ s3c24xx_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
        s3c24xx_info->target = get_target(args[1]);
        if (s3c24xx_info->target == NULL) {
                LOG_ERROR("target '%s' not defined", args[1]);
-               return NULL;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
-       return s3c24xx_info;
+       return ERROR_OK;
 }
 
 int s3c24xx_register_commands(struct command_context_s *cmd_ctx)
index ed142954f2b371b3f201160478f968cda1a9d949..3f304a98ea807cba4fc472324e6b83ce79cb559f 100644 (file)
@@ -45,9 +45,19 @@ typedef struct s3c24xx_nand_controller_s
 #undef S3C2410_NFREG
 #define S3C2410_NFREG(x) ((x) + 0x4e000000)
 
-s3c24xx_nand_controller_t *s3c24xx_nand_device_command(
-                       struct command_context_s *cmd_ctx, char *cmd,
-                       char **args, int argc, struct nand_device_s *nand);
+#define S3C24XX_DEVICE_COMMAND() \
+               COMMAND_HELPER(s3c24xx_nand_device_command, \
+                               struct nand_device_s *nand, \
+                               s3c24xx_nand_controller_t **info)
+
+S3C24XX_DEVICE_COMMAND();
+
+#define CALL_S3C24XX_DEVICE_COMMAND(d, i) \
+       do { \
+               int retval = CALL_COMMAND_HANDLER(s3c24xx_nand_device_command, d, i); \
+               if (ERROR_OK != retval) \
+                       return retval; \
+       } while (0)
 
 int s3c24xx_register_commands(struct command_context_s *cmd_ctx);
 
diff --git a/src/target/avrt.o.RcaTm5 b/src/target/avrt.o.RcaTm5
new file mode 100644 (file)
index 0000000..e69de29

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)