Add get_flash_bank_by_name (and get_nand_device_by_name) helpers
to retrieves struct flash_bank * (struct nand_device *) given a
driver name and an (optional) driver-specific bank index.

These are used to extend flash_command_get_bank_by_num (and
nand_command_get_device_by_num) to allow all flash (nand) commands to
reference defined banks by name, not just by number.  Due to this
change, this patch also improves the names for these COMMAND_HELPERs:
flash_command_get_bank{_by_num,} and nand_command_get_device{_by_num,}.

To avoid code duplication, add the flash/common.[ch] files to hold
functionality common to both types driver.  The first two methods are
helpers for the above routines to find a bank specified by a "name" or
"name.index" string.  get_flash_name_index() finds the '.index' portion,
while flash_driver_name_matches() performs the string portion matching.

Signed-off-by: Zachary T Welch <[email protected]>
---
 src/flash/Makefile.am |    2 ++
 src/flash/avrf.c      |    2 +-
 src/flash/common.c    |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 src/flash/common.h    |   39 +++++++++++++++++++++++++++++++++++++++
 src/flash/flash.c     |   35 +++++++++++++++++++++++++++++------
 src/flash/flash.h     |   14 ++++++++++++--
 src/flash/lpc2000.c   |    2 +-
 src/flash/lpc2900.c   |   12 ++++++------
 src/flash/nand.c      |   38 ++++++++++++++++++++++++++++++--------
 src/flash/nand.h      |   11 ++++++++++-
 src/flash/pic32mx.c   |    8 ++++----
 src/flash/stellaris.c |    2 +-
 src/flash/stm32x.c    |   10 +++++-----
 src/flash/str7x.c     |    2 +-
 src/flash/str9x.c     |    2 +-
 src/flash/str9xpec.c  |   22 +++++++++++-----------
 16 files changed, 199 insertions(+), 48 deletions(-)
 create mode 100644 src/flash/common.c
 create mode 100644 src/flash/common.h

diff --git a/src/flash/Makefile.am b/src/flash/Makefile.am
index bbcc34c..2bf98d5 100644
--- a/src/flash/Makefile.am
+++ b/src/flash/Makefile.am
@@ -11,6 +11,7 @@ libflash_la_SOURCES = \
        mflash.c
 
 FLASH_SRCS = \
+       common.c \
        cfi.c \
        non_cfi.c \
        faux.c \
@@ -60,6 +61,7 @@ noinst_HEADERS = \
        at91sam3.h \
        avrf.h \
        cfi.h \
+       common.h \
        flash.h \
        lpc2000.h \
        lpc288x.h \
diff --git a/src/flash/avrf.c b/src/flash/avrf.c
index 5d3c033..b1aabbf 100644
--- a/src/flash/avrf.c
+++ b/src/flash/avrf.c
@@ -426,7 +426,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/common.c b/src/flash/common.c
new file mode 100644
index 0000000..253ed9d
--- /dev/null
+++ b/src/flash/common.c
@@ -0,0 +1,46 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Zachary T Welch <[email protected]>          *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "common.h"
+#include "log.h"
+
+unsigned get_flash_name_index(const char *name)
+{
+       const char *index = strchr(name, '.');
+       if (NULL == index)
+               return 0;
+       unsigned requested;
+       int retval = parse_uint(index + 1, &requested);
+       // detect parsing error by forcing past end of bank list
+       return (ERROR_OK == retval) ? requested : ~0U;
+}
+
+bool flash_driver_name_matches(const char *name, const char *expected)
+{
+       unsigned blen = strlen(name);
+       // only match up to the length of the driver name...
+       if (strncmp(name, expected, blen) != 0)
+               return false;
+
+       // ...then check that name terminates at this spot.
+       return expected[blen] == '.' || expected[blen] == '\0';
+}
diff --git a/src/flash/common.h b/src/flash/common.h
new file mode 100644
index 0000000..1fd0d77
--- /dev/null
+++ b/src/flash/common.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Zachary T Welch <[email protected]>          *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+#ifndef FLASH_COMMON_H
+#define FLASH_COMMON_H
+
+#include "types.h"
+
+/**
+ * Parses the optional '.index' portion of a flash bank identifier.
+ * @param name The desired driver name, passed by the user.
+ * @returns The parsed index request, or 0 if not present.  If the
+ * name provides a suffix but it does not parse as an unsigned integer, 
+ * the routine returns ~0U.  This will prevent further matching.
+ */ 
+unsigned get_flash_name_index(const char *name);
+/**
+ * Attempt to match the @c expected name with the @c name of a driver.
+ * @param name The name of the driver (from the bank's device structure).
+ * @param expected The expected driver name, passed by the user.
+ */
+bool flash_driver_name_matches(const char *name, const char *expected);
+
+#endif // FLASH_COMMON_H
diff --git a/src/flash/flash.c b/src/flash/flash.c
index adc1411..680f583 100644
--- a/src/flash/flash.c
+++ b/src/flash/flash.c
@@ -28,6 +28,7 @@
 #endif
 
 #include "flash.h"
