Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: introduce tty_port_tty guard()

Having this, guards like these work:
scoped_guard(tty_port_tty, port)
tty_wakeup(scoped_tty());

See e.g. "tty_port: use scoped_guard()" later in this series.

The definitions depend on CONFIG_TTY. It's due to tty_kref_put().
On !CONFIG_TTY, it is an inline and its declaration would conflict. The
guards are not needed in that case, of course.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250814072456.182853-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
e8398b8a 4847d118

+14
+14
include/linux/tty_port.h
··· 270 270 __tty_port_tty_hangup(port, false, false); 271 271 } 272 272 273 + #ifdef CONFIG_TTY 274 + void tty_kref_put(struct tty_struct *tty); 275 + __DEFINE_CLASS_IS_CONDITIONAL(tty_port_tty, true); 276 + __DEFINE_UNLOCK_GUARD(tty_port_tty, struct tty_struct, tty_kref_put(_T->lock)); 277 + static inline class_tty_port_tty_t class_tty_port_tty_constructor(struct tty_port *tport) 278 + { 279 + class_tty_port_tty_t _t = { 280 + .lock = tty_port_tty_get(tport), 281 + }; 282 + return _t; 283 + } 284 + #define scoped_tty() ((struct tty_struct *)(__guard_ptr(tty_port_tty)(&scope))) 285 + #endif 286 + 273 287 #endif