aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tty.h
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-10-13 05:37:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 12:51:40 -0400
commit9c9f4ded90a59eee84e15f5fd38c03d60184e112 (patch)
tree925a7f7c30136477b3f8551123fd86b355fd60fb /include/linux/tty.h
parent348eb12e5598be97400c749d3d93a71856ae0b2b (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/linux/tty.h')
-rw-r--r--include/linux/tty.h18
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
210struct tty_struct { 210struct 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;
311extern void console_init(void); 312extern void console_init(void);
312extern int vcs_init(void); 313extern 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
324extern inline struct tty_struct *tty_kref_get(struct tty_struct *tty)
325{
326 if (tty)
327 kref_get(&tty->kref);
328 return tty;
329}
330extern void tty_kref_put(struct tty_struct *tty);
331
314extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, 332extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
315 const char *routine); 333 const char *routine);
316extern char *tty_name(struct tty_struct *tty, char *buf); 334extern char *tty_name(struct tty_struct *tty, char *buf);