This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 46b8efccd61 drivers/serial: make serial line break optional for
DEFAULT_SMALL
46b8efccd61 is described below
commit 46b8efccd61566cdb8ab96bd55cd8b5a808ffb58
Author: Swatantra Yadav <[email protected]>
AuthorDate: Sun Nov 22 15:00:37 2026 +0530
drivers/serial: make serial line break optional for DEFAULT_SMALL
Make TCSBRK and TCSBRKP ioctl handling and uart_tcsendbreak()
optional via CONFIG_SERIAL_BREAK, defaulting to !DEFAULT_SMALL.
When disabled, the break ioctls return -ENOTTY (causing tcsendbreak()
to return -1 with errno set to ENOTTY), saving 634 bytes of Flash
(text) and 160 bytes of data/bss on small targets.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Swatantra Yadav <[email protected]>
---
Documentation/os/drivers/character/serial.rst | 9 +++++++++
drivers/serial/Kconfig | 9 +++++++++
drivers/serial/serial.c | 6 ++++++
3 files changed, 24 insertions(+)
diff --git a/Documentation/os/drivers/character/serial.rst
b/Documentation/os/drivers/character/serial.rst
index 0d5cd7daff2..d57db5c665d 100644
--- a/Documentation/os/drivers/character/serial.rst
+++ b/Documentation/os/drivers/character/serial.rst
@@ -79,6 +79,15 @@ Serial Device Drivers
for the master and the slave; the signal goes to the foreground
process group of the slave.
+- **Serial line break**. When ``CONFIG_SERIAL_BREAK`` is enabled
+ (the default except for ``DEFAULT_SMALL``), ``TCSBRK`` and
+ ``TCSBRKP`` (used by POSIX ``tcsendbreak()``) request a line
+ break via the lower half driver's ``TIOCSBRK`` and ``TIOCCBRK``
+ ioctls. When disabled, the driver returns ``-ENOTTY`` (causing
+ ``ioctl()`` and ``tcsendbreak()`` to return -1 with ``errno``
+ set to ``ENOTTY``), reducing code size on memory-constrained
+ targets.
+
- **User Access**. Serial drivers are, ultimately, normal
`character drivers <#chardrivers>`__ and are accessed as other
character drivers.
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index cd7fbcb8d57..a5bc5210ab5 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -344,6 +344,15 @@ config SERIAL_TERMIOS
Note: other software settings (echo, \r\n<->\n, break, tcflush)
are always supported.
+config SERIAL_BREAK
+ bool "Serial line break (tcsendbreak) support"
+ default !DEFAULT_SMALL
+ ---help---
+ Enable TCSBRK and TCSBRKP ioctl handling and the
+ uart_tcsendbreak() function. When disabled, the break
+ ioctls return -ENOTTY (and tcsendbreak() returns -1 with
+ errno set to ENOTTY), saving Flash on small targets.
+
config TTY_LAUNCH
bool "Enable feature TTY launch program"
depends on SCHED_HPWORK
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index b1032e0e4c4..2d4020875f7 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -134,9 +134,11 @@ static inline ssize_t uart_irqwritev(FAR uart_dev_t *dev,
static int uart_tcdrain(FAR uart_dev_t *dev,
bool cancelable, clock_t timeout);
+#ifdef CONFIG_SERIAL_BREAK
static int uart_tcsendbreak(FAR uart_dev_t *dev,
FAR struct file *filep,
unsigned int ms);
+#endif
/* Character driver methods */
@@ -810,6 +812,7 @@ static int uart_tcdrain(FAR uart_dev_t *dev,
return ret;
}
+#ifdef CONFIG_SERIAL_BREAK
/****************************************************************************
* Name: uart_tcsendbreak
*
@@ -875,6 +878,7 @@ static int uart_tcsendbreak(FAR uart_dev_t *dev, FAR struct
file *filep,
return ret;
}
+#endif
/****************************************************************************
* Name: uart_open
@@ -2071,6 +2075,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
}
break;
+#ifdef CONFIG_SERIAL_BREAK
case TCSBRK:
{
/* Non-standard Break specifies duration in milliseconds */
@@ -2086,6 +2091,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
ret = uart_tcsendbreak(dev, filep, arg * 100);
}
break;
+#endif
case TIOCGWINSZ:
{