From 82bf0ed22edfebd555a181c2900865dfad4ec60e Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 28 Sep 2010 05:29:43 +0000 Subject: [PATCH] detectflash: preserve errors from lower layers for user to see git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1861 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 5 +++++ urjtag/src/flash/detectflash.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 4ae4b0e0..fd44e7a0 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -3,6 +3,11 @@ * src/flash/amd_flash.c (urj_flash_amd_detect): Move the bus address range checks up to before we actually attempt to read/write the bus. + * src/flash/detectflash.c (urj_flash_detectflash): Do not always clobber the + error value when we could not find a flash. If the lower layer logged an + error, then we probably want the user to see that rather than a generic + "flash not found". + 2010-09-27 Mike Frysinger * data/analog/bf533/bf533: Drop brackets from ADDR and DATA signals to match diff --git a/urjtag/src/flash/detectflash.c b/urjtag/src/flash/detectflash.c index 771d4199..d4ccf902 100644 --- a/urjtag/src/flash/detectflash.c +++ b/urjtag/src/flash/detectflash.c @@ -66,6 +66,8 @@ urj_flash_detectflash (urj_log_level_t ll, urj_bus_t *bus, uint32_t adr) return URJ_STATUS_FAIL; } + urj_error_reset (); + urj_flash_cleanup(); URJ_BUS_PREPARE (bus); @@ -94,7 +96,9 @@ urj_flash_detectflash (urj_log_level_t ll, urj_bus_t *bus, uint32_t adr) if (urj_flash_cfi_array == NULL) { - urj_error_set (URJ_ERROR_NOTFOUND, _("Flash not found")); + /* Preserve error from lower layers if they set one */ + if (urj_error_get () == URJ_ERROR_OK) + urj_error_set (URJ_ERROR_NOTFOUND, _("Flash not found")); return URJ_STATUS_FAIL; }