use ARRAY_SIZE macro
[fw/openocd] / src / flash / avrf.c
index 9aea47d69f7c1cc3159c19a01aedc1fa4c3131c5..687dd4b59ea2acf79bf263bfe9ee47532d938ae4 100644 (file)
@@ -290,7 +290,7 @@ static int avrf_probe(struct flash_bank *bank)
                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))
                {
@@ -369,7 +369,7 @@ static int avrf_info(struct flash_bank *bank, char *buf, int buf_size)
                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))
                {
@@ -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,