]> git.sur5r.net Git - openocd/commitdiff
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 6ecc60a25dfc8a87f4a94a489ab0c2e7baa3bf83..b3164abfc7947e27b769bbf2bea0967e991d5009 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 4b120779e9f447b518b0692253a77e9e715cade2..41cc33eecd6e016ffd461ecc626ae8f38d90c283 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 f6a75ef7994719cc1b1d3cb712074450df23296b..a51f8c8d567065e678c0395d20048fabdc876ffd 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 d96e288939750270fd36620c91a60a6fcce48def..57076d54857880d7f404dab59e3b1d61342a06a8 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 471c562a2399dd61bd591ec449c20b3f8dd83673..b112c9e3dc066e777a17564df13d261675caa882 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 176a1a416a7be7833b6cf4801df557848221ee03..5badf1a4af8f670365b3f6ce16f36a8a372123d5 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 7b65f84da5409586394017eb12e15d9ccecde1a0..958f013d059842f2e74bcb5ca8c8ed7abcb53bbb 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 c6d658d45eeae903193e0c0b44f6c9b7c4238bb0..80020f63def9ed1601f1f34f4554cec7834c8b57 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 6e92021dfd0ea6f6afb267b5f897a8943cc304f2..af7d9a9aa01ce9050070f31fc351bcadf58d558a 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);