Skip to content

Commit

Permalink
tty: Move tty_write_message out of kernel/printk
Browse files Browse the repository at this point in the history
This is pure tty code so put it in the tty layer where it can be with the
locking relevant material it uses

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Alan Cox authored and torvalds committed Oct 13, 2008
1 parent 452a00d commit 95f9bfc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
25 changes: 25 additions & 0 deletions drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,31 @@ static inline ssize_t do_tty_write(
return ret;
}

/**
* tty_write_message - write a message to a certain tty, not just the console.
* @tty: the destination tty_struct
* @msg: the message to write
*
* This is used for messages that need to be redirected to a specific tty.
* We don't put it into the syslog queue right now maybe in the future if
* really needed.
*
* We must still hold the BKL and test the CLOSING flag for the moment.
*/

void tty_write_message(struct tty_struct *tty, char *msg)
{
lock_kernel();
if (tty) {
mutex_lock(&tty->atomic_write_lock);
if (tty->ops->write && !test_bit(TTY_CLOSING, &tty->flags))
tty->ops->write(tty, msg, strlen(msg));
tty_write_unlock(tty);
}
unlock_kernel();
return;
}


/**
* tty_write - write method for tty device file
Expand Down
16 changes: 0 additions & 16 deletions kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,22 +1291,6 @@ static int __init disable_boot_consoles(void)
}
late_initcall(disable_boot_consoles);

/**
* tty_write_message - write a message to a certain tty, not just the console.
* @tty: the destination tty_struct
* @msg: the message to write
*
* This is used for messages that need to be redirected to a specific tty.
* We don't put it into the syslog queue right now maybe in the future if
* really needed.
*/
void tty_write_message(struct tty_struct *tty, char *msg)
{
if (tty && tty->ops->write)
tty->ops->write(tty, msg, strlen(msg));
return;
}

#if defined CONFIG_PRINTK

/*
Expand Down

0 comments on commit 95f9bfc

Please sign in to comment.