OpenCloudOS-Kernel/drivers/staging
Peter Hurley e359a4e38d tty: Remove tty_hung_up_p() tests from tty drivers' open()
Since at least before 2.6.30, it has not been possible to observe
a hung up file pointer in a tty driver's open() method unless/until
the driver open() releases the tty_lock() (eg., before blocking).

This is because tty_open() adds the file pointer while holding
the tty_lock() _and_ doesn't release the lock until after calling
the tty driver's open() method. [ Before tty_lock(), this was
lock_kernel(). ]

Since __tty_hangup() first waits on the tty_lock() before
enumerating and hanging up the open file pointers, either
__tty_hangup() will wait for the tty_lock() or tty_open() will
not yet have added the file pointer. For example,

CPU 0                          |  CPU 1
                               |
tty_open                       |  __tty_hangup
  ..                           |    ..
  tty_lock                     |    ..
  tty_reopen                   |    tty_lock  / blocks
  ..                           |
  tty_add_file(tty, filp)      |
  ..                           |
  tty->ops->open(tty, filp)    |
    tty_port_open              |
      tty_port_block_til_ready |
        ..                     |
        while (1)              |
          ..                   |
          tty_unlock           |    / unblocks
          schedule             |    for each filp on tty->tty_files
                               |      f_ops = tty_hung_up_fops;
                               |    ..
                               |    tty_unlock
          tty_lock             |
  ..                           |
  tty_unlock                   |

Note that since tty_port_block_til_ready() and similar drop
the tty_lock while blocking, when woken, the file pointer
must then be tested for having been hung up.

Also, fix bit-rotted drivers that used extra_count to track the
port->count bump.

CC: Mikael Starvik <starvik@axis.com>
CC: Samuel Ortiz <samuel@sortiz.org>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-10 16:06:49 -07:00
..
android staging: android: timed_output: fix use after free of dev 2014-06-19 17:33:37 -07:00
bcm drivers/staging: Remove useless return variables 2014-05-26 10:32:15 -07:00
ced1401
comedi staging: comedi: addi_apci_1564: add addi_watchdog dependency 2014-06-18 15:11:22 -07:00
cptm1217
crystalhd
cxt1e1 staging: ctx1e1: remove checks for three macros 2014-05-26 20:19:26 -07:00
dgap Revert "staging: dgap: remove unneeded kfree() in dgap_tty_register_ports()" 2014-05-29 13:59:03 -07:00
dgnc staging: dgnc: Use time_after_eq() 2014-05-25 11:53:44 -07:00
dgrp tty: Remove tty_hung_up_p() tests from tty drivers' open() 2014-07-10 16:06:49 -07:00
et131x Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
frontier Staging/frontier/tranzport: coding style fixes 2014-05-28 14:30:33 -07:00
ft1000 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
fwserial
gdm72xx staging: gdm72xx: code cleanup 2014-05-24 07:23:15 +09:00
gdm724x
goldfish goldfish: clean up staging ifdefs 2014-05-15 13:20:41 -07:00
gs_fpgaboot staging: gs_fpgaboot: Fixed code style issues 2014-05-15 13:56:10 -07:00
iio staging: iio/ad7291: fix error code in ad7291_probe() 2014-06-21 11:35:30 +01:00
imx-drm imx-drm: parallel-display: Fix DPMS default state. 2014-06-19 17:33:37 -07:00
keucr staging: Convert __FUNCTION__ to __func__ 2014-05-25 11:05:07 -07:00
line6 staging/line6: blank line after declaration cleanup 2014-05-15 13:54:29 -07:00
lustre Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-06-12 10:30:18 -07:00
media Merge branch 'topic/omap3isp' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2014-06-12 23:04:28 -07:00
mt29f_spinand staging/mt29f_spinand: coding style fixes 2014-06-01 16:46:57 -07:00
netlogic Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
nokia_h4p
nvec
octeon net: get rid of SET_ETHTOOL_OPS 2014-05-13 17:43:20 -04:00
octeon-usb staging: Convert __FUNCTION__ to __func__ 2014-05-25 11:05:07 -07:00
olpc_dcon staging/olpc_dcon: fix checkpatch warnings 2014-05-24 07:23:15 +09:00
ozwpan staging: ozwpan: Remove useless return variables 2014-05-23 21:11:57 +09:00
panel staging: panel: (coding style) Multiple assignments 2014-05-25 10:59:52 -07:00
phison
quickstart
rtl8188eu staging: rtl8188eu: Remove unneeded version.h inclusion 2014-05-28 14:30:32 -07:00
rtl8192e Merge branch 'next' (accumulated 3.16 merge window patches) into master 2014-06-08 11:31:16 -07:00
rtl8192ee Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
rtl8192u Staging: rtl8192u: r8192U_wx.c Fixed a misplaced brace 2014-05-29 13:43:23 -07:00
rtl8712 staging: rtl8712: return -ENOMEM instead of -1 2014-05-27 11:55:29 -07:00
rtl8723au staging: rtl8723au: Reference correct firmwarefiles with MODULE_FIRMWARE() 2014-06-17 15:39:33 -07:00
rtl8821ae Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
rts5208 staging: rts5208: Use pci_device_id rather than DEFINE_PCI_DEVICE_TABLE 2014-05-24 02:14:31 +09:00
sep drivers/staging: Remove useless return variables 2014-05-26 10:32:15 -07:00
serqt_usb2 staging: serqt_usb2: Clean up initializations of variables 2014-05-03 20:16:39 -04:00
silicom staging: silicom: fix sparse warning for static variable 2014-06-01 16:46:56 -07:00
skein staging: skein: fix sparse warning for static declarations 2014-06-01 16:58:59 -07:00
slicoss staging: slicoss: clean up use of dev_err 2014-05-25 10:59:53 -07:00
speakup Merge branch 'next' (accumulated 3.16 merge window patches) into master 2014-06-08 11:31:16 -07:00
ste_rmi4
tidspbridge staging: tidspbridge: fix an erroneous removal of parentheses 2014-06-26 21:10:31 -04:00
unisys Staging: unisys: visorchipset: Remove filexfer.c 2014-05-23 20:21:10 +09:00
usbip USB driver patches for 3.16-rc1 2014-06-03 09:11:20 -07:00
vme
vt6655 staging: vt6655: refactor iwctl_giwaplist() to avoid -Wframe-larger-than warn. 2014-05-28 14:10:46 -07:00
vt6656 staging: vt6656: rf.c replace DBG_PRT debug messages 2014-05-28 14:10:46 -07:00
winbond staging/winbond: fix a style error 2014-05-23 21:13:40 +09:00
wlags49_h2 staging: wlags49_h2: wl_priv: Remove useless return variables 2014-05-24 01:55:14 +09:00
wlags49_h25
wlan-ng Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
xgifb Staging: xgifb: Fixed a code-style warning 2014-05-24 04:42:20 +09:00
xillybus staging: xillybus: Use devm_ API on probe and remove 2014-05-24 02:11:48 +09:00
Kconfig staging: remove rts5139 driver code 2014-05-23 20:46:41 +09:00
Makefile staging: remove rts5139 driver code 2014-05-23 20:46:41 +09:00
staging.c