return ERROR_OK;
}
-static COMMAND_HELPER(create_nand_device,
+static COMMAND_HELPER(create_nand_device, const char *bank_name,
struct nand_flash_controller *controller)
{
int retval = controller->register_commands(CMD_CTX);
LOG_ERROR("couldn't register '%s' commands", controller->name);
return retval;
}
-
struct nand_device *c = malloc(sizeof(struct nand_device));
+ c->name = strdup(bank_name);
c->controller = controller;
c->controller_priv = NULL;
c->manufacturer = NULL;
return ERROR_FLASH_BANK_INVALID;
}
+ // save name and increment (for compatibility) with drivers
+ const char *bank_name = *CMD_ARGV++;
+ CMD_ARGC--;
+
const char *driver_name = CMD_ARGV[0];
for (unsigned i = 0; nand_flash_controllers[i]; i++)
{
if (strcmp(driver_name, controller->name) != 0)
continue;
- return CALL_COMMAND_HANDLER(create_nand_device, controller);
+ return CALL_COMMAND_HANDLER(create_nand_device,
+ bank_name, controller);
}
LOG_ERROR("No valid NAND flash driver found (%s)", driver_name);
struct nand_device *nand;
for (nand = nand_devices; NULL != nand; nand = nand->next)
{
+ if (strcmp(nand->name, name) == 0)
+ return nand;
if (!flash_driver_name_matches(nand->controller->name, name))
continue;
if (++found < requested)