mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 4/5] dmesg: implement dmesg -n
Date: Tue, 13 Jun 2023 08:54:07 +0200	[thread overview]
Message-ID: <20230613065407.GF18491@pengutronix.de> (raw)
In-Reply-To: <20230613064518.up4nhv3t2iqcya4s@pengutronix.de>

On Tue, Jun 13, 2023 at 08:45:18AM +0200, Marco Felsch wrote:
> Hi Sascha,
> 
> On 23-06-12, Sascha Hauer wrote:
> > Under Linux dmesg -n can be used to set the console loglevel. Implement
> > the same for barebox.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  commands/dmesg.c | 18 +++++++++++++++++-
> >  1 file changed, 17 insertions(+), 1 deletion(-)
> > 
> > diff --git a/commands/dmesg.c b/commands/dmesg.c
> > index 00e5a159e0..953bdb2068 100644
> > --- a/commands/dmesg.c
> > +++ b/commands/dmesg.c
> > @@ -77,8 +77,9 @@ static int do_dmesg(int argc, char *argv[])
> >  	int opt, i;
> >  	int delete_buf = 0, emit = 0;
> >  	unsigned flags = 0, levels = 0;
> > +	char *set = NULL;
> >  
> > -	while ((opt = getopt(argc, argv, "ctderl:")) > 0) {
> > +	while ((opt = getopt(argc, argv, "ctderl:n:")) > 0) {
> >  		switch (opt) {
> >  		case 'c':
> >  			delete_buf = 1;
> > @@ -100,11 +101,25 @@ static int do_dmesg(int argc, char *argv[])
> >  		case 'r':
> >  			flags |= BAREBOX_LOG_PRINT_RAW | BAREBOX_LOG_PRINT_TIME;
> >  			break;
> > +		case 'n':
> > +			set = optarg;
> > +			break;
> >  		default:
> >  			return COMMAND_ERROR_USAGE;
> >  		}
> >  	}
> >  
> > +	if (set) {
> > +		int level = str_to_loglevel(set);
> > +
> > +		if (level < 0)
> > +			return COMMAND_ERROR;
> > +
> > +		barebox_loglevel = level;
> 
> Not really realted to this patch, but should we make 'barebox_loglevel'
> private and use a setter like console_set_loglevel()? Asking because
> console_common.c is the currently the only upstream user.

I asked myself the same question and would likely write it with a setter
nowadays, but I was too lazy to change it ;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2023-06-13  6:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 12:32 [PATCH 0/5] " Sascha Hauer
2023-06-12 12:32 ` [PATCH 1/5] dmesg: factor out str_to_loglevel() Sascha Hauer
2023-06-13  6:41   ` Marco Felsch
2023-06-12 12:32 ` [PATCH 2/5] dmesg: error out on unknown loglevels Sascha Hauer
2023-06-13  6:34   ` Marco Felsch
2023-06-13  6:49     ` Sascha Hauer
2023-06-13  6:57       ` Marco Felsch
2023-06-12 12:32 ` [PATCH 3/5] dmesg: allow loglevels specified as numbers Sascha Hauer
2023-06-13  6:41   ` Marco Felsch
2023-06-12 12:32 ` [PATCH 4/5] dmesg: implement dmesg -n Sascha Hauer
2023-06-13  6:45   ` Marco Felsch
2023-06-13  6:54     ` Sascha Hauer [this message]
2023-06-12 12:32 ` [PATCH 5/5] dmesg: udpate help Sascha Hauer
2023-06-13  6:40   ` Marco Felsch

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=20230613065407.GF18491@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    /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