nand: add NAND_DEVICE_COMMAND_HANDLER macro
authorZachary T Welch <zw@superlucidity.net>
Tue, 10 Nov 2009 08:53:40 +0000 (00:53 -0800)
committerZachary T Welch <zw@superlucidity.net>
Fri, 13 Nov 2009 18:51:46 +0000 (10:51 -0800)
Abstracts the extended NAND command handling to allow the function
signature to be controlled by __COMMAND_HANDLER.

src/flash/davinci_nand.c
src/flash/lpc3180_nand_controller.c
src/flash/mx3_nand.c
src/flash/nand.h
src/flash/orion_nand.c
src/flash/s3c2410_nand.c
src/flash/s3c2412_nand.c
src/flash/s3c2440_nand.c
src/flash/s3c2443_nand.c

index 6ecc60a..b3164ab 100644 (file)
@@ -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;
index 4b12077..41cc33e 100644 (file)
@@ -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)
        {
index f6a75ef..a51f8c8 100644 (file)
@@ -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));
index d96e288..57076d5 100644 (file)
 
 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;
index 471c562..b112c9e 100644 (file)
@@ -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;
index 176a1a4..5badf1a 100644 (file)
@@ -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);
index 7b65f84..958f013 100644 (file)
@@ -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);
index c6d658d..80020f6 100644 (file)
@@ -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);
index 6e92021..af7d9a9 100644 (file)
@@ -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);