flash_driver_t -> struct flash_driver
[openocd.git] / src / flash / at91sam3.c
index fda279699dfeb92fb63059aa681c29bda5cc102a..335f8ab58d30dcb6849638eedb4e3a9873af7a10 100644 (file)
@@ -1308,9 +1308,9 @@ sam3_explain_ckgr_plla(struct sam3_chip *pChip)
 static void
 sam3_explain_mckr(struct sam3_chip *pChip)
 {
-       uint32_t css, pres,fin;
-       int pdiv;
-       const char *cp;
+       uint32_t css, pres, fin = 0;
+       int pdiv = 0;
+       const char *cp = NULL;
 
        css = sam3_reg_fieldname(pChip, "CSS", pChip->cfg.PMC_MCKR, 0, 2);
        switch (css & 3) {
@@ -1609,7 +1609,7 @@ static int
 sam3_protect_check(struct flash_bank_s *bank)
 {
        int r;
-       uint32_t v;
+       uint32_t v=0;
        unsigned x;
        struct sam3_bank_private *pPrivate;
 
@@ -1641,12 +1641,7 @@ sam3_protect_check(struct flash_bank_s *bank)
        return ERROR_OK;
 }
 
-static int
-sam3_flash_bank_command(struct command_context_s *cmd_ctx,
-                           char *cmd,
-                           char **args,
-                           int argc,
-                           struct flash_bank_s *bank)
+FLASH_BANK_COMMAND_HANDLER(sam3_flash_bank_command)
 {
        struct sam3_chip *pChip;
 
@@ -2266,8 +2261,7 @@ sam3_write(struct flash_bank_s *bank,
        return r;
 }
 
-static int
-sam3_handle_info_command(struct command_context_s *cmd_ctx, char *cmd, char **argv, int argc)
+COMMAND_HANDLER(sam3_handle_info_command)
 {
        struct sam3_chip *pChip;
        void *vp;
@@ -2343,11 +2337,9 @@ sam3_handle_info_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
        return ERROR_OK;
 }
 
-static int
-sam3_handle_gpnvm_command(struct command_context_s *cmd_ctx, char *cmd, char **argv, int argc)
+COMMAND_HANDLER(sam3_handle_gpnvm_command)
 {
        unsigned x,v;
-       uint32_t v32;
        int r,who;
        struct sam3_chip *pChip;
 
@@ -2388,20 +2380,17 @@ sam3_handle_gpnvm_command(struct command_context_s *cmd_ctx, char *cmd, char **a
                who = -1;
                break;
        case 2:
-               if ((0 == strcmp(argv[0], "show")) && (0 == strcmp(argv[1], "all"))) {
+               if ((0 == strcmp(args[0], "show")) && (0 == strcmp(args[1], "all"))) {
                        who = -1;
                } else {
-                       r = parse_u32(argv[1], &v32);
-                       if (r != ERROR_OK) {
-                               command_print(cmd_ctx, "Not a number: %s", argv[1]);
-                               return r;
-                       }
+                       uint32_t v32;
+                       COMMAND_PARSE_NUMBER(u32, args[1], v32);
                        who = v32;
                }
                break;
        }
 
-       if (0 == strcmp("show", argv[0])) {
+       if (0 == strcmp("show", args[0])) {
                if (who == -1) {
                showall:
                        r = ERROR_OK;
@@ -2429,24 +2418,20 @@ sam3_handle_gpnvm_command(struct command_context_s *cmd_ctx, char *cmd, char **a
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
-       if (0 == strcmp("set", argv[0])) {
+       if (0 == strcmp("set", args[0])) {
                r = FLASHD_SetGPNVM(&(pChip->details.bank[0]), who);
-       } else if ((0 == strcmp("clr", argv[0])) ||
-                          (0 == strcmp("clear", argv[0]))) { // quietly accept both
+       } else if ((0 == strcmp("clr", args[0])) ||
+                          (0 == strcmp("clear", args[0]))) { // quietly accept both
                r = FLASHD_ClrGPNVM(&(pChip->details.bank[0]), who);
        } else {
-               command_print(cmd_ctx, "Unkown command: %s", argv[0]);
+               command_print(cmd_ctx, "Unkown command: %s", args[0]);
                r = ERROR_COMMAND_SYNTAX_ERROR;
        }
        return r;
 }
 
-static int
-sam3_handle_slowclk_command(struct command_context_s *cmd_ctx, char *cmd, char **argv, int argc)
+COMMAND_HANDLER(sam3_handle_slowclk_command)
 {
-       uint32_t v;
-       int r;
-
        struct sam3_chip *pChip;
 
        pChip = get_current_sam3(cmd_ctx);
@@ -2460,8 +2445,10 @@ sam3_handle_slowclk_command(struct command_context_s *cmd_ctx, char *cmd, char *
                // show
                break;
        case 1:
+       {
                // set
-               r = parse_u32(argv[0], &v);
+               uint32_t v;
+               COMMAND_PARSE_NUMBER(u32, args[0], v);
                if (v > 200000) {
                        // absurd slow clock of 200Khz?
                        command_print(cmd_ctx,"Absurd/illegal slow clock freq: %d\n", (int)(v));
@@ -2469,7 +2456,7 @@ sam3_handle_slowclk_command(struct command_context_s *cmd_ctx, char *cmd, char *
                }
                pChip->cfg.slow_freq = v;
                break;
-
+       }
        default:
                // error
                command_print(cmd_ctx,"Too many parameters");
@@ -2513,19 +2500,16 @@ sam3_register_commands(struct command_context_s *cmd_ctx)
        return ERROR_OK;
 }
 
-
-flash_driver_t at91sam3_flash =
-{
-       .name                                           = "at91sam3",
-       .register_commands                      = sam3_register_commands,
-
-       .flash_bank_command                     = sam3_flash_bank_command,
-       .erase                                          = sam3_erase,
-       .protect                                        = sam3_protect,
-       .write                                          = sam3_write,
-       .probe                                          = sam3_probe,
-       .auto_probe                                     = sam3_auto_probe,
-       .erase_check                            = sam3_erase_check,
-       .protect_check                          = sam3_protect_check,
-       .info                                           = sam3_info
-};
+struct flash_driver at91sam3_flash = {
+               .name = "at91sam3",
+               .register_commands = &sam3_register_commands,
+               .flash_bank_command = &sam3_flash_bank_command,
+               .erase = &sam3_erase,
+               .protect = &sam3_protect,
+               .write = &sam3_write,
+               .probe = &sam3_probe,
+               .auto_probe = &sam3_auto_probe,
+               .erase_check = &sam3_erase_check,
+               .protect_check = &sam3_protect_check,
+               .info = &sam3_info,
+       };

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)