mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/9] kfifo: introduce kfifo_dump_str to dump the fifo
Date: Fri, 14 Dec 2012 23:49:07 +0100	[thread overview]
Message-ID: <20121214224907.GA26326@pengutronix.de> (raw)
In-Reply-To: <1355416810-26555-1-git-send-email-plagnioj@jcrosoft.com>

On Thu, Dec 13, 2012 at 05:40:02PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> This will allow to implement a dmesg mecanism in barebox
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  include/kfifo.h |    2 ++
>  lib/kfifo.c     |   21 +++++++++++++++++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/include/kfifo.h b/include/kfifo.h
> index 25880f4..9dbbe0d 100644
> --- a/include/kfifo.h
> +++ b/include/kfifo.h
> @@ -74,5 +74,7 @@ static inline unsigned int kfifo_len(struct kfifo *fifo)
>  void kfifo_putc(struct kfifo *fifo, unsigned char c);
>  unsigned int kfifo_getc(struct kfifo *fifo, unsigned char *c);
>  
> +void kfifo_dump_str(struct kfifo *fifo, void (*dump)(unsigned char c));
> +
>  #endif
>  
> diff --git a/lib/kfifo.c b/lib/kfifo.c
> index afd3894..7892aed 100644
> --- a/lib/kfifo.c
> +++ b/lib/kfifo.c
> @@ -154,3 +154,24 @@ unsigned int kfifo_getc(struct kfifo *fifo, unsigned char *c)
>  	return 0;
>  }
>  
> +void kfifo_dump_str(struct kfifo *fifo, void (*dump)(unsigned char c))
> +{
> +	int i;
> +	unsigned char *c;
> +	unsigned int l;
> +	unsigned int len;
> +
> +	len = fifo->in - fifo->out;
> +
> +	/* first get the data from fifo->out until the end of the buffer */
> +	l = min(len, fifo->size - (fifo->out & (fifo->size - 1)));
> +	c = fifo->buffer + (fifo->out & (fifo->size - 1));
> +	for (i = 0; i < l; i++)
> +		dump(c[i]);
> +
> +	/* then get the rest (if any) from the beginning of the buffer */
> +	c = fifo->buffer;
> +	l = len - l;
> +	for (i = 0; i < l; i++)
> +		dump(c[i]);
> +}

This function works in the innards of the fifo implementation and
replaces these two lines of code:

	while (kfifo_getc(console_output_fifo, &ch) == 0)
		console_putc(CONSOLE_STDOUT, ch);

You do not provide a reason why we should do this, so: no.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-12-14 22:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-13 16:37 [PATCH 0/9] introduction of dmesg support Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40 ` [PATCH 1/9] kfifo: introduce kfifo_dump_str to dump the fifo Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40   ` [PATCH 2/9] console: switch to kfifo_dump_str Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40   ` [PATCH 3/9] intoduce dmesg to print the barebox output ring buffer Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40   ` [PATCH 4/9] introduce printk support Jean-Christophe PLAGNIOL-VILLARD
2012-12-14 23:07     ` Sascha Hauer
2012-12-17  7:26       ` Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40   ` [PATCH 5/9] startup: switch to pr_xxx Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40   ` [PATCH 6/9] console: allow to specify ouput kfifo size via CONSOLE_KFIFO_OUTPUT_SIZE Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40   ` [PATCH 7/9] at91: clock switch to pr_info Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40   ` [PATCH 8/9] meminfo: switch to pr_xxx Jean-Christophe PLAGNIOL-VILLARD
2012-12-13 16:40   ` [PATCH 9/9] dev_printf: switch to pr_info Jean-Christophe PLAGNIOL-VILLARD
2012-12-14 22:49   ` Sascha Hauer [this message]
2012-12-17  7:23     ` [PATCH 1/9] kfifo: introduce kfifo_dump_str to dump the fifo Jean-Christophe PLAGNIOL-VILLARD
2012-12-14 23:15 ` [PATCH 0/9] introduction of dmesg support Sascha Hauer
2012-12-17  7:22   ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  8:33 [PATCH 0/9 v3] " Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  8:34 ` [PATCH 1/9] kfifo: introduce kfifo_dump_str to dump the fifo Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  8:38 [PATCH 0/9 v4] introduction of dmesg support Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  8:39 ` [PATCH 1/9] kfifo: introduce kfifo_dump_str to dump the fifo Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121214224907.GA26326@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox