summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-10 05:32:51 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-13 10:51:46 -0800
commit76868e071306bc83d25b89e57b785fef4637c4c8 (patch)
tree6ef82afc7c02f98a40050bc0788319a1761e44c5 /src
parentd02fee197f62331e36e9de110040f0170341c3e8 (diff)
downloadopenocd+libswd-76868e071306bc83d25b89e57b785fef4637c4c8.tar.gz
openocd+libswd-76868e071306bc83d25b89e57b785fef4637c4c8.tar.bz2
openocd+libswd-76868e071306bc83d25b89e57b785fef4637c4c8.tar.xz
openocd+libswd-76868e071306bc83d25b89e57b785fef4637c4c8.zip
s3c24xx: use COMMAND_HANDLER with command helper
Add S3C24XX_DEVICE_COMMAND macros to abstract common command handler conventions.
Diffstat (limited to 'src')
-rw-r--r--src/flash/s3c2410_nand.c6
-rw-r--r--src/flash/s3c2412_nand.c6
-rw-r--r--src/flash/s3c2440_nand.c6
-rw-r--r--src/flash/s3c2443_nand.c6
-rw-r--r--src/flash/s3c24xx_nand.c11
-rw-r--r--src/flash/s3c24xx_nand.h16
-rw-r--r--src/target/avrt.o.RcaTm50
7 files changed, 21 insertions, 30 deletions
diff --git a/src/flash/s3c2410_nand.c b/src/flash/s3c2410_nand.c
index e663507e..176a1a41 100644
--- a/src/flash/s3c2410_nand.c
+++ b/src/flash/s3c2410_nand.c
@@ -35,11 +35,7 @@ static int s3c2410_nand_device_command(struct command_context_s *cmd_ctx, char *
struct nand_device_s *nand)
{
s3c24xx_nand_controller_t *info;
-
- info = s3c24xx_nand_device_command(cmd_ctx, cmd, args, argc, nand);
- if (info == NULL) {
- return ERROR_NAND_DEVICE_INVALID;
- }
+ CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
/* fill in the address fields for the core device */
info->cmd = S3C2410_NFCMD;
diff --git a/src/flash/s3c2412_nand.c b/src/flash/s3c2412_nand.c
index 5c9d3199..7b65f84d 100644
--- a/src/flash/s3c2412_nand.c
+++ b/src/flash/s3c2412_nand.c
@@ -35,11 +35,7 @@ static int s3c2412_nand_device_command(struct command_context_s *cmd_ctx, char *
struct nand_device_s *nand)
{
s3c24xx_nand_controller_t *info;
-
- info = s3c24xx_nand_device_command(cmd_ctx, cmd, args, argc, nand);
- if (info == NULL) {
- return ERROR_NAND_DEVICE_INVALID;
- }
+ CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
/* fill in the address fields for the core device */
info->cmd = S3C2440_NFCMD;
diff --git a/src/flash/s3c2440_nand.c b/src/flash/s3c2440_nand.c
index fd1fbd0a..c6d658d4 100644
--- a/src/flash/s3c2440_nand.c
+++ b/src/flash/s3c2440_nand.c
@@ -36,11 +36,7 @@ static int s3c2440_nand_device_command(struct command_context_s *cmd_ctx, char *
struct nand_device_s *nand)
{
s3c24xx_nand_controller_t *info;
-
- info = s3c24xx_nand_device_command(cmd_ctx, cmd, args, argc, nand);
- if (info == NULL) {
- return ERROR_NAND_DEVICE_INVALID;
- }
+ CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
/* fill in the address fields for the core device */
info->cmd = S3C2440_NFCMD;
diff --git a/src/flash/s3c2443_nand.c b/src/flash/s3c2443_nand.c
index 82d9b8ea..6e92021d 100644
--- a/src/flash/s3c2443_nand.c
+++ b/src/flash/s3c2443_nand.c
@@ -36,11 +36,7 @@ static int s3c2443_nand_device_command(struct command_context_s *cmd_ctx, char *
struct nand_device_s *nand)
{
s3c24xx_nand_controller_t *info;
-
- info = s3c24xx_nand_device_command(cmd_ctx, cmd, args, argc, nand);
- if (info == NULL) {
- return ERROR_NAND_DEVICE_INVALID;
- }
+ CALL_S3C24XX_DEVICE_COMMAND(nand, &info);
/* fill in the address fields for the core device */
info->cmd = S3C2440_NFCMD;
diff --git a/src/flash/s3c24xx_nand.c b/src/flash/s3c24xx_nand.c
index 59d4d5bb..e2bc0053 100644
--- a/src/flash/s3c24xx_nand.c
+++ b/src/flash/s3c24xx_nand.c
@@ -31,17 +31,14 @@
#include "s3c24xx_nand.h"
-s3c24xx_nand_controller_t *
-s3c24xx_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
- char **args, int argc,
- struct nand_device_s *nand)
+S3C24XX_DEVICE_COMMAND()
{
s3c24xx_nand_controller_t *s3c24xx_info;
s3c24xx_info = malloc(sizeof(s3c24xx_nand_controller_t));
if (s3c24xx_info == NULL) {
LOG_ERROR("no memory for nand controller\n");
- return NULL;
+ return -ENOMEM;
}
nand->controller_priv = s3c24xx_info;
@@ -49,10 +46,10 @@ s3c24xx_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
s3c24xx_info->target = get_target(args[1]);
if (s3c24xx_info->target == NULL) {
LOG_ERROR("target '%s' not defined", args[1]);
- return NULL;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
- return s3c24xx_info;
+ return ERROR_OK;
}
int s3c24xx_register_commands(struct command_context_s *cmd_ctx)
diff --git a/src/flash/s3c24xx_nand.h b/src/flash/s3c24xx_nand.h
index ed142954..3f304a98 100644
--- a/src/flash/s3c24xx_nand.h
+++ b/src/flash/s3c24xx_nand.h
@@ -45,9 +45,19 @@ typedef struct s3c24xx_nand_controller_s
#undef S3C2410_NFREG
#define S3C2410_NFREG(x) ((x) + 0x4e000000)
-s3c24xx_nand_controller_t *s3c24xx_nand_device_command(
- struct command_context_s *cmd_ctx, char *cmd,
- char **args, int argc, struct nand_device_s *nand);
+#define S3C24XX_DEVICE_COMMAND() \
+ COMMAND_HELPER(s3c24xx_nand_device_command, \
+ struct nand_device_s *nand, \
+ s3c24xx_nand_controller_t **info)
+
+S3C24XX_DEVICE_COMMAND();
+
+#define CALL_S3C24XX_DEVICE_COMMAND(d, i) \
+ do { \
+ int retval = CALL_COMMAND_HANDLER(s3c24xx_nand_device_command, d, i); \
+ if (ERROR_OK != retval) \
+ return retval; \
+ } while (0)
int s3c24xx_register_commands(struct command_context_s *cmd_ctx);
diff --git a/src/target/avrt.o.RcaTm5 b/src/target/avrt.o.RcaTm5
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/target/avrt.o.RcaTm5