Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166491
b: refs/heads/master
c: f278a2f
h: refs/heads/master
i:
  166489: 2185427
  166487: fd9d876
v: v3
  • Loading branch information
Dave Young authored and Linus Torvalds committed Sep 27, 2009
1 parent fad1347 commit 448e3df
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 569ec4cc779c8aae03a4659939d08822c9e4a242
refs/heads/master: f278a2f7bbc2239f479eaf63d0b3ae573b1d746c
15 changes: 10 additions & 5 deletions trunk/drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,18 +1389,17 @@ EXPORT_SYMBOL(tty_shutdown);
* of ttys that the driver keeps.
*
* This method gets called from a work queue so that the driver private
* shutdown ops can sleep (needed for USB at least)
* cleanup ops can sleep (needed for USB at least)
*/
static void release_one_tty(struct work_struct *work)
{
struct tty_struct *tty =
container_of(work, struct tty_struct, hangup_work);
struct tty_driver *driver = tty->driver;

if (tty->ops->shutdown)
tty->ops->shutdown(tty);
else
tty_shutdown(tty);
if (tty->ops->cleanup)
tty->ops->cleanup(tty);

tty->magic = 0;
tty_driver_kref_put(driver);
module_put(driver->owner);
Expand All @@ -1415,6 +1414,12 @@ static void release_one_tty(struct work_struct *work)
static void queue_release_one_tty(struct kref *kref)
{
struct tty_struct *tty = container_of(kref, struct tty_struct, kref);

if (tty->ops->shutdown)
tty->ops->shutdown(tty);
else
tty_shutdown(tty);

/* The hangup queue is now free so we can reuse it rather than
waste a chunk of memory for each port */
INIT_WORK(&tty->hangup_work, release_one_tty);
Expand Down
14 changes: 6 additions & 8 deletions trunk/drivers/usb/serial/usb-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void usb_serial_put(struct usb_serial *serial)
* This is the first place a new tty gets used. Hence this is where we
* acquire references to the usb_serial structure and the driver module,
* where we store a pointer to the port, and where we do an autoresume.
* All these actions are reversed in serial_release().
* All these actions are reversed in serial_cleanup().
*/
static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
{
Expand Down Expand Up @@ -339,15 +339,16 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
}

/**
* serial_release - free resources post close/hangup
* serial_cleanup - free resources post close/hangup
* @port: port to free up
*
* Do the resource freeing and refcount dropping for the port.
* Avoid freeing the console.
*
* Called when the last tty kref is dropped.
* Called asynchronously after the last tty kref is dropped,
* and the tty layer has already done the tty_shutdown(tty);
*/
static void serial_release(struct tty_struct *tty)
static void serial_cleanup(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial;
Expand All @@ -361,9 +362,6 @@ static void serial_release(struct tty_struct *tty)

dbg("%s - port %d", __func__, port->number);

/* Standard shutdown processing */
tty_shutdown(tty);

tty->driver_data = NULL;

serial = port->serial;
Expand Down Expand Up @@ -1210,7 +1208,7 @@ static const struct tty_operations serial_ops = {
.chars_in_buffer = serial_chars_in_buffer,
.tiocmget = serial_tiocmget,
.tiocmset = serial_tiocmset,
.shutdown = serial_release,
.cleanup = serial_cleanup,
.install = serial_install,
.proc_fops = &serial_proc_fops,
};
Expand Down
13 changes: 11 additions & 2 deletions trunk/include/linux/tty_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@
*
* void (*shutdown)(struct tty_struct * tty);
*
* This routine is called when a particular tty device is closed for
* the last time freeing up the resources.
* This routine is called synchronously when a particular tty device
* is closed for the last time freeing up the resources.
*
*
* void (*cleanup)(struct tty_struct * tty);
*
* This routine is called asynchronously when a particular tty device
* is closed for the last time freeing up the resources. This is
* actually the second part of shutdown for routines that might sleep.
*
*
* int (*write)(struct tty_struct * tty,
* const unsigned char *buf, int count);
Expand Down Expand Up @@ -233,6 +241,7 @@ struct tty_operations {
int (*open)(struct tty_struct * tty, struct file * filp);
void (*close)(struct tty_struct * tty, struct file * filp);
void (*shutdown)(struct tty_struct *tty);
void (*cleanup)(struct tty_struct *tty);
int (*write)(struct tty_struct * tty,
const unsigned char *buf, int count);
int (*put_char)(struct tty_struct *tty, unsigned char ch);
Expand Down

0 comments on commit 448e3df

Please sign in to comment.