Commit 670f999e authored by Zachary T Welch's avatar Zachary T Welch
Browse files

nand: add NAND_DEVICE_COMMAND_HANDLER macro

Abstracts the extended NAND command handling to allow the function
signature to be controlled by __COMMAND_HANDLER.
parent 0796dfff
......@@ -629,9 +629,7 @@ static int davinci_read_page_ecc4infix(struct nand_device_s *nand, uint32_t page
return ERROR_OK;
}
static int davinci_nand_device_command(struct command_context_s *cmd_ctx,
char *cmd, char **args, int argc,
struct nand_device_s *nand)
NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
{
struct davinci_nand *info;
target_t *target;
......
......@@ -29,7 +29,7 @@ static int lpc3180_controller_ready(struct nand_device_s *nand, int timeout);
/* nand device lpc3180 <target#> <oscillator_frequency>
*/
static int lpc3180_nand_device_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct nand_device_s *nand)
NAND_DEVICE_COMMAND_HANDLER(lpc3180_nand_device_command)
{
if (argc < 3)
{
......
......@@ -61,9 +61,7 @@ static int imx31_command (struct nand_device_s *nand, uint8_t command);
static int imx31_address (struct nand_device_s *nand, uint8_t address);
static int imx31_controller_ready (struct nand_device_s *nand, int tout);
static int imx31_nand_device_command (struct command_context_s *cmd_ctx,
char *cmd, char **args, int argc,
struct nand_device_s *nand)
NAND_DEVICE_COMMAND_HANDLER(imx31_nand_device_command)
{
mx3_nf_controller_t *mx3_nf_info;
mx3_nf_info = malloc (sizeof (mx3_nf_controller_t));
......
......@@ -29,10 +29,13 @@
struct nand_device_s;
#define __NAND_DEVICE_COMMAND(name) \
COMMAND_HELPER(name, struct nand_device_s *nand)
typedef struct nand_flash_controller_s
{
char *name;
int (*nand_device_command)(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct nand_device_s *nand);
__NAND_DEVICE_COMMAND((*nand_device_command));
int (*register_commands)(struct command_context_s *cmd_ctx);
int (*init)(struct nand_device_s *nand);
int (*reset)(struct nand_device_s *nand);
......@@ -48,6 +51,8 @@ typedef struct nand_flash_controller_s
int (*nand_ready)(struct nand_device_s *nand, int timeout);
} nand_flash_controller_t;
#define NAND_DEVICE_COMMAND_HANDLER(name) static __NAND_DEVICE_COMMAND(name)
typedef struct nand_block_s
{
uint32_t offset;
......
......@@ -125,9 +125,7 @@ static int orion_nand_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
int orion_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
char **args, int argc,
struct nand_device_s *nand)
NAND_DEVICE_COMMAND_HANDLER(orion_nand_device_command)
{
orion_nand_controller_t *hw;
uint32_t base;
......
......@@ -30,9 +30,7 @@
#include "s3c24xx_nand.h"
static int s3c2410_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
char **args, int argc,
struct nand_device_s *nand)
NAND_DEVICE_COMMAND_HANDLER(s3c2410_nand_device_command)
{
s3c24xx_nand_controller_t *info;
CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
......
......@@ -30,9 +30,7 @@
#include "s3c24xx_nand.h"
static int s3c2412_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
char **args, int argc,
struct nand_device_s *nand)
NAND_DEVICE_COMMAND_HANDLER(s3c2412_nand_device_command)
{
s3c24xx_nand_controller_t *info;
CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
......
......@@ -31,9 +31,7 @@
#include "s3c24xx_nand.h"
static int s3c2440_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
char **args, int argc,
struct nand_device_s *nand)
NAND_DEVICE_COMMAND_HANDLER(s3c2440_nand_device_command)
{
s3c24xx_nand_controller_t *info;
CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
......
......@@ -31,9 +31,7 @@
#include "s3c24xx_nand.h"
static int s3c2443_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
char **args, int argc,
struct nand_device_s *nand)
NAND_DEVICE_COMMAND_HANDLER(s3c2443_nand_device_command)
{
s3c24xx_nand_controller_t *info;
CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment