Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751822AbdFHHbS (ORCPT ); Thu, 8 Jun 2017 03:31:18 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:7698 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751393AbdFHHbQ (ORCPT ); Thu, 8 Jun 2017 03:31:16 -0400 Subject: Re: [PATCH 06/15] serial: 8250_ingenic: Parse earlycon options To: Paul Cercueil , Ralf Baechle , Michael Turquette , Stephen Boyd , Rob Herring CC: Paul Burton , Maarten ter Huurne , , , , References: <20170607200439.24450-1-paul@crapouillou.net> <20170607200439.24450-7-paul@crapouillou.net> From: Marcin Nowakowski Message-ID: <939febde-f962-6e2b-3657-a9b6c719dac1@imgtec.com> Date: Thu, 8 Jun 2017 09:31:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170607200439.24450-7-paul@crapouillou.net> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.2.5] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2067 Lines: 71 Hi Paul, On 07.06.2017 22:04, Paul Cercueil wrote: > In the devicetree, it is possible to specify the baudrate, parity, > bits, flow of the early console, by passing a configuration string like > this: > > aliases { > serial0 = &uart0; > }; > > chosen { > stdout-path = "serial0:57600n8"; > }; > > This, for instance, will configure the early console for a baudrate of > 57600 bps, no parity, and 8 bits per baud. > > This patches implements parsing of this configuration string in the > 8250_ingenic driver, which previously just ignored it. > > Signed-off-by: Paul Cercueil > --- > drivers/tty/serial/8250/8250_ingenic.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/8250/8250_ingenic.c b/drivers/tty/serial/8250/8250_ingenic.c > index b31b2ca552d1..59f3e632df49 100644 > --- a/drivers/tty/serial/8250/8250_ingenic.c > +++ b/drivers/tty/serial/8250/8250_ingenic.c > @@ -99,14 +99,24 @@ static int __init ingenic_early_console_setup(struct earlycon_device *dev, > const char *opt) > { > struct uart_port *port = &dev->port; > - unsigned int baud, divisor; > + unsigned int divisor; > + int baud = 115200; > > if (!dev->port.membase) > return -ENODEV; > > + if (opt) { > + char options[256]; > + unsigned int parity, bits, flow; /* unused for now */ > + > + strlcpy(options, opt, sizeof(options)); Rather than adding this extra local copy maybe you could instead: -void uart_parse_options(char *options, int *baud, int *parity, int *bits, +void uart_parse_options(const char *options, int *baud, int *parity, int *bits, I cannot see any reason why uart_parse_options shouldn't take 'const char *options' as an argument. > + uart_parse_options(options, &baud, &parity, &bits, &flow); > + } > + > ingenic_early_console_setup_clock(dev); > > - baud = dev->baud ?: 115200; > + if (dev->baud) > + baud = dev->baud; > divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * baud); > > early_out(port, UART_IER, 0); > Marcin