remove flash_driver->register_callbacks
authorZachary T Welch <zw@superlucidity.net>
Sun, 22 Nov 2009 14:12:04 +0000 (06:12 -0800)
committerZachary T Welch <zw@superlucidity.net>
Wed, 25 Nov 2009 05:37:35 +0000 (21:37 -0800)
Replace flash_driver callback with pointer to command_registration.
Eliminates all related routines and allows drivers to omit commands.

17 files changed:
src/flash/at91sam3.c
src/flash/at91sam7.c
src/flash/avrf.c
src/flash/cfi.c
src/flash/ecos.c
src/flash/faux.c
src/flash/flash.c
src/flash/flash.h
src/flash/lpc2000.c
src/flash/lpc2900.c
src/flash/pic32mx.c
src/flash/stellaris.c
src/flash/stm32x.c
src/flash/str7x.c
src/flash/str9x.c
src/flash/str9xpec.c
src/flash/tms470.c

index 75e8495326ac90869d6fa96c22d810dd5f5c5e49..be17a5f807d3fcbdf78e2d8c4ccd8594e2c9fe14 100644 (file)
@@ -2501,14 +2501,9 @@ static const struct command_registration at91sam3_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int sam3_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, at91sam3_command_handlers);
-}
-
 struct flash_driver at91sam3_flash = {
                .name = "at91sam3",
-               .register_commands = &sam3_register_commands,
+               .commands = at91sam3_command_handlers,
                .flash_bank_command = &sam3_flash_bank_command,
                .erase = &sam3_erase,
                .protect = &sam3_protect,
index 02046608a1894cd0e9ae92b5d7709618e9941451..f9b87babb23708da4c6542e43a36d408eb5c8271 100644 (file)
@@ -1198,14 +1198,9 @@ static const struct command_registration at91sam7_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int at91sam7_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, at91sam7_command_handlers);
-}
-
 struct flash_driver at91sam7_flash = {
                .name = "at91sam7",
-               .register_commands = &at91sam7_register_commands,
+               .commands = at91sam7_command_handlers,
                .flash_bank_command = &at91sam7_flash_bank_command,
                .erase = &at91sam7_erase,
                .protect = &at91sam7_protect,
index 9aea47d69f7c1cc3159c19a01aedc1fa4c3131c5..1c484643c06b9dd708b8f50855d64eeeb096acfb 100644 (file)
@@ -468,14 +468,9 @@ static const struct command_registration avrf_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int avrf_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, avrf_command_handlers);
-}
-
 struct flash_driver avr_flash = {
                .name = "avr",
-               .register_commands = &avrf_register_commands,
+               .commands = avrf_command_handlers,
                .flash_bank_command = &avrf_flash_bank_command,
                .erase = &avrf_erase,
                .protect = &avrf_protect,
index b92ecbd8bc41f0e9217337e2e9ba6b67774f74ad..6dbffb9e1cb3a1c5e17ba50d460332773ad93e0b 100644 (file)
@@ -589,11 +589,6 @@ static int cfi_intel_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-static int cfi_register_commands(struct command_context *cmd_ctx)
-{
-       return ERROR_OK;
-}
-
 /* flash_bank cfi <base> <size> <chip_width> <bus_width> <target#> [options]
  */
 FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command)
