drivers/tty/serial/8250/8250_port.c:2572:2: error: use of undeclared identifier 'class_tty_port_tty_t'

From: kernel test robot

Date: Sat Aug 08 2026 - 01:10:42 EST


Hi Jiri,

FYI, the error/warning still remains.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: bcc44b6785f216eb939226ade6e3910baa30516b
commit: b339809edda15939e7d46b429c420c2bfe4ad946 serial: 8250: use guard()s
date: 12 months ago
config: mips-randconfig-r122-20260808 (https://download.01.org/0day-ci/archive/20260808/202608081221.JTg0gz0g-lkp@xxxxxxxxx/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260808/202608081221.JTg0gz0g-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: b339809edda1 ("serial: 8250: use guard()s")
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608081221.JTg0gz0g-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

>> drivers/tty/serial/8250/8250_port.c:2572:2: error: use of undeclared identifier 'class_tty_port_tty_t'
2572 | scoped_guard(tty_port_tty, tport) {
| ^
include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
429 | __scoped_guard(_name, __UNIQUE_ID(label), args)
| ^
include/linux/cleanup.h:420:7: note: expanded from macro '__scoped_guard'
420 | for (CLASS(_name, scope)(args); \
| ^
include/linux/cleanup.h:290:2: note: expanded from macro 'CLASS'
290 | class_##_name##_t var __cleanup(class_##_name##_destructor) = \
| ^
<scratch space>:35:1: note: expanded from here
35 | class_tty_port_tty_t
| ^
>> drivers/tty/serial/8250/8250_port.c:2572:2: error: call to undeclared function 'class_tty_port_tty_lock_ptr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
429 | __scoped_guard(_name, __UNIQUE_ID(label), args)
| ^
include/linux/cleanup.h:421:7: note: expanded from macro '__scoped_guard'
421 | __guard_ptr(_name)(&scope) || !__is_cond_ptr(_name); \
| ^
include/linux/cleanup.h:403:28: note: expanded from macro '__guard_ptr'
403 | #define __guard_ptr(_name) class_##_name##_lock_ptr
| ^
<scratch space>:41:1: note: expanded from here
41 | class_tty_port_tty_lock_ptr
| ^
>> drivers/tty/serial/8250/8250_port.c:2572:2: error: use of undeclared identifier 'scope'
include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
429 | __scoped_guard(_name, __UNIQUE_ID(label), args)
| ^
include/linux/cleanup.h:421:27: note: expanded from macro '__scoped_guard'
421 | __guard_ptr(_name)(&scope) || !__is_cond_ptr(_name); \
| ^
>> drivers/tty/serial/8250/8250_port.c:2572:2: error: use of undeclared identifier 'class_tty_port_tty_is_conditional'
include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
429 | __scoped_guard(_name, __UNIQUE_ID(label), args)
| ^
include/linux/cleanup.h:421:38: note: expanded from macro '__scoped_guard'
421 | __guard_ptr(_name)(&scope) || !__is_cond_ptr(_name); \
| ^
include/linux/cleanup.h:405:30: note: expanded from macro '__is_cond_ptr'
405 | #define __is_cond_ptr(_name) class_##_name##_is_conditional
| ^
<scratch space>:43:1: note: expanded from here
43 | class_tty_port_tty_is_conditional
| ^
>> drivers/tty/serial/8250/8250_port.c:2573:28: error: call to undeclared function 'scoped_tty'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
2573 | struct tty_struct *tty = scoped_tty();
| ^
drivers/tty/serial/8250/8250_port.c:2573:28: note: did you mean 'stop_tty'?
include/linux/tty.h:404:6: note: 'stop_tty' declared here
404 | void stop_tty(struct tty_struct *tty);
| ^
>> drivers/tty/serial/8250/8250_port.c:2573:22: error: incompatible integer to pointer conversion initializing 'struct tty_struct *' with an expression of type 'int' [-Wint-conversion]
2573 | struct tty_struct *tty = scoped_tty();
| ^ ~~~~~~~~~~~~
6 errors generated.

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SERIAL_8250
Depends on [n]: TTY [=n] && HAS_IOMEM [=y] && !S390
Selected by [y]:
- ECONET [=y]
WARNING: unmet direct dependencies detected for SERIAL_OF_PLATFORM
Depends on [n]: TTY [=n] && HAS_IOMEM [=y] && SERIAL_8250 [=y] && OF [=y]
Selected by [y]:
- ECONET [=y]


vim +/class_tty_port_tty_t +2572 drivers/tty/serial/8250/8250_port.c

2562
2563 /*
2564 * Note in order to avoid the tty port mutex deadlock don't use the next method
2565 * within the uart port callbacks. Primarily it's supposed to be utilized to
2566 * handle a sudden reference clock rate change.
2567 */
2568 void serial8250_update_uartclk(struct uart_port *port, unsigned int uartclk)
2569 {
2570 struct tty_port *tport = &port->state->port;
2571
> 2572 scoped_guard(tty_port_tty, tport) {
> 2573 struct tty_struct *tty = scoped_tty();
2574
2575 guard(rwsem_write)(&tty->termios_rwsem);
2576 guard(mutex)(&tport->mutex);
2577
2578 if (port->uartclk == uartclk)
2579 return;
2580
2581 port->uartclk = uartclk;
2582
2583 if (!tty_port_initialized(tport))
2584 return;
2585
2586 serial8250_do_set_termios(port, &tty->termios, NULL);
2587
2588 return;
2589 }
2590 guard(mutex)(&tport->mutex);
2591 port->uartclk = uartclk;
2592 }
2593 EXPORT_SYMBOL_GPL(serial8250_update_uartclk);
2594

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki