diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-01-27 09:31:13 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-01-27 09:31:13 +0100 |
commit | 192d6fe9beb1b8e298806ddd2d81670e578efd7e (patch) | |
tree | 4c46ae60d19429ffdaf23267a1d1ca1f14afcf63 /lib | |
parent | 268c531d62a3b7e6c13728feab007e866ed8be84 (diff) | |
parent | 79c2f03aeed7b232592495f6af5fd94fbd102d25 (diff) | |
download | barebox-192d6fe9beb1b8e298806ddd2d81670e578efd7e.tar.gz barebox-192d6fe9beb1b8e298806ddd2d81670e578efd7e.tar.xz |
Merge branch 'pu/debug' into next
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kfifo.c | 23 | ||||
-rw-r--r-- | lib/vsprintf.c | 2 |
2 files changed, 11 insertions, 14 deletions
diff --git a/lib/kfifo.c b/lib/kfifo.c index 27d44e9bd8..a2f3727db3 100644 --- a/lib/kfifo.c +++ b/lib/kfifo.c @@ -34,19 +34,11 @@ * Do NOT pass the kfifo to kfifo_free() after use! Simply free the * &struct kfifo with free(). */ -struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size) +void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int size) { - struct kfifo *fifo; - - fifo = malloc(sizeof(struct kfifo)); - if (!fifo) - return NULL; - fifo->buffer = buffer; fifo->size = size; fifo->in = fifo->out = 0; - - return fifo; } /** @@ -60,18 +52,21 @@ struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size) struct kfifo *kfifo_alloc(unsigned int size) { unsigned char *buffer; - struct kfifo *ret; + struct kfifo *fifo; buffer = malloc(size); if (!buffer) return NULL; - ret = kfifo_init(buffer, size); - - if (!ret) + fifo = malloc(sizeof(struct kfifo)); + if (!fifo) { free(buffer); + return NULL; + } + + kfifo_init(fifo, buffer, size); - return ret; + return fifo; } /** diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 4165f97485..9763515130 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -625,6 +625,8 @@ void __noreturn panic(const char *fmt, ...) putchar('\n'); va_end(args); + dump_stack(); + led_trigger(LED_TRIGGER_PANIC, TRIGGER_ENABLE); #if defined (CONFIG_PANIC_HANG) |