Skip to contentSkip to conversation

tty: small tidying

PATCH New Jiri Slaby 1 participant 5 messages Nov 18, 2021 TTY layer and serial drivers

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

cover tty: small tidying

This is only 4 small random cleanups in tty.

Jiri Slaby (4):
tty: remove TTY_SOFT_SAK part from __do_SAK()
tty: remove tty NULL check from __do_SAK()
tty: clean up whitespace in __do_SAK()
tty: serial, join uport checks in uart_port_shutdown()

 drivers/tty/serial/serial_core.c | 12 ++++--------
 drivers/tty/tty_io.c             | 15 +++++----------
 2 files changed, 9 insertions(+), 18 deletions(-)
Signature · 1 line
2.33.1
author
#1 lore raw

PATCH 1/4 tty: remove TTY_SOFT_SAK part from __do_SAK()

Remove the TTY_SOFT_SAK part. It is never defined, so this is only confusing.

It was actually never defined since its introduction in 0.99.14g.

---
 drivers/tty/tty_io.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/tty/tty_io.c +0 -4
index 6616d4a0d41d..829944dfaf48 100644
@@ -3028,9 +3028,6 @@ static int this_tty(const void *t, struct file *file, unsigned fd)
  */
 void __do_SAK(struct tty_struct *tty)
 {
-#ifdef TTY_SOFT_SAK
-	tty_hangup(tty);
-#else
 	struct task_struct *g, *p;
 	struct pid *session;
 	int		i;
@@ -3074,7 +3071,6 @@ void __do_SAK(struct tty_struct *tty)
 	} while_each_thread(g, p);
 	read_unlock(&tasklist_lock);
 	put_pid(session);
-#endif
 }
 
 static void do_SAK_work(struct work_struct *work)
Signature · 1 line
2.33.1
author
#2 lore raw

PATCH 2/4 tty: remove tty NULL check from __do_SAK()

In reply to Jiri Slaby

Both do_SAK_work() and vc_SAK() provide a valid tty to __do_SAK(), so remove the check.

---
 drivers/tty/tty_io.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/tty/tty_io.c +0 -3
index 829944dfaf48..8e653bb4d7c7 100644
@@ -3033,9 +3033,6 @@ void __do_SAK(struct tty_struct *tty)
 	int		i;
 	unsigned long flags;
 
-	if (!tty)
-		return;
-
 	spin_lock_irqsave(&tty->ctrl.lock, flags);
 	session = get_pid(tty->ctrl.session);
 	spin_unlock_irqrestore(&tty->ctrl.lock, flags);
Signature · 1 line
2.33.1
author
#3 lore raw

PATCH 3/4 tty: clean up whitespace in __do_SAK()

In reply to Jiri Slaby

Remove spaces before the 'i' variable declaration and wrap parameters of group_send_sig_info().

---
 drivers/tty/tty_io.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/tty/tty_io.c +5 -3
index 8e653bb4d7c7..99cad1560876 100644
@@ -3030,7 +3030,7 @@ void __do_SAK(struct tty_struct *tty)
 {
 	struct task_struct *g, *p;
 	struct pid *session;
-	int		i;
+	int i;
 	unsigned long flags;
 
 	spin_lock_irqsave(&tty->ctrl.lock, flags);
@@ -3054,7 +3054,8 @@ void __do_SAK(struct tty_struct *tty)
 		if (p->signal->tty == tty) {
 			tty_notice(tty, "SAK: killed process %d (%s): by controlling tty\n",
 				   task_pid_nr(p), p->comm);
-			group_send_sig_info(SIGKILL, SEND_SIG_PRIV, p, PIDTYPE_SID);
+			group_send_sig_info(SIGKILL, SEND_SIG_PRIV, p,
+					PIDTYPE_SID);
 			continue;
 		}
 		task_lock(p);
@@ -3062,7 +3063,8 @@ void __do_SAK(struct tty_struct *tty)
 		if (i != 0) {
 			tty_notice(tty, "SAK: killed process %d (%s): by fd#%d\n",
 				   task_pid_nr(p), p->comm, i - 1);
-			group_send_sig_info(SIGKILL, SEND_SIG_PRIV, p, PIDTYPE_SID);
+			group_send_sig_info(SIGKILL, SEND_SIG_PRIV, p,
+					PIDTYPE_SID);
 		}
 		task_unlock(p);
 	} while_each_thread(g, p);
Signature · 1 line
2.33.1
author
#4 lore raw

PATCH 4/4 tty: serial, join uport checks in uart_port_shutdown()

In reply to Jiri Slaby

There are two consequent checks of uport != NULL in uart_port_shutdown(). Join these two under a single block.

De-multiline the comments when shuffling with them anyway.

---
 drivers/tty/serial/serial_core.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/tty/serial/serial_core.c +4 -8
index 1e738f265eea..a8750927f03c 100644
@@ -1685,17 +1685,13 @@ static void uart_port_shutdown(struct tty_port *port)
 	 */
 	wake_up_interruptible(&port->delta_msr_wait);
 
-	/*
-	 * Free the IRQ and disable the port.
-	 */
-	if (uport)
+	if (uport) {
+		/* Free the IRQ and disable the port. */
 		uport->ops->shutdown(uport);
 
-	/*
-	 * Ensure that the IRQ handler isn't running on another CPU.
-	 */
-	if (uport)
+		/* Ensure that the IRQ handler isn't running on another CPU. */
 		synchronize_irq(uport->irq);
+	}
 }
 
 static int uart_carrier_raised(struct tty_port *port)
Signature · 1 line
2.33.1