2022-11-15 07:29:52

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 1/4] tty: serial: altera_jtaguart: remove flag from altera_jtaguart_rx_chars()

TTY_NORMAL is the only value it contains, so remove the variable and use
the constant instead.

Cc: Tobias Klauser <[email protected]>
Signed-off-by: Jiri Slaby (SUSE) <[email protected]>
---
drivers/tty/serial/altera_jtaguart.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index aa49553fac58..8d1729711584 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -126,18 +126,17 @@ static void altera_jtaguart_set_termios(struct uart_port *port,
static void altera_jtaguart_rx_chars(struct altera_jtaguart *pp)
{
struct uart_port *port = &pp->port;
- unsigned char ch, flag;
+ unsigned char ch;
unsigned long status;

while ((status = readl(port->membase + ALTERA_JTAGUART_DATA_REG)) &
ALTERA_JTAGUART_DATA_RVALID_MSK) {
ch = status & ALTERA_JTAGUART_DATA_DATA_MSK;
- flag = TTY_NORMAL;
port->icount.rx++;

if (uart_handle_sysrq_char(port, ch))
continue;
- uart_insert_char(port, 0, 0, ch, flag);
+ uart_insert_char(port, 0, 0, ch, TTY_NORMAL);
}

tty_flip_buffer_push(&port->state->port);
--
2.38.1



2022-11-15 07:30:51

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 4/4] tty: serial: altera_jtaguart: remove struct altera_jtaguart

It contains only struct uart_port, so no need for another structure.
Remove it and convert the rest to use struct uart_port directly.

Cc: Tobias Klauser <[email protected]>
Signed-off-by: Jiri Slaby (SUSE) <[email protected]>
---
drivers/tty/serial/altera_jtaguart.c | 29 +++++++++-------------------
1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index 6808abd27785..9f843d1cee40 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -50,13 +50,6 @@
#define ALTERA_JTAGUART_CONTROL_AC_MSK 0x00000400
#define ALTERA_JTAGUART_CONTROL_WSPACE_MSK 0xFFFF0000

-/*
- * Local per-uart structure.
- */
-struct altera_jtaguart {
- struct uart_port port;
-};
-
static unsigned int altera_jtaguart_tx_space(struct uart_port *port, u32 *ctlp)
{
u32 ctl = readl(port->membase + ALTERA_JTAGUART_CONTROL_REG);
@@ -115,9 +108,8 @@ static void altera_jtaguart_set_termios(struct uart_port *port,
tty_termios_copy_hw(termios, old);
}

-static void altera_jtaguart_rx_chars(struct altera_jtaguart *pp)
+static void altera_jtaguart_rx_chars(struct uart_port *port)
{
- struct uart_port *port = &pp->port;
unsigned char ch;
unsigned long status;

@@ -134,9 +126,8 @@ static void altera_jtaguart_rx_chars(struct altera_jtaguart *pp)
tty_flip_buffer_push(&port->state->port);
}

-static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp)
+static void altera_jtaguart_tx_chars(struct uart_port *port)
{
- struct uart_port *port = &pp->port;
unsigned int count;
u8 ch;

@@ -151,8 +142,6 @@ static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp)
static irqreturn_t altera_jtaguart_interrupt(int irq, void *data)
{
struct uart_port *port = data;
- struct altera_jtaguart *pp =
- container_of(port, struct altera_jtaguart, port);
unsigned int isr;

isr = (readl(port->membase + ALTERA_JTAGUART_CONTROL_REG) >>
@@ -161,9 +150,9 @@ static irqreturn_t altera_jtaguart_interrupt(int irq, void *data)
spin_lock(&port->lock);

if (isr & ALTERA_JTAGUART_CONTROL_RE_MSK)
- altera_jtaguart_rx_chars(pp);
+ altera_jtaguart_rx_chars(port);
if (isr & ALTERA_JTAGUART_CONTROL_WE_MSK)
- altera_jtaguart_tx_chars(pp);
+ altera_jtaguart_tx_chars(port);

spin_unlock(&port->lock);

@@ -265,7 +254,7 @@ static const struct uart_ops altera_jtaguart_ops = {
};

#define ALTERA_JTAGUART_MAXPORTS 1
-static struct altera_jtaguart altera_jtaguart_ports[ALTERA_JTAGUART_MAXPORTS];
+static struct uart_port altera_jtaguart_ports[ALTERA_JTAGUART_MAXPORTS];

#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE)

@@ -308,7 +297,7 @@ static void altera_jtaguart_console_putc(struct uart_port *port, unsigned char c
static void altera_jtaguart_console_write(struct console *co, const char *s,
unsigned int count)
{
- struct uart_port *port = &(altera_jtaguart_ports + co->index)->port;
+ struct uart_port *port = &altera_jtaguart_ports[co->index];

uart_console_write(port, s, count, altera_jtaguart_console_putc);
}
@@ -320,7 +309,7 @@ static int __init altera_jtaguart_console_setup(struct console *co,

if (co->index < 0 || co->index >= ALTERA_JTAGUART_MAXPORTS)
return -EINVAL;
- port = &altera_jtaguart_ports[co->index].port;
+ port = &altera_jtaguart_ports[co->index];
if (port->membase == NULL)
return -ENODEV;
return 0;
@@ -400,7 +389,7 @@ static int altera_jtaguart_probe(struct platform_device *pdev)
if (i >= ALTERA_JTAGUART_MAXPORTS)
return -EINVAL;

- port = &altera_jtaguart_ports[i].port;
+ port = &altera_jtaguart_ports[i];

res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res_mem)
@@ -444,7 +433,7 @@ static int altera_jtaguart_remove(struct platform_device *pdev)
if (i == -1)
i = 0;

- port = &altera_jtaguart_ports[i].port;
+ port = &altera_jtaguart_ports[i];
uart_remove_one_port(&altera_jtaguart_driver, port);
iounmap(port->membase);

--
2.38.1


2022-11-15 15:30:49

by Tobias Klauser

[permalink] [raw]
Subject: Re: [PATCH 4/4] tty: serial: altera_jtaguart: remove struct altera_jtaguart

On 2022-11-15 at 08:17:24 +0100, Jiri Slaby (SUSE) <[email protected]> wrote:
> It contains only struct uart_port, so no need for another structure.
> Remove it and convert the rest to use struct uart_port directly.
>
> Cc: Tobias Klauser <[email protected]>
> Signed-off-by: Jiri Slaby (SUSE) <[email protected]>

Reviewed-by: Tobias Klauser <[email protected]>

Thanks

2022-11-15 15:31:51

by Tobias Klauser

[permalink] [raw]
Subject: Re: [PATCH 1/4] tty: serial: altera_jtaguart: remove flag from altera_jtaguart_rx_chars()

On 2022-11-15 at 08:17:21 +0100, Jiri Slaby (SUSE) <[email protected]> wrote:
> TTY_NORMAL is the only value it contains, so remove the variable and use
> the constant instead.
>
> Cc: Tobias Klauser <[email protected]>
> Signed-off-by: Jiri Slaby (SUSE) <[email protected]>

Reviewed-by: Tobias Klauser <[email protected]>

Thanks