aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2014-10-16 14:59:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-05 19:26:13 -0500
commit5b239542207d83687489a22e6dd93ffef1ad9eb9 (patch)
tree040f182e92689cad6f921ecfc4c67299c432aba7
parent8a8a55105dd2857743dc4f7097f28a6cb2e696ee (diff)
tty: Replace open-coded tty_get_pgrp()
Replace open-coded instances of tty_get_pgrp(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Reviewed-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/pty.c24
-rw-r--r--drivers/tty/tty_io.c8
2 files changed, 8 insertions, 24 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 7c4447a5c0f4..4c0218db85ad 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -207,15 +207,12 @@ static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
207/* Send a signal to the slave */ 207/* Send a signal to the slave */
208static int pty_signal(struct tty_struct *tty, int sig) 208static int pty_signal(struct tty_struct *tty, int sig)
209{ 209{
210 unsigned long flags;
211 struct pid *pgrp; 210 struct pid *pgrp;
212 211
213 if (tty->link) { 212 if (tty->link) {
214 spin_lock_irqsave(&tty->link->ctrl_lock, flags); 213 pgrp = tty_get_pgrp(tty->link);
215 pgrp = get_pid(tty->link->pgrp); 214 if (pgrp)
216 spin_unlock_irqrestore(&tty->link->ctrl_lock, flags); 215 kill_pgrp(pgrp, sig, 1);
217
218 kill_pgrp(pgrp, sig, 1);
219 put_pid(pgrp); 216 put_pid(pgrp);
220 } 217 }
221 return 0; 218 return 0;
@@ -278,7 +275,6 @@ static void pty_set_termios(struct tty_struct *tty,
278static int pty_resize(struct tty_struct *tty, struct winsize *ws) 275static int pty_resize(struct tty_struct *tty, struct winsize *ws)
279{ 276{
280 struct pid *pgrp, *rpgrp; 277 struct pid *pgrp, *rpgrp;
281 unsigned long flags;
282 struct tty_struct *pty = tty->link; 278 struct tty_struct *pty = tty->link;
283 279
284 /* For a PTY we need to lock the tty side */ 280 /* For a PTY we need to lock the tty side */
@@ -286,17 +282,9 @@ static int pty_resize(struct tty_struct *tty, struct winsize *ws)
286 if (!memcmp(ws, &tty->winsize, sizeof(*ws))) 282 if (!memcmp(ws, &tty->winsize, sizeof(*ws)))
287 goto done; 283 goto done;
288 284
289 /* Get the PID values and reference them so we can 285 /* Signal the foreground process group of both ptys */
290 avoid holding the tty ctrl lock while sending signals. 286 pgrp = tty_get_pgrp(tty);
291 We need to lock these individually however. */ 287 rpgrp = tty_get_pgrp(pty);
292
293 spin_lock_irqsave(&tty->ctrl_lock, flags);
294 pgrp = get_pid(tty->pgrp);
295 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
296
297 spin_lock_irqsave(&pty->ctrl_lock, flags);
298 rpgrp = get_pid(pty->pgrp);
299 spin_unlock_irqrestore(&pty->ctrl_lock, flags);
300 288
301 if (pgrp) 289 if (pgrp)
302 kill_pgrp(pgrp, SIGWINCH, 1); 290 kill_pgrp(pgrp, SIGWINCH, 1);
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 3d71642b18ad..6bf5f44d215e 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2324,18 +2324,14 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg)
2324int tty_do_resize(struct tty_struct *tty, struct winsize *ws) 2324int tty_do_resize(struct tty_struct *tty, struct winsize *ws)
2325{ 2325{
2326 struct pid *pgrp; 2326 struct pid *pgrp;
2327 unsigned long flags;
2328 2327
2329 /* Lock the tty */ 2328 /* Lock the tty */
2330 mutex_lock(&tty->winsize_mutex); 2329 mutex_lock(&tty->winsize_mutex);
2331 if (!memcmp(ws, &tty->winsize, sizeof(*ws))) 2330 if (!memcmp(ws, &tty->winsize, sizeof(*ws)))
2332 goto done; 2331 goto done;
2333 /* Get the PID values and reference them so we can
2334 avoid holding the tty ctrl lock while sending signals */
2335 spin_lock_irqsave(&tty->ctrl_lock, flags);
2336 pgrp = get_pid(tty->pgrp);
2337 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
2338 2332
2333 /* Signal the foreground process group */
2334 pgrp = tty_get_pgrp(tty);
2339 if (pgrp) 2335 if (pgrp)
2340 kill_pgrp(pgrp, SIGWINCH, 1); 2336 kill_pgrp(pgrp, SIGWINCH, 1);
2341 put_pid(pgrp); 2337 put_pid(pgrp);