]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'tty/tty-next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 11 Feb 2016 02:43:47 +0000 (13:43 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 11 Feb 2016 02:43:47 +0000 (13:43 +1100)
1  2 
drivers/of/fdt.c
drivers/tty/pty.c
drivers/tty/serial/8250/8250_pci.c
drivers/tty/serial/omap-serial.c
drivers/tty/tty_io.c
drivers/tty/tty_mutex.c
include/linux/sched.h
kernel/audit.c

Simple merge
index 2348fa6137070e19c19d97a5dc436b1a0b762441,78170e7aa3a31acd8c2bb1592bb2064775215b8b..e16a49b507efbd57734b0b8f522d0e2a5dfe03ce
@@@ -674,21 -660,10 +660,17 @@@ static int pty_unix98_install(struct tt
        return pty_common_install(driver, tty, false);
  }
  
- static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)
- {
- }
  /* this is called once with whichever end is closed last */
- static void pty_unix98_shutdown(struct tty_struct *tty)
+ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)
  {
 -      devpts_kill_index(tty->driver_data, tty->index);
 +      struct inode *ptmx_inode;
 +
 +      if (tty->driver->subtype == PTY_TYPE_MASTER)
 +              ptmx_inode = tty->driver_data;
 +      else
 +              ptmx_inode = tty->link->driver_data;
 +      devpts_kill_index(ptmx_inode, tty->index);
 +      devpts_del_ref(ptmx_inode);
  }
  
  static const struct tty_operations ptm_unix98_ops = {
Simple merge
Simple merge
index a7eacef1bd2216ef697c12d046cb8975f9fefb20,8d26ed79bb4c593a1dabbd4ab76b45be2338e8fc..c14c45fefa70d8fa5f522c5715e9ae6931235cad
@@@ -2003,6 -2008,69 +2008,68 @@@ static struct tty_driver *tty_lookup_dr
        return driver;
  }
  
 -              /* safe to drop the kref from tty_driver_lookup_tty() */
 -              tty_kref_put(tty);
+ /**
+  *    tty_open_by_driver      -       open a tty device
+  *    @device: dev_t of device to open
+  *    @inode: inode of device file
+  *    @filp: file pointer to tty
+  *
+  *    Performs the driver lookup, checks for a reopen, or otherwise
+  *    performs the first-time tty initialization.
+  *
+  *    Returns the locked initialized or re-opened &tty_struct
+  *
+  *    Claims the global tty_mutex to serialize:
+  *      - concurrent first-time tty initialization
+  *      - concurrent tty driver removal w/ lookup
+  *      - concurrent tty removal from driver table
+  */
+ static struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode,
+                                            struct file *filp)
+ {
+       struct tty_struct *tty;
+       struct tty_driver *driver = NULL;
+       int index = -1;
+       int retval;
+       mutex_lock(&tty_mutex);
+       driver = tty_lookup_driver(device, filp, &index);
+       if (IS_ERR(driver)) {
+               mutex_unlock(&tty_mutex);
+               return ERR_CAST(driver);
+       }
+       /* check whether we're reopening an existing tty */
+       tty = tty_driver_lookup_tty(driver, inode, index);
+       if (IS_ERR(tty)) {
+               mutex_unlock(&tty_mutex);
+               goto out;
+       }
+       if (tty) {
+               mutex_unlock(&tty_mutex);
+               retval = tty_lock_interruptible(tty);
++              tty_kref_put(tty);  /* drop kref from tty_driver_lookup_tty() */
+               if (retval) {
+                       if (retval == -EINTR)
+                               retval = -ERESTARTSYS;
+                       tty = ERR_PTR(retval);
+                       goto out;
+               }
+               retval = tty_reopen(tty);
+               if (retval < 0) {
+                       tty_unlock(tty);
+                       tty = ERR_PTR(retval);
+               }
+       } else { /* Returns with the tty_lock held for now */
+               tty = tty_init_dev(driver, index);
+               mutex_unlock(&tty_mutex);
+       }
+ out:
+       tty_driver_kref_put(driver);
+       return tty;
+ }
  /**
   *    tty_open                -       open a tty device
   *    @inode: inode of device file
index dfa9ec03fa8e06dfe03a6e0ae04c62a2ac774103,75351e4b77dfbad2843cb96331b1bcdfa4af4672..d8bae67a6174b65e676a887e08dd9e681c2f5693
@@@ -26,13 -24,10 +26,13 @@@ int tty_lock_interruptible(struct tty_s
        if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
                return -EIO;
        tty_kref_get(tty);
 -      return mutex_lock_interruptible(&tty->legacy_mutex);
 +      ret = mutex_lock_interruptible(&tty->legacy_mutex);
 +      if (ret)
 +              tty_kref_put(tty);
 +      return ret;
  }
  
- void __lockfunc tty_unlock(struct tty_struct *tty)
+ void tty_unlock(struct tty_struct *tty)
  {
        if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty))
                return;
Simple merge
diff --cc kernel/audit.c
Simple merge