Skip to content

Commit 3f8bab1

Browse files
Jiri Slabygregkh
authored andcommitted
serial: make uart_console_write->putchar()'s character an unsigned char
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. Cc: Paul Cercueil <paul@crapouillou.net> Cc: Tobias Klauser <tklauser@distanz.ch> 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: Florian Fainelli <f.fainelli@gmail.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> Acked-by: Richard Genoud <richard.genoud@gmail.com> [atmel_serial] Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Paul Cercueil <paul@crapouillou.net> Acked-by: Neil Armstrong <narmstrong@baylibre.com> # meson_serial Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20220303080831.21783-1-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 47b95e8 commit 3f8bab1

62 files changed

Lines changed: 77 additions & 76 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drivers/tty/goldfish.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static int goldfish_tty_remove(struct platform_device *pdev)
434434
}
435435

436436
#ifdef CONFIG_GOLDFISH_TTY_EARLY_CONSOLE
437-
static void gf_early_console_putchar(struct uart_port *port, int ch)
437+
static void gf_early_console_putchar(struct uart_port *port, unsigned char ch)
438438
{
439439
__raw_writel(ch, port->membase);
440440
}

drivers/tty/hvc/hvc_dcc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define DCC_STATUS_RX (1 << 30)
1616
#define DCC_STATUS_TX (1 << 29)
1717

18-
static void dcc_uart_console_putchar(struct uart_port *port, int ch)
18+
static void dcc_uart_console_putchar(struct uart_port *port, unsigned char ch)
1919
{
2020
while (__dcc_getstatus() & DCC_STATUS_TX)
2121
cpu_relax();

drivers/tty/serial/21285.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static void serial21285_setup_ports(void)
403403
}
404404

405405
#ifdef CONFIG_SERIAL_21285_CONSOLE
406-
static void serial21285_console_putchar(struct uart_port *port, int ch)
406+
static void serial21285_console_putchar(struct uart_port *port, unsigned char ch)
407407
{
408408
while (*CSR_UARTFLG & 0x20)
409409
barrier();

drivers/tty/serial/8250/8250_early.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static void serial8250_early_out(struct uart_port *port, int offset, int value)
8686

8787
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
8888

89-
static void serial_putc(struct uart_port *port, int c)
89+
static void serial_putc(struct uart_port *port, unsigned char c)
9090
{
9191
unsigned int status;
9292

drivers/tty/serial/8250/8250_ingenic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void early_out(struct uart_port *port, int offset, uint8_t value)
5252
writel(value, port->membase + (offset << 2));
5353
}
5454

55-
static void ingenic_early_console_putc(struct uart_port *port, int c)
55+
static void ingenic_early_console_putc(struct uart_port *port, unsigned char c)
5656
{
5757
uint8_t lsr;
5858

drivers/tty/serial/8250/8250_port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3305,7 +3305,7 @@ EXPORT_SYMBOL_GPL(serial8250_set_defaults);
33053305

33063306
#ifdef CONFIG_SERIAL_8250_CONSOLE
33073307

3308-
static void serial8250_console_putchar(struct uart_port *port, int ch)
3308+
static void serial8250_console_putchar(struct uart_port *port, unsigned char ch)
33093309
{
33103310
struct uart_8250_port *up = up_to_u8250p(port);
33113311

drivers/tty/serial/altera_jtaguart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static struct altera_jtaguart altera_jtaguart_ports[ALTERA_JTAGUART_MAXPORTS];
298298
#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE)
299299

300300
#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS)
301-
static void altera_jtaguart_console_putc(struct uart_port *port, int c)
301+
static void altera_jtaguart_console_putc(struct uart_port *port, unsigned char c)
302302
{
303303
unsigned long status;
304304
unsigned long flags;
@@ -318,7 +318,7 @@ static void altera_jtaguart_console_putc(struct uart_port *port, int c)
318318
spin_unlock_irqrestore(&port->lock, flags);
319319
}
320320
#else
321-
static void altera_jtaguart_console_putc(struct uart_port *port, int c)
321+
static void altera_jtaguart_console_putc(struct uart_port *port, unsigned char c)
322322
{
323323
unsigned long flags;
324324

drivers/tty/serial/altera_uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static struct altera_uart altera_uart_ports[CONFIG_SERIAL_ALTERA_UART_MAXPORTS];
438438

439439
#if defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE)
440440

441-
static void altera_uart_console_putc(struct uart_port *port, int c)
441+
static void altera_uart_console_putc(struct uart_port *port, unsigned char c)
442442
{
443443
while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) &
444444
ALTERA_UART_STATUS_TRDY_MSK))

drivers/tty/serial/amba-pl010.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ static struct uart_amba_port *amba_ports[UART_NR];
551551

552552
#ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE
553553

554-
static void pl010_console_putchar(struct uart_port *port, int ch)
554+
static void pl010_console_putchar(struct uart_port *port, unsigned char ch)
555555
{
556556
unsigned int status;
557557

drivers/tty/serial/amba-pl011.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ static struct uart_amba_port *amba_ports[UART_NR];
22552255

22562256
#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
22572257

2258-
static void pl011_console_putchar(struct uart_port *port, int ch)
2258+
static void pl011_console_putchar(struct uart_port *port, unsigned char ch)
22592259
{
22602260
struct uart_amba_port *uap =
22612261
container_of(port, struct uart_amba_port, port);
@@ -2471,7 +2471,7 @@ static struct console amba_console = {
24712471

24722472
#define AMBA_CONSOLE (&amba_console)
24732473

2474-
static void qdf2400_e44_putc(struct uart_port *port, int c)
2474+
static void qdf2400_e44_putc(struct uart_port *port, unsigned char c)
24752475
{
24762476
while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
24772477
cpu_relax();
@@ -2487,7 +2487,7 @@ static void qdf2400_e44_early_write(struct console *con, const char *s, unsigned
24872487
uart_console_write(&dev->port, s, n, qdf2400_e44_putc);
24882488
}
24892489

2490-
static void pl011_putc(struct uart_port *port, int c)
2490+
static void pl011_putc(struct uart_port *port, unsigned char c)
24912491
{
24922492
while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
24932493
cpu_relax();

0 commit comments

Comments
 (0)