summaryrefslogtreecommitdiff
path: root/src/flash
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-10 00:53:40 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-13 10:51:46 -0800
commit670f999e7a1ec04cda599a5487de068379e36f0e (patch)
treefa1c1cd69f2e741bbf689689f1a4a4533cbb2e8b /src/flash
parent0796dfff89bf00f82a780d7719767bcffe881d67 (diff)
downloadopenocd+libswd-670f999e7a1ec04cda599a5487de068379e36f0e.tar.gz
openocd+libswd-670f999e7a1ec04cda599a5487de068379e36f0e.tar.bz2
openocd+libswd-670f999e7a1ec04cda599a5487de068379e36f0e.tar.xz
openocd+libswd-670f999e7a1ec04cda599a5487de068379e36f0e.zip
nand: add NAND_DEVICE_COMMAND_HANDLER macro
Abstracts the extended NAND command handling to allow the function signature to be controlled by __COMMAND_HANDLER.
Diffstat (limited to 'src/flash')
-rw-r--r--src/flash/davinci_nand.c4
-rw-r--r--src/flash/lpc3180_nand_controller.c2
-rw-r--r--src/flash/mx3_nand.c4
-rw-r--r--src/flash/nand.h7
-rw-r--r--src/flash/orion_nand.c4
-rw-r--r--src/flash/s3c2410_nand.c4
-rw-r--r--src/flash/s3c2412_nand.c4
-rw-r--r--src/flash/s3c2440_nand.c4
-rw-r--r--src/flash/s3c2443_nand.c4
9 files changed, 14 insertions, 23 deletions
diff --git a/src/flash/davinci_nand.c b/src/flash/davinci_nand.c
index 6ecc60a2..b3164abf 100644
--- a/src/flash/davinci_nand.c
+++ b/src/flash/davinci_nand.c
@@ -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;
diff --git a/src/flash/lpc3180_nand_controller.c b/src/flash/lpc3180_nand_controller.c
index 4b120779..41cc33ee 100644
--- a/src/flash/lpc3180_nand_controller.c
+++ b/src/flash/lpc3180_nand_controller.c
@@ -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)
{
diff --git a/src/flash/mx3_nand.c b/src/flash/mx3_nand.c
index f6a75ef7..a51f8c8d 100644
--- a/src/flash/mx3_nand.c
+++ b/src/flash/mx3_nand.c
@@ -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));
diff --git a/src/flash/nand.h b/src/flash/nand.h
index d96e2889..57076d54 100644
--- a/src/flash/nand.h
+++ b/src/flash/nand.h
@@ -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;
diff --git a/src/flash/orion_nand.c b/src/flash/orion_nand.c
index 471c562a..b112c9e3 100644
--- a/src/flash/orion_nand.c
+++ b/src/flash/orion_nand.c
@@ -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;
diff --git a/src/flash/s3c2410_nand.c b/src/flash/s3c2410_nand.c
index 176a1a41..5badf1a4 100644
--- a/src/flash/s3c2410_nand.c
+++ b/src/flash/s3c2410_nand.c
@@ -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);
diff --git a/src/flash/s3c2412_nand.c b/src/flash/s3c2412_nand.c
index 7b65f84d..958f013d 100644
--- a/src/flash/s3c2412_nand.c
+++ b/src/flash/s3c2412_nand.c
@@ -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);
diff --git a/src/flash/s3c2440_nand.c b/src/flash/s3c2440_nand.c
index c6d658d4..80020f63 100644
--- a/src/flash/s3c2440_nand.c
+++ b/src/flash/s3c2440_nand.c
@@ -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);
diff --git a/src/flash/s3c2443_nand.c b/src/flash/s3c2443_nand.c
index 6e92021d..af7d9a9a 100644
--- a/src/flash/s3c2443_nand.c
+++ b/src/flash/s3c2443_nand.c
@@ -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);