Skip to content

Commit

Permalink
tty: Minor changes to allow kernel modules to use tty ports
Browse files Browse the repository at this point in the history
Change-Id: Ib8b306082d8733b051add1bd1f9b3ec5b091c53f
Signed-off-by: Greg Meiste <w30289@motorola.com>
Reviewed-on: http://gerrit.mot.com/774841
SLTApproved: Slta Waiver <sltawvr@motorola.com>
SME-Granted: SME Approvals Granted
Reviewed-by: Jason Hrycay <jason.hrycay@motorola.com>
Submit-Approved: Jason Hrycay <jason.hrycay@motorola.com>
Tested-by: Jason Hrycay <jason.hrycay@motorola.com>
  • Loading branch information
meisteg authored and Yinjun Chen committed Jun 18, 2016
1 parent ad1ddb0 commit 155500f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions drivers/tty/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ EXPORT_SYMBOL(tty_std_termios);
into this file */

LIST_HEAD(tty_drivers); /* linked list of tty drivers */
EXPORT_SYMBOL(tty_drivers);

/* Mutex to protect creating and releasing a tty. This is shared with
vt.c for deeply disgusting hack reasons */
Expand All @@ -152,7 +153,6 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
#endif
static int __tty_fasync(int fd, struct file *filp, int on);
static int tty_fasync(int fd, struct file *filp, int on);
static void release_tty(struct tty_struct *tty, int idx);
static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
static void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);

Expand Down Expand Up @@ -1510,6 +1510,7 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx)
release_tty(tty, idx);
return ERR_PTR(retval);
}
EXPORT_SYMBOL(tty_init_dev);

void tty_free_termios(struct tty_struct *tty)
{
Expand Down Expand Up @@ -1621,7 +1622,7 @@ EXPORT_SYMBOL(tty_kref_put);
* of ttys that the driver keeps.
*
*/
static void release_tty(struct tty_struct *tty, int idx)
void release_tty(struct tty_struct *tty, int idx)
{
/* This should always be true but check for the moment */
WARN_ON(tty->index != idx);
Expand All @@ -1639,6 +1640,7 @@ static void release_tty(struct tty_struct *tty, int idx)
tty_kref_put(tty->link);
tty_kref_put(tty);
}
EXPORT_SYMBOL(release_tty);

/**
* tty_release_checks - check a tty before real release
Expand Down
1 change: 1 addition & 0 deletions drivers/tty/tty_ldisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
tty_unlock(tty);
return retval;
}
EXPORT_SYMBOL(tty_set_ldisc);

/**
* tty_reset_termios - reset terminal state
Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/tty_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ int tty_port_block_til_ready(struct tty_port *port,
port->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}
if (filp->f_flags & O_NONBLOCK) {
if (!filp || filp->f_flags & O_NONBLOCK) {
/* Indicate we are open */
if (tty->termios.c_cflag & CBAUD)
tty_port_raise_dtr_rts(port);
Expand Down Expand Up @@ -474,7 +474,7 @@ int tty_port_close_start(struct tty_port *port,
unsigned long flags;

spin_lock_irqsave(&port->lock, flags);
if (tty_hung_up_p(filp)) {
if (filp && tty_hung_up_p(filp)) {
spin_unlock_irqrestore(&port->lock, flags);
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions include/linux/tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ extern void free_tty_struct(struct tty_struct *tty);
extern void deinitialize_tty_struct(struct tty_struct *tty);
extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx);
extern int tty_release(struct inode *inode, struct file *filp);
extern void release_tty(struct tty_struct *tty, int idx);
extern int tty_init_termios(struct tty_struct *tty);
extern int tty_standard_install(struct tty_driver *driver,
struct tty_struct *tty);
Expand Down

0 comments on commit 155500f

Please sign in to comment.