* [PATCH 01/11] amiserial: remove unused DBG_CNT
@ 2021-07-14 9:13 Jiri Slaby
2021-07-14 9:13 ` [PATCH 02/11] amiserial: remove serial_* strings Jiri Slaby
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
The ugly DBG_CNT macro is unused, so remove.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 5ec19c48fb7a..08987c438408 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -31,15 +31,6 @@
#undef SERIAL_DEBUG_FLOW
#undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
-/* Sanity checks */
-
-#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
-#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
- tty->name, (info->tport.flags), serial_driver->refcount,info->count,tty->count,s)
-#else
-#define DBG_CNT(s)
-#endif
-
/*
* End of serial driver configuration section.
*/
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 02/11] amiserial: remove serial_* strings
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 03/11] amiserial: remove stale comment Jiri Slaby
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
Remove a print of serial_name and serial_version from the probe
function, i.e. show_serial_version() from amiga_serial_probe(). The
value of such a print is minimal.
Aside from that, the version is artificial (copied from the serial core
in 2.3.45pre2 and never increased). So inline the version into
seq_printf's format string in rs_proc_show() and remove both strings
completely.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 08987c438408..b2ff5861ca78 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -40,8 +40,6 @@
#include <linux/types.h>
#include <linux/serial.h>
#include <linux/serial_reg.h>
-static char *serial_version = "4.30";
-
#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/sched.h>
@@ -91,7 +89,6 @@ struct serial_state {
};
#define custom amiga_custom
-static char *serial_name = "Amiga-builtin serial driver";
static struct tty_driver *serial_driver;
@@ -1452,7 +1449,7 @@ static inline void line_info(struct seq_file *m, int line,
static int rs_proc_show(struct seq_file *m, void *v)
{
- seq_printf(m, "serinfo:1.0 driver:%s\n", serial_version);
+ seq_printf(m, "serinfo:1.0 driver:4.30\n");
line_info(m, 0, &rs_table[0]);
return 0;
}
@@ -1465,17 +1462,6 @@ static int rs_proc_show(struct seq_file *m, void *v)
* ---------------------------------------------------------------------
*/
-/*
- * This routine prints out the appropriate serial driver version
- * number, and identifies which options were configured into this
- * driver.
- */
-static void show_serial_version(void)
-{
- printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
-}
-
-
static const struct tty_operations serial_ops = {
.open = rs_open,
.close = rs_close,
@@ -1542,8 +1528,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
if (!serial_driver)
return -ENOMEM;
- show_serial_version();
-
/* Initialize the tty_driver structure */
serial_driver->driver_name = "amiserial";
@@ -1628,7 +1612,6 @@ static int __exit amiga_serial_remove(struct platform_device *pdev)
{
struct serial_state *state = platform_get_drvdata(pdev);
- /* printk("Unloading %s: version %s\n", serial_name, serial_version); */
tty_unregister_driver(serial_driver);
put_tty_driver(serial_driver);
tty_port_destroy(&state->tport);
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 03/11] amiserial: remove stale comment
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
2021-07-14 9:13 ` [PATCH 02/11] amiserial: remove serial_* strings Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 04/11] amiserial: remove serial_state::xmit_fifo_size Jiri Slaby
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
The comment about interrupt routines is stale at least since commit
41c28ff1635e (kill _INLINE_) from 2006. So remove the obsolete parts and
leave only "here they start...".
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index b2ff5861ca78..6edd2de01f39 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -179,21 +179,8 @@ static void rs_start(struct tty_struct *tty)
/*
* ----------------------------------------------------------------------
*
- * Here starts the interrupt handling routines. All of the following
- * subroutines are declared as inline and are folded into
- * rs_interrupt(). They were separated out for readability's sake.
+ * Here start the interrupt handling routines.
*
- * Note: rs_interrupt() is a "fast" interrupt, which means that it
- * runs with interrupts turned off. People who may want to modify
- * rs_interrupt() should try to keep the interrupt handler as fast as
- * possible. After you are done making modifications, it is not a bad
- * idea to do:
- *
- * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
- *
- * and look at the resulting assemble code in serial.s.
- *
- * - Ted Ts'o (tytso@mit.edu), 7-Mar-93
* -----------------------------------------------------------------------
*/
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 04/11] amiserial: remove serial_state::xmit_fifo_size
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
2021-07-14 9:13 ` [PATCH 02/11] amiserial: remove serial_* strings Jiri Slaby
2021-07-14 9:13 ` [PATCH 03/11] amiserial: remove stale comment Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 05/11] amiserial: simplify rs_open Jiri Slaby
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
It's always 1, so define a macro for it instead. Note that the check in
set_serial_info is doubled, hence remove the latter.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 6edd2de01f39..0962b197e676 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -77,7 +77,6 @@ struct serial_state {
unsigned long port;
int baud_base;
- int xmit_fifo_size;
int custom_divisor;
int read_status_mask;
int ignore_status_mask;
@@ -95,6 +94,8 @@ static struct tty_driver *serial_driver;
/* number of characters left in xmit buffer before we ask for more */
#define WAKEUP_CHARS 256
+#define XMIT_FIFO_SIZE 1
+
static unsigned char current_ctl_bits;
static void change_speed(struct tty_struct *tty, struct serial_state *info,
@@ -646,7 +647,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
if (!quot)
quot = baud_base / 9600;
info->quot = quot;
- info->timeout = ((info->xmit_fifo_size*HZ*bits*quot) / baud_base);
+ info->timeout = (XMIT_FIFO_SIZE*HZ*bits*quot) / baud_base;
info->timeout += HZ/50; /* Add .02 seconds of slop */
/* CTS flow control flag and modem status interrupts */
@@ -923,7 +924,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
ss->line = tty->index;
ss->port = state->port;
ss->flags = state->tport.flags;
- ss->xmit_fifo_size = state->xmit_fifo_size;
+ ss->xmit_fifo_size = XMIT_FIFO_SIZE;
ss->baud_base = state->baud_base;
ss->close_delay = close_delay;
ss->closing_wait = closing_wait;
@@ -944,7 +945,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) ||
ss->custom_divisor != state->custom_divisor;
if (ss->irq || ss->port != state->port ||
- ss->xmit_fifo_size != state->xmit_fifo_size) {
+ ss->xmit_fifo_size != XMIT_FIFO_SIZE) {
tty_unlock(tty);
return -EINVAL;
}
@@ -958,7 +959,6 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
if ((ss->baud_base != state->baud_base) ||
(close_delay != port->close_delay) ||
(closing_wait != port->closing_wait) ||
- (ss->xmit_fifo_size != state->xmit_fifo_size) ||
((ss->flags & ~ASYNC_USR_MASK) !=
(port->flags & ~ASYNC_USR_MASK))) {
tty_unlock(tty);
@@ -1290,9 +1290,6 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
unsigned long orig_jiffies, char_time;
int lsr;
- if (info->xmit_fifo_size == 0)
- return; /* Just in case.... */
-
orig_jiffies = jiffies;
/*
@@ -1303,7 +1300,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
* Note: we have to use pretty tight timings here to satisfy
* the NIST-PCTS.
*/
- char_time = (info->timeout - HZ/50) / info->xmit_fifo_size;
+ char_time = (info->timeout - HZ/50) / XMIT_FIFO_SIZE;
char_time = char_time / 5;
if (char_time == 0)
char_time = 1;
@@ -1550,7 +1547,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
/* Hardware set up */
state->baud_base = amiga_colorclock;
- state->xmit_fifo_size = 1;
/* set ISRs, and then disable the rx interrupts */
error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state);
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 05/11] amiserial: simplify rs_open
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
` (2 preceding siblings ...)
2021-07-14 9:13 ` [PATCH 04/11] amiserial: remove serial_state::xmit_fifo_size Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 06/11] amiserial: use memset to zero serial_state Jiri Slaby
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
tty->port is already set when rs_open is called given we linked it by
tty_port_link_device(). If it wasn't, the tty layer would WARN loudly.
So it's pointless to set it in rs_open. Instead, use the value in
tty->port to find out the serial_state (info).
It's a fallout of commit b19e2ca77ee4 (TTY: use tty_port_link_device)
which added tty_port_link_device here, but omitted to remove the
tty->port assignment from rs_open.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 0962b197e676..68f8cee389ec 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1361,14 +1361,14 @@ static void rs_hangup(struct tty_struct *tty)
*/
static int rs_open(struct tty_struct *tty, struct file * filp)
{
- struct serial_state *info = rs_table + tty->index;
- struct tty_port *port = &info->tport;
+ struct tty_port *port = tty->port;
+ struct serial_state *info = container_of(port, struct serial_state,
+ tport);
int retval;
port->count++;
port->tty = tty;
tty->driver_data = info;
- tty->port = port;
retval = startup(tty, info);
if (retval) {
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 06/11] amiserial: use memset to zero serial_state
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
` (3 preceding siblings ...)
2021-07-14 9:13 ` [PATCH 05/11] amiserial: simplify rs_open Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 07/11] amiserial: expand serial_isroot Jiri Slaby
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
Zeroing each member of struct serial_state in probe is fragile and
overly complicated. Do one memset for them all.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 68f8cee389ec..558c77653e21 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1527,13 +1527,8 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
tty_set_operations(serial_driver, &serial_ops);
state = rs_table;
+ memset(state, 0, sizeof(*state));
state->port = (int)&custom.serdatr; /* Just to give it a value */
- state->custom_divisor = 0;
- state->icount.cts = state->icount.dsr =
- state->icount.rng = state->icount.dcd = 0;
- state->icount.rx = state->icount.tx = 0;
- state->icount.frame = state->icount.parity = 0;
- state->icount.overrun = state->icount.brk = 0;
tty_port_init(&state->tport);
state->tport.ops = &amiga_port_ops;
tty_port_link_device(&state->tport, serial_driver, 0);
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 07/11] amiserial: expand serial_isroot
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
` (4 preceding siblings ...)
2021-07-14 9:13 ` [PATCH 06/11] amiserial: use memset to zero serial_state Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 08/11] amiserial: expand "custom" Jiri Slaby
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
Having a macro (serial_isroot) for capable(CAP_SYS_ADMIN) does not save
us from anything. It rather obfuscates the code. Hence expand
serial_isroot to be explicit like every other driver is.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 558c77653e21..51b51c5acf96 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -109,8 +109,6 @@ static struct serial_state rs_table[1];
#include <linux/uaccess.h>
-#define serial_isroot() (capable(CAP_SYS_ADMIN))
-
/* some serial hardware definitions */
#define SDR_OVRUN (1<<15)
#define SDR_RBF (1<<14)
@@ -485,11 +483,11 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
retval = request_irq(IRQ_AMIGA_VERTB, ser_vbl_int, 0, "serial status", info);
if (retval) {
- if (serial_isroot()) {
- set_bit(TTY_IO_ERROR, &tty->flags);
- retval = 0;
- }
- goto errout;
+ if (capable(CAP_SYS_ADMIN)) {
+ set_bit(TTY_IO_ERROR, &tty->flags);
+ retval = 0;
+ }
+ goto errout;
}
/* enable both Rx and Tx interrupts */
@@ -955,7 +953,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
if (closing_wait != ASYNC_CLOSING_WAIT_NONE)
closing_wait = msecs_to_jiffies(closing_wait * 10);
- if (!serial_isroot()) {
+ if (!capable(CAP_SYS_ADMIN)) {
if ((ss->baud_base != state->baud_base) ||
(close_delay != port->close_delay) ||
(closing_wait != port->closing_wait) ||
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 08/11] amiserial: expand "custom"
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
` (5 preceding siblings ...)
2021-07-14 9:13 ` [PATCH 07/11] amiserial: expand serial_isroot Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 09/11] amiserial: pack and sort includes Jiri Slaby
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
"custom" macro is a too generic name. Expand it -- that is use
amiga_custom on all the locations.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 86 ++++++++++++++++++++---------------------
1 file changed, 42 insertions(+), 44 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 51b51c5acf96..4658df1b5623 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -87,8 +87,6 @@ struct serial_state {
int x_char; /* xon/xoff character */
};
-#define custom amiga_custom
-
static struct tty_driver *serial_driver;
/* number of characters left in xmit buffer before we ask for more */
@@ -148,9 +146,9 @@ static void rs_stop(struct tty_struct *tty)
if (info->IER & UART_IER_THRI) {
info->IER &= ~UART_IER_THRI;
/* disable Tx interrupt and remove any pending interrupts */
- custom.intena = IF_TBE;
+ amiga_custom.intena = IF_TBE;
mb();
- custom.intreq = IF_TBE;
+ amiga_custom.intreq = IF_TBE;
mb();
}
local_irq_restore(flags);
@@ -166,10 +164,10 @@ static void rs_start(struct tty_struct *tty)
&& info->xmit.buf
&& !(info->IER & UART_IER_THRI)) {
info->IER |= UART_IER_THRI;
- custom.intena = IF_SETCLR | IF_TBE;
+ amiga_custom.intena = IF_SETCLR | IF_TBE;
mb();
/* set a pending Tx Interrupt, transmitter should restart now */
- custom.intreq = IF_SETCLR | IF_TBE;
+ amiga_custom.intreq = IF_SETCLR | IF_TBE;
mb();
}
local_irq_restore(flags);
@@ -194,9 +192,9 @@ static void receive_chars(struct serial_state *info)
icount = &info->icount;
status = UART_LSR_DR; /* We obviously have a character! */
- serdatr = custom.serdatr;
+ serdatr = amiga_custom.serdatr;
mb();
- custom.intreq = IF_RBF;
+ amiga_custom.intreq = IF_RBF;
mb();
if((serdatr & 0x1ff) == 0)
@@ -273,10 +271,10 @@ static void receive_chars(struct serial_state *info)
static void transmit_chars(struct serial_state *info)
{
- custom.intreq = IF_TBE;
+ amiga_custom.intreq = IF_TBE;
mb();
if (info->x_char) {
- custom.serdat = info->x_char | 0x100;
+ amiga_custom.serdat = info->x_char | 0x100;
mb();
info->icount.tx++;
info->x_char = 0;
@@ -286,12 +284,12 @@ static void transmit_chars(struct serial_state *info)
|| info->tport.tty->flow.stopped
|| info->tport.tty->hw_stopped) {
info->IER &= ~UART_IER_THRI;
- custom.intena = IF_TBE;
+ amiga_custom.intena = IF_TBE;
mb();
return;
}
- custom.serdat = info->xmit.buf[info->xmit.tail++] | 0x100;
+ amiga_custom.serdat = info->xmit.buf[info->xmit.tail++] | 0x100;
mb();
info->xmit.tail = info->xmit.tail & (SERIAL_XMIT_SIZE-1);
info->icount.tx++;
@@ -305,7 +303,7 @@ static void transmit_chars(struct serial_state *info)
printk("THRE...");
#endif
if (info->xmit.head == info->xmit.tail) {
- custom.intena = IF_TBE;
+ amiga_custom.intena = IF_TBE;
mb();
info->IER &= ~UART_IER_THRI;
}
@@ -358,10 +356,10 @@ static void check_modem_status(struct serial_state *info)
#endif
port->tty->hw_stopped = 0;
info->IER |= UART_IER_THRI;
- custom.intena = IF_SETCLR | IF_TBE;
+ amiga_custom.intena = IF_SETCLR | IF_TBE;
mb();
/* set a pending Tx Interrupt, transmitter should restart now */
- custom.intreq = IF_SETCLR | IF_TBE;
+ amiga_custom.intreq = IF_SETCLR | IF_TBE;
mb();
tty_wakeup(port->tty);
return;
@@ -374,9 +372,9 @@ static void check_modem_status(struct serial_state *info)
port->tty->hw_stopped = 1;
info->IER &= ~UART_IER_THRI;
/* disable Tx interrupt and remove any pending interrupts */
- custom.intena = IF_TBE;
+ amiga_custom.intena = IF_TBE;
mb();
- custom.intreq = IF_TBE;
+ amiga_custom.intreq = IF_TBE;
mb();
}
}
@@ -418,7 +416,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
{
struct serial_state *info = dev_id;
- if (custom.serdatr & SDR_TBE) {
+ if (amiga_custom.serdatr & SDR_TBE) {
#ifdef SERIAL_DEBUG_INTR
printk("ser_tx_int...");
#endif
@@ -478,7 +476,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
/* Clear anything in the input buffer */
- custom.intreq = IF_RBF;
+ amiga_custom.intreq = IF_RBF;
mb();
retval = request_irq(IRQ_AMIGA_VERTB, ser_vbl_int, 0, "serial status", info);
@@ -491,7 +489,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
}
/* enable both Rx and Tx interrupts */
- custom.intena = IF_SETCLR | IF_RBF | IF_TBE;
+ amiga_custom.intena = IF_SETCLR | IF_RBF | IF_TBE;
mb();
info->IER = UART_IER_MSI;
@@ -557,11 +555,11 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
}
info->IER = 0;
- custom.intena = IF_RBF | IF_TBE;
+ amiga_custom.intena = IF_RBF | IF_TBE;
mb();
/* disable break condition */
- custom.adkcon = AC_UARTBRK;
+ amiga_custom.adkcon = AC_UARTBRK;
mb();
if (C_HUPCL(tty))
@@ -705,7 +703,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
if(cval & UART_LCR_PARITY)
serper |= (SERPER_PARENB);
- custom.serper = serper;
+ amiga_custom.serper = serper;
mb();
}
@@ -749,10 +747,10 @@ static void rs_flush_chars(struct tty_struct *tty)
local_irq_save(flags);
info->IER |= UART_IER_THRI;
- custom.intena = IF_SETCLR | IF_TBE;
+ amiga_custom.intena = IF_SETCLR | IF_TBE;
mb();
/* set a pending Tx Interrupt, transmitter should restart now */
- custom.intreq = IF_SETCLR | IF_TBE;
+ amiga_custom.intreq = IF_SETCLR | IF_TBE;
mb();
local_irq_restore(flags);
}
@@ -791,10 +789,10 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
&& !(info->IER & UART_IER_THRI)) {
info->IER |= UART_IER_THRI;
local_irq_disable();
- custom.intena = IF_SETCLR | IF_TBE;
+ amiga_custom.intena = IF_SETCLR | IF_TBE;
mb();
/* set a pending Tx Interrupt, transmitter should restart now */
- custom.intreq = IF_SETCLR | IF_TBE;
+ amiga_custom.intreq = IF_SETCLR | IF_TBE;
mb();
local_irq_restore(flags);
}
@@ -841,11 +839,11 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
/* Check this ! */
local_irq_save(flags);
- if(!(custom.intenar & IF_TBE)) {
- custom.intena = IF_SETCLR | IF_TBE;
+ if(!(amiga_custom.intenar & IF_TBE)) {
+ amiga_custom.intena = IF_SETCLR | IF_TBE;
mb();
/* set a pending Tx Interrupt, transmitter should restart now */
- custom.intreq = IF_SETCLR | IF_TBE;
+ amiga_custom.intreq = IF_SETCLR | IF_TBE;
mb();
}
local_irq_restore(flags);
@@ -1016,7 +1014,7 @@ static int get_lsr_info(struct serial_state *info, unsigned int __user *value)
unsigned long flags;
local_irq_save(flags);
- status = custom.serdatr;
+ status = amiga_custom.serdatr;
mb();
local_irq_restore(flags);
result = ((status & SDR_TSRE) ? TIOCSER_TEMT : 0);
@@ -1078,9 +1076,9 @@ static int rs_break(struct tty_struct *tty, int break_state)
local_irq_save(flags);
if (break_state == -1)
- custom.adkcon = AC_SETCLR | AC_UARTBRK;
+ amiga_custom.adkcon = AC_SETCLR | AC_UARTBRK;
else
- custom.adkcon = AC_UARTBRK;
+ amiga_custom.adkcon = AC_UARTBRK;
mb();
local_irq_restore(flags);
return 0;
@@ -1257,10 +1255,10 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
state->read_status_mask &= ~UART_LSR_DR;
if (tty_port_initialized(port)) {
/* disable receive interrupts */
- custom.intena = IF_RBF;
+ amiga_custom.intena = IF_RBF;
mb();
/* clear any pending receive interrupt */
- custom.intreq = IF_RBF;
+ amiga_custom.intreq = IF_RBF;
mb();
/*
@@ -1319,7 +1317,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time);
printk("jiff=%lu...", jiffies);
#endif
- while(!((lsr = custom.serdatr) & SDR_TSRE)) {
+ while(!((lsr = amiga_custom.serdatr) & SDR_TSRE)) {
#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
printk("serdatr = %d (jiff=%lu)...", lsr, jiffies);
#endif
@@ -1526,7 +1524,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
state = rs_table;
memset(state, 0, sizeof(*state));
- state->port = (int)&custom.serdatr; /* Just to give it a value */
+ state->port = (int)&amiga_custom.serdatr; /* Just to give it a value */
tty_port_init(&state->tport);
state->tport.ops = &amiga_port_ops;
tty_port_link_device(&state->tport, serial_driver, 0);
@@ -1554,11 +1552,11 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
local_irq_save(flags);
/* turn off Rx and Tx interrupts */
- custom.intena = IF_RBF | IF_TBE;
+ amiga_custom.intena = IF_RBF | IF_TBE;
mb();
/* clear any pending interrupt */
- custom.intreq = IF_RBF | IF_TBE;
+ amiga_custom.intreq = IF_RBF | IF_TBE;
mb();
local_irq_restore(flags);
@@ -1618,8 +1616,8 @@ module_platform_driver_probe(amiga_serial_driver, amiga_serial_probe);
static void amiga_serial_putc(char c)
{
- custom.serdat = (unsigned char)c | 0x100;
- while (!(custom.serdatr & 0x2000))
+ amiga_custom.serdat = (unsigned char)c | 0x100;
+ while (!(amiga_custom.serdatr & 0x2000))
barrier();
}
@@ -1632,9 +1630,9 @@ static void amiga_serial_putc(char c)
static void serial_console_write(struct console *co, const char *s,
unsigned count)
{
- unsigned short intena = custom.intenar;
+ unsigned short intena = amiga_custom.intenar;
- custom.intena = IF_TBE;
+ amiga_custom.intena = IF_TBE;
while (count--) {
if (*s == '\n')
@@ -1642,7 +1640,7 @@ static void serial_console_write(struct console *co, const char *s,
amiga_serial_putc(*s++);
}
- custom.intena = IF_SETCLR | (intena & IF_TBE);
+ amiga_custom.intena = IF_SETCLR | (intena & IF_TBE);
}
static struct tty_driver *serial_console_device(struct console *c, int *index)
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 09/11] amiserial: pack and sort includes
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
` (6 preceding siblings ...)
2021-07-14 9:13 ` [PATCH 08/11] amiserial: expand "custom" Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 10/11] amiserial: switch rs_table to a single state Jiri Slaby
2021-07-14 9:13 ` [PATCH 11/11] amiserial: remove unused state from shutdown Jiri Slaby
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
The #include directives are in different places in amiserial:
1) there is no reason for that, and
2) it makes hard to judge what is included and what is not.
Therefore, move all the includes to a single place and sort them.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 50 ++++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 28 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 4658df1b5623..0a76e70a0b96 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -22,8 +22,6 @@
*
*/
-#include <linux/delay.h>
-
/* Set of debugging defines */
#undef SERIAL_DEBUG_INTR
@@ -35,40 +33,38 @@
* End of serial driver configuration section.
*/
-#include <linux/module.h>
-
-#include <linux/types.h>
-#include <linux/serial.h>
-#include <linux/serial_reg.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
+#include <linux/bitops.h>
#include <linux/circ_buf.h>
#include <linux/console.h>
-#include <linux/major.h>
-#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
#include <linux/fcntl.h>
-#include <linux/ptrace.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
#include <linux/ioport.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/ptrace.h>
#include <linux/seq_file.h>
+#include <linux/serial.h>
+#include <linux/serial_reg.h>
+#include <linux/sched.h>
+#include <linux/signal.h>
#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/bitops.h>
-#include <linux/platform_device.h>
-
-#include <asm/setup.h>
-
-
-#include <asm/irq.h>
+#include <linux/string.h>
+#include <linux/timer.h>
+#include <linux/tty_flip.h>
+#include <linux/tty.h>
+#include <linux/types.h>
+#include <linux/uaccess.h>
#include <asm/amigahw.h>
#include <asm/amigaints.h>
+#include <asm/irq.h>
+#include <asm/setup.h>
struct serial_state {
struct tty_port tport;
@@ -105,8 +101,6 @@ static struct serial_state rs_table[1];
#define NR_PORTS ARRAY_SIZE(rs_table)
-#include <linux/uaccess.h>
-
/* some serial hardware definitions */
#define SDR_OVRUN (1<<15)
#define SDR_RBF (1<<14)
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 10/11] amiserial: switch rs_table to a single state
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
` (7 preceding siblings ...)
2021-07-14 9:13 ` [PATCH 09/11] amiserial: pack and sort includes Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
2021-07-14 9:13 ` [PATCH 11/11] amiserial: remove unused state from shutdown Jiri Slaby
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
amiserial deals only with a single serial, so drop the rs_table array
and NR_PORTS and define a single non-array serial_state for simplicity
instead.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 0a76e70a0b96..dffaff5a587a 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -97,9 +97,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
-static struct serial_state rs_table[1];
-
-#define NR_PORTS ARRAY_SIZE(rs_table)
+static struct serial_state serial_state;
/* some serial hardware definitions */
#define SDR_OVRUN (1<<15)
@@ -1424,7 +1422,7 @@ static inline void line_info(struct seq_file *m, int line,
static int rs_proc_show(struct seq_file *m, void *v)
{
seq_printf(m, "serinfo:1.0 driver:4.30\n");
- line_info(m, 0, &rs_table[0]);
+ line_info(m, 0, &serial_state);
return 0;
}
@@ -1494,11 +1492,11 @@ static const struct tty_port_operations amiga_port_ops = {
*/
static int __init amiga_serial_probe(struct platform_device *pdev)
{
+ struct serial_state *state = &serial_state;
unsigned long flags;
- struct serial_state * state;
int error;
- serial_driver = alloc_tty_driver(NR_PORTS);
+ serial_driver = alloc_tty_driver(1);
if (!serial_driver)
return -ENOMEM;
@@ -1516,7 +1514,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
serial_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(serial_driver, &serial_ops);
- state = rs_table;
memset(state, 0, sizeof(*state));
state->port = (int)&amiga_custom.serdatr; /* Just to give it a value */
tty_port_init(&state->tport);
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 11/11] amiserial: remove unused state from shutdown
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
` (8 preceding siblings ...)
2021-07-14 9:13 ` [PATCH 10/11] amiserial: switch rs_table to a single state Jiri Slaby
@ 2021-07-14 9:13 ` Jiri Slaby
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2021-07-14 9:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
'state' variable is only set but never read in amiserial's shutdown.
Drop it.
It was like this since the driver was added to the tree as far as I can
tell.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/amiserial.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index dffaff5a587a..7ad103e128ac 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -517,13 +517,10 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
static void shutdown(struct tty_struct *tty, struct serial_state *info)
{
unsigned long flags;
- struct serial_state *state;
if (!tty_port_initialized(&info->tport))
return;
- state = info;
-
#ifdef SERIAL_DEBUG_OPEN
printk("Shutting down serial port %d ....\n", info->line);
#endif
--
2.32.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-07-14 9:13 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 9:13 [PATCH 01/11] amiserial: remove unused DBG_CNT Jiri Slaby
2021-07-14 9:13 ` [PATCH 02/11] amiserial: remove serial_* strings Jiri Slaby
2021-07-14 9:13 ` [PATCH 03/11] amiserial: remove stale comment Jiri Slaby
2021-07-14 9:13 ` [PATCH 04/11] amiserial: remove serial_state::xmit_fifo_size Jiri Slaby
2021-07-14 9:13 ` [PATCH 05/11] amiserial: simplify rs_open Jiri Slaby
2021-07-14 9:13 ` [PATCH 06/11] amiserial: use memset to zero serial_state Jiri Slaby
2021-07-14 9:13 ` [PATCH 07/11] amiserial: expand serial_isroot Jiri Slaby
2021-07-14 9:13 ` [PATCH 08/11] amiserial: expand "custom" Jiri Slaby
2021-07-14 9:13 ` [PATCH 09/11] amiserial: pack and sort includes Jiri Slaby
2021-07-14 9:13 ` [PATCH 10/11] amiserial: switch rs_table to a single state Jiri Slaby
2021-07-14 9:13 ` [PATCH 11/11] amiserial: remove unused state from shutdown Jiri Slaby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).