Commit d25a2e74 authored by John Ogness's avatar John Ogness Committed by Petr Mladek
Browse files

tty: tty_io: document console_lock usage



show_cons_active() uses the console_lock to gather information
on registered consoles. Since the console_lock is being used for
multiple reasons, explicitly document these reasons. This will
be useful when the console_lock is split into fine-grained
locking.

Signed-off-by: default avatarJohn Ogness <john.ogness@linutronix.de>
Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20221116162152.193147-10-john.ogness@linutronix.de
parent 0fb413ea
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3526,6 +3526,16 @@ static ssize_t show_cons_active(struct device *dev,
	struct console *c;
	ssize_t count = 0;

	/*
	 * Hold the console_lock to guarantee that no consoles are
	 * unregistered until all console processing is complete.
	 * This also allows safe traversal of the console list and
	 * race-free reading of @flags.
	 *
	 * Take console_lock to serialize device() callback with
	 * other console operations. For example, fg_console is
	 * modified under console_lock when switching vt.
	 */
	console_lock();
	for_each_console(c) {
		if (!c->device)