LOG_ERROR("0x%" PRIx32 " is invalid Manufacturer for avr, 0x%X is expected", EXTRACT_MFG(device_id), 0x1F);
}
- for (i = 0; i < (int)(sizeof(avft_chips_info) / sizeof(avft_chips_info[0])); i++)
+ for (i = 0; i < (int)ARRAY_SIZE(avft_chips_info); i++)
{
if (avft_chips_info[i].chip_id == EXTRACT_PART(device_id))
{
LOG_ERROR("0x%" PRIx32 " is invalid Manufacturer for avr, 0x%X is expected", EXTRACT_MFG(device_id), 0x1F);
}
- for (i = 0; i < (int)(sizeof(avft_chips_info) / sizeof(avft_chips_info[0])); i++)
+ for (i = 0; i < (int)ARRAY_SIZE(avft_chips_info); i++)
{
if (avft_chips_info[i].chip_id == EXTRACT_PART(device_id))
{
}
struct flash_bank *bank;
- int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank);
+ int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
if (ERROR_OK != retval)
return retval;
return ERROR_OK;
}
-static int avrf_register_commands(struct command_context *cmd_ctx)
-{
- struct command *avr_cmd = register_command(cmd_ctx, NULL, "avr",
- NULL, COMMAND_ANY, "avr flash specific commands");
-
- register_command(cmd_ctx, avr_cmd, "mass_erase",
- avrf_handle_mass_erase_command, COMMAND_EXEC,
- "mass erase device");
-
- return ERROR_OK;
-}
+static const struct command_registration avrf_exec_command_handlers[] = {
+ {
+ .name = "mass_erase",
+ .handler = &avrf_handle_mass_erase_command,
+ .mode = COMMAND_EXEC,
+ .help = "erase entire device",
+ },
+ COMMAND_REGISTRATION_DONE
+};
+static const struct command_registration avrf_command_handlers[] = {
+ {
+ .name = "avrf",
+ .mode = COMMAND_ANY,
+ .help = "AVR flash command group",
+ .chain = avrf_exec_command_handlers,
+ },
+ COMMAND_REGISTRATION_DONE
+};
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,