Messages in this thread | | | Subject | Re: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char | From | Vladimir Zapolskiy <> | Date | Wed, 2 Mar 2022 20:21:15 +0200 |
| |
On 3/2/22 9:27 AM, Jiri Slaby wrote: > Currently, uart_console_write->putchar's second parameter (the > character) is of type int. It makes little sense, provided uart_console_write() > accepts the input string as "const char *s" and passes its content -- the > characters -- to putchar(). So switch the character's type to unsigned > char. > > We don't use char as that is signed on some platforms. That would cause > troubles for drivers which (implicitly) cast the char to u16 when > writing to the device. Sign extension would happen in that case and the > value written would be completely different to the provided char. DZ is > an example of such a driver -- on MIPS, it uses u16 for dz_out in > dz_console_putchar(). > > Note we do the char -> uchar conversion implicitly in > uart_console_write(). Provided we do not change size of the data type, > sign extension does not happen there, so the problem is void. > > This makes the types consistent and unified with the rest of the uart > layer, which uses unsigned char in most places already. One exception is > xmit_buf, but that is going to be converted later. > > Signed-off-by: Jiri Slaby <jslaby@suse.cz> > Acked-by: Richard Genoud <richard.genoud@gmail.com> [atmel_serial] > Acked-by: Florian Fainelli <f.fainelli@gmail.com> [bcm63xx_uart] > Acked-by: Tobias Klauser <tklauser@distanz.ch> [altera_*] > Cc: Paul Cercueil <paul@crapouillou.net> > Cc: Russell King <linux@armlinux.org.uk> > Cc: Vineet Gupta <vgupta@kernel.org> > Cc: Nicolas Ferre <nicolas.ferre@microchip.com> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches@microchip.com> > Cc: bcm-kernel-feedback-list@broadcom.com > Cc: Alexander Shiyan <shc_work@mail.ru> > Cc: Baruch Siach <baruch@tkos.co.il> > Cc: "Maciej W. Rozycki" <macro@orcam.me.uk> > Cc: Paul Walmsley <paul.walmsley@sifive.com> > Cc: Palmer Dabbelt <palmer@dabbelt.com> > Cc: Albert Ou <aou@eecs.berkeley.edu> > Cc: Shawn Guo <shawnguo@kernel.org> > Cc: Sascha Hauer <s.hauer@pengutronix.de> > Cc: Pengutronix Kernel Team <kernel@pengutronix.de> > Cc: Fabio Estevam <festevam@gmail.com> > Cc: NXP Linux Team <linux-imx@nxp.com> > Cc: Karol Gugala <kgugala@antmicro.com> > Cc: Mateusz Holenko <mholenko@antmicro.com> > Cc: Vladimir Zapolskiy <vz@mleia.com> > Cc: Neil Armstrong <narmstrong@baylibre.com> > Cc: Kevin Hilman <khilman@baylibre.com> > Cc: Jerome Brunet <jbrunet@baylibre.com> > Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com> > Cc: Taichi Sugaya <sugaya.taichi@socionext.com> > Cc: Takao Orito <orito.takao@socionext.com> > Cc: Liviu Dudau <liviu.dudau@arm.com> > Cc: Sudeep Holla <sudeep.holla@arm.com> > Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> > Cc: "Andreas Färber" <afaerber@suse.de> > Cc: Manivannan Sadhasivam <mani@kernel.org> > Cc: Michael Ellerman <mpe@ellerman.id.au> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> > Cc: Paul Mackerras <paulus@samba.org> > Cc: Andy Gross <agross@kernel.org> > Cc: Bjorn Andersson <bjorn.andersson@linaro.org> > Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> > Cc: Orson Zhai <orsonzhai@gmail.com> > Cc: Baolin Wang <baolin.wang7@gmail.com> > Cc: Chunyan Zhang <zhang.lyra@gmail.com> > Cc: Patrice Chotard <patrice.chotard@foss.st.com> > Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> > Cc: Alexandre Torgue <alexandre.torgue@foss.st.com> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Peter Korsgaard <peter@korsgaard.com> > Cc: Michal Simek <michal.simek@xilinx.com> > ---
[snip]
> diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c > index 54437a087aa0..93140cac1ca1 100644 > --- a/drivers/tty/serial/lpc32xx_hs.c > +++ b/drivers/tty/serial/lpc32xx_hs.c > @@ -122,7 +122,7 @@ static void wait_for_xmit_ready(struct uart_port *port) > } > } > > -static void lpc32xx_hsuart_console_putchar(struct uart_port *port, int ch) > +static void lpc32xx_hsuart_console_putchar(struct uart_port *port, unsigned char ch) > { > wait_for_xmit_ready(port); > writel((u32)ch, LPC32XX_HSUART_FIFO(port->membase));
for NXP LPC32xx HS UART:
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
-- Best wishes, Vladimir
| |