turn flash detection routines into an array

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1965 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent 424f2ec225
commit da894d0249

@ -12,6 +12,10 @@
src/cmd/cmd_part.c, src/cmd/cmd_pod.c, src/cmd/cmd_shell.c,
src/cmd/cmd_svf.c, src/cmd/cmd_writemem.c: Add completion handlers.
* include/urjtag/flash.h, src/flash/detectflash.c: Turn flash detection
handling into an array to make adding new routines easy. Patch by
Jonathan Stroud.
2011-07-06 Jie Zhang <jie.zhang@analog.com>
* src/tap/chain.c (urj_tap_chain_connect): Correct checking of the

@ -41,6 +41,9 @@
typedef struct URJ_FLASH_CFI_ARRAY urj_flash_cfi_array_t;
typedef int (*urj_flash_detect_func_t) (urj_bus_t *bus, uint32_t adr,
urj_flash_cfi_array_t **cfi_array);
typedef struct
{
const char *name;

@ -47,6 +47,15 @@
urj_flash_cfi_array_t *urj_flash_cfi_array = NULL;
static const urj_flash_detect_func_t urj_flash_detect_funcs[] = {
&urj_flash_cfi_detect,
&urj_flash_jedec_detect,
&urj_flash_amd_detect,
#ifdef JEDEC_EXP
&urj_flash_jedec_exp_detect,
#endif
};
void
urj_flash_cleanup (void)
{
@ -59,6 +68,7 @@ urj_flash_detectflash (urj_log_level_t ll, urj_bus_t *bus, uint32_t adr)
{
urj_flash_cfi_query_structure_t *cfi;
const char *s;
int i, ret;
if (!bus)
{
@ -72,26 +82,12 @@ urj_flash_detectflash (urj_log_level_t ll, urj_bus_t *bus, uint32_t adr)
URJ_BUS_PREPARE (bus);
if (urj_flash_cfi_detect (bus, adr, &urj_flash_cfi_array) != URJ_STATUS_OK)
for (i = 0; i < ARRAY_SIZE (urj_flash_detect_funcs); ++i)
{
urj_flash_cleanup();
if (urj_flash_jedec_detect (bus, adr, &urj_flash_cfi_array)
!= URJ_STATUS_OK)
{
urj_flash_cleanup();
if (urj_flash_amd_detect (bus, adr, &urj_flash_cfi_array)
!= URJ_STATUS_OK)
{
urj_flash_cleanup();
#ifdef JEDEC_EXP
if (urj_flash_jedec_exp_detect (bus, adr, &urj_flash_cfi_array)
!= URJ_STATUS_OK)
{
urj_flash_cleanup();
}
#endif
}
}
ret = urj_flash_detect_funcs[i] (bus, adr, &urj_flash_cfi_array);
if (ret == URJ_STATUS_OK)
break;
urj_flash_cleanup ();
}
if (urj_flash_cfi_array == NULL)

Loading…
Cancel
Save