Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1594324

Re: [PATCH v3 3/3] printk: fix double printing with earlycon

Path csiph.com!fu-berlin.de!bofh.it!news.nic.it!robomod
From Aleksey Makarov <amakarov.linux@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3 3/3] printk: fix double printing with earlycon
Date Tue, 07 Mar 2017 16:10:01 +0100
Message-ID <tioUp-PI-13@gated-at.bofh.it> (permalink)
References <tgyOe-2Mh-23@gated-at.bofh.it> <tgXMB-3jh-1@gated-at.bofh.it> <ti2qR-1v4-1@gated-at.bofh.it>
X-Original-To Sergey Senozhatsky <sergey.senozhatsky@gmail.com>, Aleksey Makarov <aleksey.makarov@linaro.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=3Gw+7a7bgxEUEAgdBicpZ3KVxAQyOTygtyYwHrpIEtk=; b=ZEytUE7pRPNXiXhw45Sw96o/DyBjj8+GZEL/lIxT6W1jRKgj9LotB9YLWl2fqfA5f2 R80VS3ACIGQkOU8q68bsW5Mp7ETzRSGjcAyflYNZba05p7XkxJsvN4YeaeQinLqi44AG mawZmsqrfzzuJzvlcd45S0FnF8HjXRF3jIowzIjR4ATO4n5a9tiwoNH6BxcQGMZu9pjq Krrv5mdFPLuwgvRxEoYbDBVPd5jnhxWGMnwk75vQ2PWFq2m3NnDsr4vQ6qRd3jxnApI/ FR1JEKUgUHe0nfUdunX5Qbj2L49TBQ44JfEyhtXQBtDr2zkE75JiJR9+qzV7jVQleDXE q/og==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=3Gw+7a7bgxEUEAgdBicpZ3KVxAQyOTygtyYwHrpIEtk=; b=Recif0trN1jnWA8qYKezpe4BA6NaU+7KXf6yCwLjSbqrzIg7/Cc3mDpLA3XrOAsYWT jAA2hosRa7GNEEGOl9N8AW+Nsmdj6M/0QvI6P9fAygnT+GEi9CAeEcX40PmkVUr3NFwG MLKx8owXO9Asc4iEYHfZT3Um/xBgxgF+GtTDTjL6xn/OIYrlEfFs+eZ/aostoUfHyWj+ 2sGAf5IYAzfGSPcfLHnIpT5PcnTfnGeVaNQu0cYY8TZCzPi2rSgafCwL/XI3DSlEDXLG Z5ju53lV1IhAKlPe0qGktdXY/u5ZKwqMmMoJBjmNCLVjl93mWr+o1oucOtkHt8UBoews cFtg==
X-Gm-Message-State AMke39k5OZkwUaqTiPe4inDX5ZT5izC99E+1yAZS+UA76f90A4A0f6cDAbGQ0UEM3BeK1Q==
X-Received by 10.28.62.144 with SMTP id l138mr1234515wma.50.1488898485646; Tue, 07 Mar 2017 06:54:45 -0800 (PST)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1
MIME-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 141
Organization linux.* mail to news gateway
X-Original-Cc linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Sudeep Holla <sudeep.holla@arm.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Peter Hurley <peter@hurleysoftware.com>, Jiri Slaby <jslaby@suse.com>, Robin Murphy <robin.murphy@arm.com>, Steven Rostedt <rostedt@goodmis.org>, "Nair, Jayachandran" <Jayachandran.Nair@cavium.com>, Petr Mladek <pmladek@suse.com>
X-Original-Date Tue, 7 Mar 2017 15:54:43 +0100
X-Original-Message-ID <563502ae-1560-9dca-fe5b-4ec627c567f8@gmail.com>
X-Original-References <20170302131153.22733-4-aleksey.makarov@linaro.org> <20170303154946.15399-1-aleksey.makarov@linaro.org> <20170306145933.GB425@tigerII.localdomain>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1594324

Show key headers only | View raw



On 03/06/2017 03:59 PM, Sergey Senozhatsky wrote:
> On (03/03/17 18:49), Aleksey Makarov wrote:
> [..]
>> +static enum { CONSOLE_MATCH, CONSOLE_MATCH_RETURN, CONSOLE_MATCH_NEXT }
>> +match_console(struct console *newcon, struct console_cmdline *c)
>
> that enum in function return is interesting :)
> can we make it less hackish?

We probably can, but I can not figure out how to do that.
Suggestions will be appreciated.
We should signal 3 different outcomes.
I thought that using standard errnos is not quite desciptive.

>> +	if (!newcon->match ||
>> +	    newcon->match(newcon, c->name, c->index, c->options) != 0) {
>> +		/* default matching */
>> +		BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name));
>> +		if (strcmp(c->name, newcon->name) != 0)
>> +			return CONSOLE_MATCH_NEXT;
>> +		if (newcon->index >= 0 && newcon->index != c->index)
>> +			return CONSOLE_MATCH_NEXT;
>
> who is checking CONSOLE_MATCH_NEXT?