+#include "common.h"
 #include "image.h"
 #include "time_support.h"
 
@@ -180,6 +181,23 @@ int flash_get_bank_count(void)
        return i;
 }
 
+struct flash_bank *get_flash_bank_by_name(const char *name)
+{
+       unsigned requested = get_flash_name_index(name);
+       unsigned found = 0;
+
+       struct flash_bank *bank;
+       for (bank = flash_banks; NULL != bank; bank = bank->next)
+       {
+               if (!flash_driver_name_matches(bank->driver->name, name))
+                       continue;
+               if (++found < requested)
+                       continue;
+               return bank;
+       }
+       return NULL;
+}
+
 struct flash_bank *get_flash_bank_by_num(int num)
 {
        struct flash_bank *p = get_flash_bank_by_num_noprobe(num);
@@ -198,17 +216,22 @@ struct flash_bank *get_flash_bank_by_num(int num)
        return p;
 }
 
-COMMAND_HELPER(flash_command_get_bank_by_num,
+COMMAND_HELPER(flash_command_get_bank,
        unsigned name_index, struct flash_bank **bank)
 {
+       const char *name = args[name_index];
+       *bank = get_flash_bank_by_name(name);
+       if (*bank)
+               return ERROR_OK;
+
        unsigned bank_num;
-       COMMAND_PARSE_NUMBER(uint, args[name_index], bank_num);
+       COMMAND_PARSE_NUMBER(uint, name, bank_num);
 
        *bank = get_flash_bank_by_num(bank_num);
        if (!*bank)
        {
                command_print(cmd_ctx,
-                       "flash bank '#%u' not found", bank_num);
+                       "flash bank '%s' not found", name);
                return ERROR_INVALID_ARGUMENTS;
        }
        return ERROR_OK;
@@ -403,7 +426,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command)
        }
 
        struct flash_bank *p;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &p);
        if (ERROR_OK != retval)
                return retval;
 
@@ -491,7 +514,7 @@ COMMAND_HANDLER(handle_flash_protect_check_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        struct flash_bank *p;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &p);
        if (ERROR_OK != retval)
                return retval;
 
@@ -820,7 +843,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
        duration_start(&bench);
 
        struct flash_bank *p;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &p);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/flash.h b/src/flash/flash.h
index 96a4120..38b8bd6 100644
--- a/src/flash/flash.h
+++ b/src/flash/flash.h
@@ -310,6 +310,14 @@ int default_flash_blank_check(struct flash_bank *bank);
 int default_flash_mem_blank_check(struct flash_bank *bank);
 
 /**
+ * Returns the flash bank specified by @a name, which matches the
+ * driver name and a suffix (option) specify the driver-specific
+ * bank number. The suffix consists of the '.' and the driver-specific
+ * bank number: when two str9x banks are defined, then 'str9x.1' refers
+ * to the second.
+ */
+struct flash_bank *get_flash_bank_by_name(const char *name);
+/**
  * Returns a flash bank by the specified flash_bank_s bank_number, @a num.
  * @param num The flash bank number.
  * @returns A struct flash_bank for flash bank @a num, or NULL
@@ -317,13 +325,15 @@ int default_flash_mem_blank_check(struct flash_bank 
*bank);
 struct flash_bank *get_flash_bank_by_num(int num);
 /**
  * Retreives @a bank from a command argument, reporting errors parsing
- * the bank identifier or retreiving the specified bank.
+ * the bank identifier or retreiving the specified bank.  The bank
+ * may be identified by its bank number or by @c name.instance, where
+ * @a instance is driver-specific.
  * @param name_index The index to the string in args containing the
  * bank identifier.
  * @param bank On output, contians a pointer to the bank or NULL.
  * @returns ERROR_OK on success, or an error indicating the problem.
  */
-COMMAND_HELPER(flash_command_get_bank_by_num, unsigned name_index,
+COMMAND_HELPER(flash_command_get_bank, unsigned name_index,
                struct flash_bank **bank);
 /**
  * Returns the flash bank like get_flash_bank_by_num(), without probing.
diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c
index a3f9718..468ee95 100644
--- a/src/flash/lpc2000.c
+++ b/src/flash/lpc2000.c
@@ -750,7 +750,7 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c
index dc91668..ec82f46 100644
--- a/src/flash/lpc2900.c
+++ b/src/flash/lpc2900.c
@@ -544,7 +544,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -589,7 +589,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -660,7 +660,7 @@ COMMAND_HANDLER(lpc2900_handle_password_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -695,7 +695,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -806,7 +806,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
 
        /* Get the bank descriptor */
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -905,7 +905,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
 
        /* Get the bank descriptor */
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/nand.c b/src/flash/nand.c
index 71a67c4..0e4fe83 100644
--- a/src/flash/nand.c
+++ b/src/flash/nand.c
@@ -25,6 +25,7 @@
 #endif
 
 #include "nand.h"
+#include "common.h"
 #include "time_support.h"
 #include "fileio.h"
 
@@ -288,6 +289,23 @@ int nand_register_commands(struct command_context *cmd_ctx)
        return ERROR_OK;
 }
 
+struct nand_device *get_nand_device_by_name(const char *name)
+{
+       unsigned requested = get_flash_name_index(name);
+       unsigned found = 0;
+
+       struct nand_device *nand;
+       for (nand = nand_devices; NULL != nand; nand = nand->next)
+       {
+               if (!flash_driver_name_matches(nand->controller->name, name))
+                       continue;
+               if (++found < requested)
+                       continue;
+               return nand;
+       }
+       return NULL;
+}
+
 struct nand_device *get_nand_device_by_num(int num)
 {
        struct nand_device *p;
@@ -304,15 +322,19 @@ struct nand_device *get_nand_device_by_num(int num)
        return NULL;
 }
 
-COMMAND_HELPER(nand_command_get_device_by_num, unsigned name_index,
+COMMAND_HELPER(nand_command_get_device, unsigned name_index,
                struct nand_device **nand)
 {
        const char *str = args[name_index];
+       *nand = get_nand_device_by_name(str);
+       if (*nand)
+               return ERROR_OK;
+
        unsigned num;
        COMMAND_PARSE_NUMBER(uint, str, num);
        *nand = get_nand_device_by_num(num);
        if (!*nand) {
-               command_print(cmd_ctx, "NAND flash device '#%s' is out of 
bounds", str);
+               command_print(cmd_ctx, "NAND flash device '%s' not found", str);
                return ERROR_INVALID_ARGUMENTS;
        }
        return ERROR_OK;
@@ -1078,7 +1100,7 @@ COMMAND_HANDLER(handle_nand_info_command)
        int last = -1;
 
        struct nand_device *p;
-       int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, 
&p);
+       int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1153,7 +1175,7 @@ COMMAND_HANDLER(handle_nand_probe_command)
        }
 
        struct nand_device *p;
-       int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, 
&p);
+       int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1182,7 +1204,7 @@ COMMAND_HANDLER(handle_nand_erase_command)
        }
 
        struct nand_device *p;
