remove flash_driver->register_callbacks
Replace flash_driver callback with pointer to command_registration. Eliminates all related routines and allows drivers to omit commands.__archive__
parent
6b9bb584a5
commit
ad090413a8
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue