summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-05-03 15:49:23 +0200
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-05-04 09:11:20 +0200
commit8865209545dae9c2745927758a51c60f922e02ca (patch)
treec2e0148b9ce02478e780a673755716318d31e9ab
parent32e647acf40bc11858a524e5ee73183ce0d9449b (diff)
downloadopenocd_libswd-8865209545dae9c2745927758a51c60f922e02ca.tar.gz
openocd_libswd-8865209545dae9c2745927758a51c60f922e02ca.tar.bz2
openocd_libswd-8865209545dae9c2745927758a51c60f922e02ca.tar.xz
openocd_libswd-8865209545dae9c2745927758a51c60f922e02ca.zip
target: clean up target memory allocation error messages
target memory allocation can be implemented not to show bogus error messages. E.g. when trying a big allocation first and then a smaller one if that fails. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
-rw-r--r--src/target/target.c17
-rw-r--r--src/target/target.h8
2 files changed, 22 insertions, 3 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 73594fb0..a3a1b0ad 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1111,7 +1111,7 @@ int target_call_timer_callbacks_now(void)
return target_call_timer_callbacks_check_time(0);
}
-int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
+int target_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area)
{
struct working_area *c = target->working_areas;
struct working_area *new_wa = NULL;
@@ -1189,8 +1189,6 @@ int target_alloc_working_area(struct target *target, uint32_t size, struct worki
if (free_size < size)
{
- LOG_WARNING("not enough working area available(requested %u, free %u)",
- (unsigned)(size), (unsigned)(free_size));
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
@@ -1231,6 +1229,19 @@ int target_alloc_working_area(struct target *target, uint32_t size, struct worki
return ERROR_OK;
}
+int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
+{
+ int retval;
+
+ retval = target_alloc_working_area_try(target, size, area);
+ if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
+ {
+ LOG_WARNING("not enough working area available(requested %u)", (unsigned)(size));
+ }
+ return retval;
+
+}
+
static int target_free_working_area_restore(struct target *target, struct working_area *area, int restore)
{
if (area->free)
diff --git a/src/target/target.h b/src/target/target.h
index 0292945d..4a48e5aa 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -452,6 +452,14 @@ const char *target_state_name( struct target *target );
*/
int target_alloc_working_area(struct target *target,
uint32_t size, struct working_area **area);
+/* Same as target_alloc_working_area, except that no error is logged
+ * when ERROR_TARGET_RESOURCE_NOT_AVAILABLE is returned.
+ *
+ * This allows the calling code to *try* to allocate target memory
+ * and have a fallback to another behavior(slower?).
+ */
+int target_alloc_working_area_try(struct target *target,
+ uint32_t size, struct working_area **area);
int target_free_working_area(struct target *target, struct working_area *area);
void target_free_all_working_areas(struct target *target);