tty: Add a kref count

Introduce a kref to the tty structure and use it to protect the tty->signal
tty references. For now we don't introduce it for anything else.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox
2008-10-13 10:37:26 +01:00
committed by Linus Torvalds
parent 348eb12e55
commit 9c9f4ded90
4 changed files with 71 additions and 10 deletions

View File

@ -209,6 +209,7 @@ struct tty_operations;
struct tty_struct {
int magic;
struct kref kref;
struct tty_driver *driver;
const struct tty_operations *ops;
int index;
@ -311,6 +312,23 @@ extern int kmsg_redirect;
extern void console_init(void);
extern int vcs_init(void);
/**
* tty_kref_get - get a tty reference
* @tty: tty device
*
* Return a new reference to a tty object. The caller must hold
* sufficient locks/counts to ensure that their existing reference cannot
* go away
*/
extern inline struct tty_struct *tty_kref_get(struct tty_struct *tty)
{
if (tty)
kref_get(&tty->kref);
return tty;
}
extern void tty_kref_put(struct tty_struct *tty);
extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
const char *routine);
extern char *tty_name(struct tty_struct *tty, char *buf);