Replace flash_driver callback with pointer to command_registration.
Eliminates all related routines and allows drivers to omit commands.
return false;
}
-static int davinci_register_commands(struct command_context *cmd_ctx)
-{
- return ERROR_OK;
-}
-
static int davinci_init(struct nand_device *nand)
{
struct davinci_nand *info = nand->controller_priv;
struct nand_flash_controller davinci_nand_controller = {
.name = "davinci",
.nand_device_command = davinci_nand_device_command,
- .register_commands = davinci_register_commands,
.init = davinci_init,
.reset = davinci_reset,
.command = davinci_command,
COMMAND_REGISTRATION_DONE
};
-static int lpc3180_register_commands(struct command_context *cmd_ctx)
-{
- return register_commands(cmd_ctx, NULL, lpc3180_command_handler);
-}
-
struct nand_flash_controller lpc3180_nand_controller = {
.name = "lpc3180",
+ .commands = lpc3180_command_handler,
.nand_device_command = lpc3180_nand_device_command,
- .register_commands = lpc3180_register_commands,
.init = lpc3180_init,
.reset = lpc3180_reset,
.command = lpc3180_command,
return imx31_controller_ready (nand, timeout);
}
-static int imx31_register_commands (struct command_context *cmd_ctx)
-{
- return ERROR_OK;
-}
-
static int imx31_reset (struct nand_device *nand)
{
/*
struct nand_flash_controller imx31_nand_flash_controller = {
.name = "imx31",
.nand_device_command = &imx31_nand_device_command,
- .register_commands = &imx31_register_commands,
.init = &imx31_init,
.reset = &imx31_reset,
.command = &imx31_command,
static COMMAND_HELPER(create_nand_device, const char *bank_name,
struct nand_flash_controller *controller)
{
- int retval = controller->register_commands(CMD_CTX);
- if (ERROR_OK != retval)
+ if (NULL != controller->commands)
{
- LOG_ERROR("couldn't register '%s' commands", controller->name);
- return retval;
+ int retval = register_commands(CMD_CTX, NULL,
+ controller->commands);
+ if (ERROR_OK != retval)
+ return retval;
}
struct nand_device *c = malloc(sizeof(struct nand_device));
c->use_raw = 0;
c->next = NULL;
- retval = CALL_COMMAND_HANDLER(controller->nand_device_command, c);
+ int retval = CALL_COMMAND_HANDLER(controller->nand_device_command, c);
if (ERROR_OK != retval)
{
LOG_ERROR("'%s' driver rejected nand flash", controller->name);
struct nand_flash_controller
{
char *name;
+ const struct command_registration *commands;
__NAND_DEVICE_COMMAND((*nand_device_command));
- int (*register_commands)(struct command_context *cmd_ctx);
int (*init)(struct nand_device *nand);
int (*reset)(struct nand_device *nand);
int (*command)(struct nand_device *nand, uint8_t command);
return 1;
}
-static int orion_nand_register_commands(struct command_context *cmd_ctx)
-{
- return ERROR_OK;
-}
-
NAND_DEVICE_COMMAND_HANDLER(orion_nand_device_command)
{
struct orion_nand_controller *hw;
.reset = orion_nand_reset,
.controller_ready = orion_nand_controller_ready,
.nand_device_command = orion_nand_device_command,
- .register_commands = orion_nand_register_commands,
.init = orion_nand_init,
};
struct nand_flash_controller s3c2410_nand_controller = {
.name = "s3c2410",
.nand_device_command = &s3c2410_nand_device_command,
- .register_commands = &s3c24xx_register_commands,
.init = &s3c2410_init,
.reset = &s3c24xx_reset,
.command = &s3c24xx_command,
struct nand_flash_controller s3c2412_nand_controller = {
.name = "s3c2412",
.nand_device_command = &s3c2412_nand_device_command,
- .register_commands = &s3c24xx_register_commands,
.init = &s3c2412_init,
.reset = &s3c24xx_reset,
.command = &s3c24xx_command,
struct nand_flash_controller s3c2440_nand_controller = {
.name = "s3c2440",
.nand_device_command = &s3c2440_nand_device_command,
- .register_commands = &s3c24xx_register_commands,
.init = &s3c2440_init,
.reset = &s3c24xx_reset,
.command = &s3c24xx_command,
struct nand_flash_controller s3c2443_nand_controller = {
.name = "s3c2443",
.nand_device_command = &s3c2443_nand_device_command,
- .register_commands = &s3c24xx_register_commands,
.init = &s3c2443_init,
.reset = &s3c24xx_reset,
.command = &s3c24xx_command,
return ERROR_OK;
}
-int s3c24xx_register_commands(struct command_context *cmd_ctx)
-{
- return ERROR_OK;
-}
-
int s3c24xx_reset(struct nand_device *nand)
{
struct s3c24xx_nand_controller *s3c24xx_info = nand->controller_priv;
return retval; \
} while (0)
-int s3c24xx_register_commands(struct command_context *cmd_ctx);
-
int s3c24xx_reset(struct nand_device *nand);
int s3c24xx_command(struct nand_device *nand, uint8_t command);