]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
printk: Move locking annotation to printk.c
authorMarco Elver <elver@google.com>
Fri, 19 Dec 2025 15:40:22 +0000 (16:40 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 5 Jan 2026 15:43:36 +0000 (16:43 +0100)
With Sparse support gone, Clang is a bit more strict and warns:

./include/linux/console.h:492:50: error: use of undeclared identifier 'console_mutex'
  492 | extern void console_list_unlock(void) __releases(console_mutex);

Since it does not make sense to make console_mutex itself global, move
the annotation to printk.c. Context analysis remains disabled for
printk.c.

This is needed to enable context analysis for modules that include
<linux/console.h>.

Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251219154418.3592607-34-elver@google.com
include/linux/console.h
kernel/printk/printk.c

index fc9f5c5c1b04c8b68fcf090caf2c5bc37d0ab989..f882833bedf0b066a373d531986ff48defe41da2 100644 (file)
@@ -492,8 +492,8 @@ static inline bool console_srcu_read_lock_is_held(void)
 extern int console_srcu_read_lock(void);
 extern void console_srcu_read_unlock(int cookie);
 
-extern void console_list_lock(void) __acquires(console_mutex);
-extern void console_list_unlock(void) __releases(console_mutex);
+extern void console_list_lock(void);
+extern void console_list_unlock(void);
 
 extern struct hlist_head console_list;
 
index 1d765ad242b828500d8b7365324fc12197201ef6..37d16ef27f13ba31e6ff5e3a9b7003e12cac4bf9 100644 (file)
@@ -245,6 +245,7 @@ int devkmsg_sysctl_set_loglvl(const struct ctl_table *table, int write,
  * For console list or console->flags updates
  */
 void console_list_lock(void)
+       __acquires(&console_mutex)
 {
        /*
         * In unregister_console() and console_force_preferred_locked(),
@@ -269,6 +270,7 @@ EXPORT_SYMBOL(console_list_lock);
  * Counterpart to console_list_lock()
  */
 void console_list_unlock(void)
+       __releases(&console_mutex)
 {
        mutex_unlock(&console_mutex);
 }