The caller checks two other values,  this one goes under the default case.
Should I check it explicitly?

>> +		if (newcon->index < 0)
>> +			newcon->index = c->index;
>> +
>> +		if (_braille_register_console(newcon, c))
>> +			return CONSOLE_MATCH_RETURN;
>> +
>> +		if (newcon->setup &&
>> +		    newcon->setup(newcon, c->options) != 0)
>> +			return CONSOLE_MATCH;
>> +	}
>> +
>> +	newcon->flags |= CON_ENABLED;
>> +	return CONSOLE_MATCH;
>> +}
>> +
>>  /*
>>   * The console driver calls this routine during kernel initialization
>>   * to register the console printing procedure with printk() and to
>> @@ -2454,40 +2480,50 @@ void register_console(struct console *newcon)
>>  	}
>>
>>  	/*
>> +	 * Check if this console was set as preferred by command line parameters
>> +	 * or by call to add_preferred_console().  There may be several entries
>> +	 * in the console_cmdline array matching with the same console so we
>> +	 * can not just use the first match.  Instead check the entry pointed
>> +	 * by preferred_console and then all other entries.
>> +	 */
>> +	if (preferred_console >= 0) {
>> +		switch (match_console(newcon,
>> +				      console_cmdline + preferred_console)) {
>> +		case CONSOLE_MATCH:
>> +			if (newcon->flags | CON_ENABLED) {
>
> 			newcon->flags & CON_ENABLED  ?

Sure.  Thank you.

>> +				newcon->flags |= CON_CONSDEV;
>> +				has_preferred = true;
>> +			}
>> +			goto match;
>> +		case CONSOLE_MATCH_RETURN:
>> +			return;
>> +		default:
>> +			break;
>> +		}
>> +	}
>> +
>> +	/*
>>  	 *	See if this console matches one we selected on
>>  	 *	the command line.
>>  	 */
>>  	for (i = 0, c = console_cmdline;
>>  	     i < MAX_CMDLINECONSOLES && c->name[0];
>>  	     i++, c++) {
>> -		if (!newcon->match ||
>> -		    newcon->match(newcon, c->name, c->index, c->options) != 0) {
>> -			/* default matching */
>> -			BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name));
>> -			if (strcmp(c->name, newcon->name) != 0)
>> -				continue;
>> -			if (newcon->index >= 0 &&
>> -			    newcon->index != c->index)
>> -				continue;
>> -			if (newcon->index < 0)
>> -				newcon->index = c->index;
>> -
>> -			if (_braille_register_console(newcon, c))
>> -				return;
>>
>> -			if (newcon->setup &&
>> -			    newcon->setup(newcon, c->options) != 0)
>> -				break;
>> -		}
>> +		if (preferred_console == i)
>> +			continue;
>>
>> -		newcon->flags |= CON_ENABLED;
>> -		if (i == preferred_console) {
>> -			newcon->flags |= CON_CONSDEV;
>> -			has_preferred = true;
>> +		switch (match_console(newcon, c)) {
>> +		case CONSOLE_MATCH:
>> +			goto match;
>> +		case CONSOLE_MATCH_RETURN:
>> +			return;
>> +		default:
>> +			break;
>
> sorry, it was a rather long for me today. need to look more at this.
> for what is now CONSOLE_MATCH_NEXT we used to have continue,

CONSOLE_MATCH is for the case when the console matches against the description,
CONSOLE_MATCH_NEXT - it does not, we should try next,
CONSOLE_MATCH_RETURN - we should return as the braille console is registered now.

> and now we break out of the loop?

`goto match` or just when we have seen all the entries

Thank you
Aleksey Makarov

>
> 	-ss
> --
> To unsubscribe from this list: send the line "unsubscribe linux-serial" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 3/3] printk: fix double printing with earlycon Aleksey Makarov <aleksey.makarov@linaro.org> - 2017-03-02 14:20 +0100
  Re: [PATCH v2 3/3] printk: fix double printing with earlycon Aleksey Makarov <aleksey.makarov@linaro.org> - 2017-03-02 15:40 +0100
  [PATCH v3 3/3] printk: fix double printing with earlycon Aleksey Makarov <aleksey.makarov@linaro.org> - 2017-03-03 17:00 +0100
    Re: [PATCH v3 3/3] printk: fix double printing with earlycon Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2017-03-06 16:10 +0100
      Re: [PATCH v3 3/3] printk: fix double printing with earlycon Aleksey Makarov <amakarov.linux@gmail.com> - 2017-03-07 16:10 +0100
        Re: [PATCH v3 3/3] printk: fix double printing with earlycon Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-03-08 06:40 +0100
          Re: [PATCH v3 3/3] printk: fix double printing with earlycon Aleksey Makarov <amakarov.linux@gmail.com> - 2017-03-08 16:00 +0100

csiph-web