-       int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, 
&p);
+       int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1241,7 +1263,7 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command)
        }
 
        struct nand_device *p;
-       int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, 
&p);
+       int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1393,7 +1415,7 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct 
nand_fileio_state *state,
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        struct nand_device *nand;
-       int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, 
&nand);
+       int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &nand);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1652,7 +1674,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command)
        }
 
        struct nand_device *p;
-       int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, 
&p);
+       int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/nand.h b/src/flash/nand.h
index ddc4520..d38ed67 100644
--- a/src/flash/nand.h
+++ b/src/flash/nand.h
@@ -212,6 +212,15 @@ enum oob_formats
 };
 
 
+/**
+ * Returns the flash bank specified by @a name, which matches the
+ * driver name and a suffix (option) specify the driver-specific
+ * bank number. The suffix consists of the '.' and the driver-specific
+ * bank number: when two davinci banks are defined, then 'davinci.1' refers
+ * to the second (e.g. DM355EVM).
+ */
+struct nand_device *get_nand_device_by_name(const char *name);
+
 struct nand_device *get_nand_device_by_num(int num);
 
 int nand_read_page_raw(struct nand_device *nand, uint32_t page,
@@ -230,7 +239,7 @@ int nand_register_commands(struct command_context *cmd_ctx);
 int nand_init(struct command_context *cmd_ctx);
 
 /// helper for parsing a nand device command argument string
-COMMAND_HELPER(nand_command_get_device_by_num, unsigned name_index,
+COMMAND_HELPER(nand_command_get_device, unsigned name_index,
                struct nand_device **nand);
 
 
diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c
index 51c42b5..c6287ef 100644
--- a/src/flash/pic32mx.c
+++ b/src/flash/pic32mx.c
@@ -684,7 +684,7 @@ COMMAND_HANDLER(pic32mx_handle_lock_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -730,7 +730,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -820,7 +820,7 @@ COMMAND_HANDLER(pic32mx_handle_chip_erase_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -858,7 +858,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command)
        COMMAND_PARSE_NUMBER(u32, args[1], value);
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 2, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 2, &bank);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c
index bbe4aef..97a70cd 100644
--- a/src/flash/stellaris.c
+++ b/src/flash/stellaris.c
@@ -1139,7 +1139,7 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c
index ab9831b..03adbe4 100644
--- a/src/flash/stm32x.c
+++ b/src/flash/stm32x.c
@@ -905,7 +905,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -951,7 +951,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -995,7 +995,7 @@ COMMAND_HANDLER(stm32x_handle_options_read_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1051,7 +1051,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1160,7 +1160,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/str7x.c b/src/flash/str7x.c
index d851051..e3acd9e 100644
--- a/src/flash/str7x.c
+++ b/src/flash/str7x.c
@@ -618,7 +618,7 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/str9x.c b/src/flash/str9x.c
index 4c4d8ae..632e1d1 100644
--- a/src/flash/str9x.c
+++ b/src/flash/str9x.c
@@ -642,7 +642,7 @@ COMMAND_HANDLER(str9x_handle_flash_config_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c
index 7f6d8be..f199471 100644
--- a/src/flash/str9xpec.c
+++ b/src/flash/str9xpec.c
@@ -738,7 +738,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -789,7 +789,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -905,7 +905,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -928,7 +928,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_cmap_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -957,7 +957,7 @@ 
COMMAND_HANDLER(str9xpec_handle_flash_options_lvdthd_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -986,7 +986,7 @@ 
COMMAND_HANDLER(str9xpec_handle_flash_options_lvdsel_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1015,7 +1015,7 @@ 
COMMAND_HANDLER(str9xpec_handle_flash_options_lvdwarn_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1044,7 +1044,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_lock_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1067,7 +1067,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1093,7 +1093,7 @@ 
COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1140,7 +1140,7 @@ 
COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command)
        }
 
        struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, 
&bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
-- 
1.6.4.4

_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to