if (strcmp(args[0], nand_flash_controllers[i]->name) == 0)
{
/* register flash specific commands */
- if (nand_flash_controllers[i]->register_commands(cmd_ctx) != ERROR_OK)
+ if ((retval = nand_flash_controllers[i]->register_commands(cmd_ctx)) != ERROR_OK)
{
LOG_ERROR("couldn't register '%s' commands", args[0]);
- exit(-1);
+ return retval;
}
c = malloc(sizeof(nand_device_t));
/* Send read status command */
device->controller->command(device, NAND_CMD_STATUS);
- usleep(1000);
+ alive_sleep(1);
/* read status */
if (device->device->options & NAND_BUSWIDTH_16)
* or 2048 for the beginning of OOB area)
*/
device->controller->address(device, 0x0);
- device->controller->address(device, 0x8);
+ if (data)
+ device->controller->address(device, 0x0);
+ else
+ device->controller->address(device, 0x8);
/* row */
device->controller->address(device, page & 0xff);