@@ -2623,7 +2618,6 @@ static int cfi_info(struct flash_bank *bank, char *buf, int buf_size)
 
 struct flash_driver cfi_flash = {
                .name = "cfi",
-               .register_commands = &cfi_register_commands,
                .flash_bank_command = &cfi_flash_bank_command,
                .erase = &cfi_erase,
                .protect = &cfi_protect,
index f6f3307b068ca7e7efe1c5483e2f3a868d816eb3..7a0b26f323d44f0e220542824f2c8c3798c75603 100644 (file)
@@ -336,11 +336,6 @@ static int ecosflash_probe(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int ecosflash_register_commands(struct command_context *cmd_ctx)
-{
-       return ERROR_OK;
-}
-
 #if 0
 static void command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
 {
@@ -437,7 +432,6 @@ static int ecosflash_handle_gpnvm_command(struct command_context *cmd_ctx, char
 
 struct flash_driver ecosflash_flash = {
                .name = "ecosflash",
-               .register_commands = &ecosflash_register_commands,
                .flash_bank_command = &ecosflash_flash_bank_command,
                .erase = &ecosflash_erase,
                .protect = &ecosflash_protect,
index 558d7b07f31a7ac916c848738cb6fafe3ae1d283..adfc7bd3e79b038f62111a83cd472d38e1f39cea 100644 (file)
@@ -87,11 +87,6 @@ FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command)
        return ERROR_OK;
 }
 
-static int faux_register_commands(struct command_context *cmd_ctx)
-{
-       return ERROR_OK;
-}
-
 static int faux_erase(struct flash_bank *bank, int first, int last)
 {
        struct faux_flash_bank *info = bank->driver_priv;
@@ -130,7 +125,6 @@ static int faux_probe(struct flash_bank *bank)
 
 struct flash_driver faux_flash = {
                .name = "faux",
-               .register_commands = &faux_register_commands,
                .flash_bank_command = &faux_flash_bank_command,
                .erase = &faux_erase,
                .protect = &faux_protect,
index de95b62f5b42a25ade70b43c0fd192c9da86bdb3..4584c5d03ee6f4fc958f4252d97383a22bd46ae8 100644 (file)
@@ -263,15 +263,20 @@ COMMAND_HANDLER(handle_flash_bank_command)
                if (strcmp(driver_name, flash_drivers[i]->name) != 0)
                        continue;
 
-               struct flash_bank *p, *c;
-
                /* register flash specific commands */
-               if (flash_drivers[i]->register_commands(CMD_CTX) != ERROR_OK)
+               if (NULL != flash_drivers[i]->commands)
                {
-                       LOG_ERROR("couldn't register '%s' commands", driver_name);
-                       return ERROR_FAIL;
+                       int retval = register_commands(CMD_CTX, NULL,
+                                       flash_drivers[i]->commands);
+                       if (ERROR_OK != retval)
+                       {
+                               LOG_ERROR("couldn't register '%s' commands",
+                                               driver_name);
+                               return ERROR_FAIL;
+                       }
                }
 
+               struct flash_bank *p, *c;
                c = malloc(sizeof(struct flash_bank));
                c->name = strdup(bank_name);
                c->target = target;
index ac1600e4587f535942aa2f633ffae8b1f77129fe..92727bf9e998824cc26db1b0833efdfce346a5a3 100644 (file)
@@ -91,13 +91,11 @@ struct flash_driver
        char *name;
 
        /**
-        * Registers driver-specific commands.  When called (during the
-        * "flash bank" command), the driver may register addition
+        * An array of driver-specific commands to register.  When called
+        * during the "flash bank" command, the driver can register addition
         * commands to support new flash chip functions.
-        *
-        * @returns ERROR_OK if successful; otherwise, an error code.
         */
-       int (*register_commands)(struct command_context *cmd_ctx);
+       const struct command_registration *commands;
 
        /**
         * Finish the "flash bank" command for @a bank.  The
index 896b7949cf594eb6fee373c8555326a25ac806c5..418b5b0345dff8bff3c3421dc24d92b79a3dc0a4 100644 (file)
@@ -795,14 +795,9 @@ static const struct command_registration lpc2000_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int lpc2000_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, lpc2000_command_handlers);
-}
-
 struct flash_driver lpc2000_flash = {
                .name = "lpc2000",
-               .register_commands = &lpc2000_register_commands,
+               .commands = lpc2000_command_handlers,
                .flash_bank_command = &lpc2000_flash_bank_command,
                .erase = &lpc2000_erase,
                .protect = &lpc2000_protect,
index 0d961e47f8bb81e2fbb5e8517638cf4667e4db3c..81e2def466260604ae7b3a643dc297713ec1f395 100644 (file)
@@ -1003,15 +1003,6 @@ static const struct command_registration lpc2900_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-/**
- * Register private command handlers.
- */
-static int lpc2900_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, lpc2900_command_handlers);
-}
-
-
 /// Evaluate flash bank command.
 FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command)
 {
@@ -1830,7 +1821,7 @@ static int lpc2900_info(struct flash_bank *bank, char *buf, int buf_size)
 struct flash_driver lpc2900_flash =
 {
        .name               = "lpc2900",
-       .register_commands  = lpc2900_register_commands,
+       .commands           = lpc2900_command_handlers,
        .flash_bank_command = lpc2900_flash_bank_command,
        .erase              = lpc2900_erase,
        .protect            = lpc2900_protect,
index 1950e05cf11b8211d580aeb3429d88e0c1d2b262..9bb6c97edd2b50c4a603a9e52abf5b6499a8c110 100644 (file)
@@ -907,14 +907,9 @@ static const struct command_registration pic32mx_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int pic32mx_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, pic32mx_command_handlers);
-}
-
 struct flash_driver pic32mx_flash = {
                .name = "pic32mx",
-               .register_commands = &pic32mx_register_commands,
+               .commands = pic32mx_command_handlers,
                .flash_bank_command = &pic32mx_flash_bank_command,
                .erase = &pic32mx_erase,
                .protect = &pic32mx_protect,
index 1cff48679dcaab4020edab3bc9c13d6fbbdea10d..771f0a7123c65b53a76242d2f60bd613ad489ef6 100644 (file)
@@ -1180,15 +1180,9 @@ static const struct command_registration stellaris_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int stellaris_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, stellaris_command_handlers);
-}
-
-
 struct flash_driver stellaris_flash = {
                .name = "stellaris",
-               .register_commands = &stellaris_register_commands,
+               .commands = stellaris_command_handlers,
                .flash_bank_command = &stellaris_flash_bank_command,
                .erase = &stellaris_erase,
                .protect = &stellaris_protect,
index 808e32cf8bdfe1a753cdda89ed740f8bf0c72f13..2f51aa55a9463ec4b6cf435ff441c4ec0bbd45ac 100644 (file)
@@ -1225,13 +1225,9 @@ static const struct command_registration stm32x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int stm32x_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, stm32x_command_handlers);
-}
 struct flash_driver stm32x_flash = {
                .name = "stm32x",
-               .register_commands = &stm32x_register_commands,
+               .commands = stm32x_command_handlers,
                .flash_bank_command = &stm32x_flash_bank_command,
                .erase = &stm32x_erase,
                .protect = &stm32x_protect,
index e72946f7d244cad42831300461ef7b14acd07d1c..7edffac9e222523944bb497e1c17bcbccfc3da5e 100644 (file)
@@ -691,14 +691,9 @@ static const struct command_registration str7x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int str7x_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, str7x_command_handlers);
-}
-
 struct flash_driver str7x_flash = {
                .name = "str7x",
-               .register_commands = &str7x_register_commands,
+               .commands = str7x_command_handlers,
                .flash_bank_command = &str7x_flash_bank_command,
                .erase = &str7x_erase,
                .protect = &str7x_protect,
index f6ad51af100540995f3e7940cfdcfc94b5a9ac72..98f15e75b4bf7d8d8337b27e70dc7b084fd866e5 100644 (file)
@@ -696,14 +696,9 @@ static const struct command_registration str9x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int str9x_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, str9x_command_handlers);
-}
-
 struct flash_driver str9x_flash = {
                .name = "str9x",
-               .register_commands = &str9x_register_commands,
+               .commands = str9x_command_handlers,
                .flash_bank_command = &str9x_flash_bank_command,
                .erase = &str9x_erase,
                .protect = &str9x_protect,
index 7f6a29aec6a9e53c6feca31a50889ebd1d98929e..96e12596a6694bcc58e0bd59c103c5f9d3f01ffc 100644 (file)
@@ -1242,15 +1242,9 @@ static const struct command_registration str9xpec_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int str9xpec_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, str9xpec_command_handlers);
-}
-
-
 struct flash_driver str9xpec_flash = {
                .name = "str9xpec",
-               .register_commands = &str9xpec_register_commands,
+               .commands = str9xpec_command_handlers,
                .flash_bank_command = &str9xpec_flash_bank_command,
                .erase = &str9xpec_erase,
                .protect = &str9xpec_protect,
index 3f32b51c8f021ae1e9a3bf61e7c0e1d16b6d451f..682013ef076983001e910c4dae608407eea2c9b8 100644 (file)
@@ -848,11 +848,6 @@ static const struct command_registration tms470_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int tms470_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL, tms470_command_handlers);
-}
-
 /* ---------------------------------------------------------------------- */
 
 static int tms470_erase(struct flash_bank *bank, int first, int last)
@@ -1263,7 +1258,7 @@ FLASH_BANK_COMMAND_HANDLER(tms470_flash_bank_command)
 
 struct flash_driver tms470_flash = {
                .name = "tms470",
-               .register_commands = &tms470_register_commands,
+               .commands = tms470_command_handlers,
                .flash_bank_command = &tms470_flash_bank_command,
                .erase = &tms470_erase,
                .protect = &tms470_protect,