diff options
author | Alan Cox <alan@redhat.com> | 2008-10-13 05:37:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 12:51:40 -0400 |
commit | 9c9f4ded90a59eee84e15f5fd38c03d60184e112 (patch) | |
tree | 925a7f7c30136477b3f8551123fd86b355fd60fb /include | |
parent | 348eb12e5598be97400c749d3d93a71856ae0b2b (diff) |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/tty.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h index e3612c3ac194..b6e6c26883ee 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -209,6 +209,7 @@ struct tty_operations; | |||
209 | 209 | ||
210 | struct tty_struct { | 210 | struct tty_struct { |
211 | int magic; | 211 | int magic; |
212 | struct kref kref; | ||
212 | struct tty_driver *driver; | 213 | struct tty_driver *driver; |
213 | const struct tty_operations *ops; | 214 | const struct tty_operations *ops; |
214 | int index; | 215 | int index; |
@@ -311,6 +312,23 @@ extern int kmsg_redirect; | |||
311 | extern void console_init(void); | 312 | extern void console_init(void); |
312 | extern int vcs_init(void); | 313 | extern int vcs_init(void); |
313 | 314 | ||
315 | /** | ||
316 | * tty_kref_get - get a tty reference | ||
317 | * @tty: tty device | ||
318 | * | ||
319 | * Return a new reference to a tty object. The caller must hold | ||
320 | * sufficient locks/counts to ensure that their existing reference cannot | ||
321 | * go away | ||
322 | */ | ||
323 | |||
324 | extern inline struct tty_struct *tty_kref_get(struct tty_struct *tty) | ||
325 | { | ||
326 | if (tty) | ||
327 | kref_get(&tty->kref); | ||
328 | return tty; | ||
329 | } | ||
330 | extern void tty_kref_put(struct tty_struct *tty); | ||
331 | |||
314 | extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, | 332 | extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, |
315 | const char *routine); | 333 | const char *routine); |
316 | extern char *tty_name(struct tty_struct *tty, char *buf); | 334 | extern char *tty_name(struct tty_struct *tty, char *buf); |