diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-22 06:12:04 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-24 21:37:35 -0800 |
commit | ad090413a8dfacccc993ff15b8376e0f2bd56712 (patch) | |
tree | 361fbbe3c90adaa54cb1c894ad108647224cdd3f | |
parent | 6b9bb584a5edec4889b12ed3f99a1e2eeab1ada2 (diff) | |
download | openocd+libswd-ad090413a8dfacccc993ff15b8376e0f2bd56712.tar.gz openocd+libswd-ad090413a8dfacccc993ff15b8376e0f2bd56712.tar.bz2 openocd+libswd-ad090413a8dfacccc993ff15b8376e0f2bd56712.tar.xz openocd+libswd-ad090413a8dfacccc993ff15b8376e0f2bd56712.zip |
remove flash_driver->register_callbacks
Replace flash_driver callback with pointer to command_registration.
Eliminates all related routines and allows drivers to omit commands.
-rw-r--r-- | src/flash/at91sam3.c | 7 | ||||
-rw-r--r-- | src/flash/at91sam7.c | 7 | ||||
-rw-r--r-- | src/flash/avrf.c | 7 | ||||
-rw-r--r-- | src/flash/cfi.c | 6 | ||||
-rw-r--r-- | src/flash/ecos.c | 6 | ||||
-rw-r--r-- | src/flash/faux.c | 6 | ||||
-rw-r--r-- | src/flash/flash.c | 15 | ||||
-rw-r--r-- | src/flash/flash.h | 8 | ||||
-rw-r--r-- | src/flash/lpc2000.c | 7 | ||||
-rw-r--r-- | src/flash/lpc2900.c | 11 | ||||
-rw-r--r-- | src/flash/pic32mx.c | 7 | ||||
-rw-r--r-- | src/flash/stellaris.c | 8 | ||||
-rw-r--r-- | src/flash/stm32x.c | 6 | ||||
-rw-r--r-- | src/flash/str7x.c | 7 | ||||
-rw-r--r-- | src/flash/str9x.c | 7 | ||||
-rw-r--r-- | src/flash/str9xpec.c | 8 | ||||
-rw-r--r-- | src/flash/tms470.c | 7 |
17 files changed, 25 insertions, 105 deletions
diff --git a/src/flash/at91sam3.c b/src/flash/at91sam3.c index 75e84953..be17a5f8 100644 --- a/src/flash/at91sam3.c +++ b/src/flash/at91sam3.c @@ -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, diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c index 02046608..f9b87bab 100644 --- a/src/flash/at91sam7.c +++ b/src/flash/at91sam7.c @@ -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, diff --git a/src/flash/avrf.c b/src/flash/avrf.c index 9aea47d6..1c484643 100644 --- a/src/flash/avrf.c +++ b/src/flash/avrf.c @@ -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, diff --git a/src/flash/cfi.c b/src/flash/cfi.c index b92ecbd8..6dbffb9e 100644 --- a/src/flash/cfi.c +++ b/src/flash/cfi.c @@ -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, diff --git a/src/flash/ecos.c b/src/flash/ecos.c index f6f3307b..7a0b26f3 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -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, diff --git a/src/flash/faux.c b/src/flash/faux.c index 558d7b07..adfc7bd3 100644 --- a/src/flash/faux.c +++ b/src/flash/faux.c @@ -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, diff --git a/src/flash/flash.c b/src/flash/flash.c index de95b62f..4584c5d0 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -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; diff --git a/src/flash/flash.h b/src/flash/flash.h index ac1600e4..92727bf9 100644 --- a/src/flash/flash.h +++ b/src/flash/flash.h @@ -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 diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index 896b7949..418b5b03 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -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, diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index 0d961e47..81e2def4 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -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, diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c index 1950e05c..9bb6c97e 100644 --- a/src/flash/pic32mx.c +++ b/src/flash/pic32mx.c @@ -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, diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c index 1cff4867..771f0a71 100644 --- a/src/flash/stellaris.c +++ b/src/flash/stellaris.c @@ -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, diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index 808e32cf..2f51aa55 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -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, diff --git a/src/flash/str7x.c b/src/flash/str7x.c index e72946f7..7edffac9 100644 --- a/src/flash/str7x.c +++ b/src/flash/str7x.c @@ -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, diff --git a/src/flash/str9x.c b/src/flash/str9x.c index f6ad51af..98f15e75 100644 --- a/src/flash/str9x.c +++ b/src/flash/str9x.c @@ -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, diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c index 7f6a29ae..96e12596 100644 --- a/src/flash/str9xpec.c +++ b/src/flash/str9xpec.c @@ -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, diff --git a/src/flash/tms470.c b/src/flash/tms470.c index 3f32b51c..682013ef 100644 --- a/src/flash/tms470.c +++ b/src/flash/tms470.c @@ -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, |