staging: greybus: uart: document c_cflag handling in set_termios
Subsystems (3)
PATCH 1/1 staging: greybus: uart: document c_cflag handling in set_termios
gb_tty_set_termios() derives UART line configuration from a subset of termios->c_cflag bits, namely CSIZE, CSTOPB, PARENB, PARODD, CMSPAR, CRTSCTS, CLOCAL and CBAUD. Other c_cflag bits are not interpreted by the driver and are not represented in the Greybus UART protocol messages.
The existing FIXME suggests clearing unsupported bits from termios. However, the driver already limits its behavior to the supported subset when constructing line coding, and unused bits are effectively ignored. No invalid or unsupported values are propagated to the hardware.
Replace the FIXME with a comment documenting which c_cflag bits are consumed by the driver and clarifying that other bits are ignored.
No functional change intended.
--- drivers/staging/greybus/uart.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/staging/greybus/uart.c +14 -2
@@ -494,8 +494,20 @@ static void gb_tty_set_termios(struct tty_struct *tty, (termios->c_cflag & CMSPAR ? 2 : 0) : 0; newline.data_bits =tty_get_char_size (termios->c_cflag); - -/* FIXME: needs to clear unsupported bits in the termios */ +/* +* The Greybus UART driver only interprets a subset of termios +* c_cflag bits when configuring line settings: +* +* - CSIZE via tty_get_char_size() for data bits +* - CSTOPB for stop-bit format +* - PARENB, PARODD, CMSPAR for parity encoding +* - CRTSCTS for hardware flow control +* - CLOCAL for modem control handling +* - CBAUD via C_BAUD() for baud rate and B0 semantics +* +* Other c_cflag bits are ignored as they are not represented in +* the Greybus UART protocol. +*/ gb_tty->clocal = ((termios->c_cflag &CLOCAL ) !=0 );if (C_BAUD (tty) ==B0 ) {
Signature · 1 line
2.53.0
Greg KH
maintainerQuoted 6 lines · Debjeet Banerjee
gb_tty_set_termios()derives UART line configuration from a subset oftermios->c_cflagbits, namely CSIZE, CSTOPB, PARENB, PARODD, CMSPAR, CRTSCTS, CLOCAL and CBAUD. Otherc_cflagbits are not interpreted by the driver and are not represented in the Greybus UART protocol messages.
Quoted 7 lines
The existing FIXME suggests clearing unsupported bits from termios. However, the driver already limits its behavior to the supported subset when constructing line coding, and unused bits are effectively ignored. No invalid or unsupported values are propagated to the hardware.
Replace the FIXME with a comment documenting which
c_cflagbits are consumed by the driver and clarifying that other bits are ignored.
Ignoring is fine, but shouldn't the bits be cleared to let userspace know about this? I think that's why we wrote that FIXME all so long ago.
thanks,
greg k-h
Quoted 3 lines · Greg Kroah-Hartman
Ignoring is fine, but shouldn't the bits be cleared to let userspace know about this? I think that's why we wrote that FIXME all so long ago.
Thanks for the feedback.
That makes sense. I had considered clearing unsupported bits earlier, but held off to avoid modifying termios and left them ignored instead. Your point about userspace visibility makes sense.
I'll send a v2 that clears unsupported c_cflag bits accordingly.
Regards,
Debjeet
PATCH v2 1/1 staging: greybus: uart: clear unsupported c_cflag bits in set_termios
In reply to Greg KHgb_tty_set_termios() derives UART line configuration from a subset of termios->c_cflag bits (CSIZE, CSTOPB, PARENB, PARODD, CMSPAR, CRTSCTS, CLOCAL and CBAUD). Other bits are not interpreted by the driver and are not represented in the Greybus UART protocol.
Mask unsupported c_cflag bits so that userspace-visible termios reflects the supported bits implemented by the driver.
This addresses the existing FIXME.
---
v2:
- Clear unsupported c_cflag bits as suggested
- Update comment to mention the change
--- drivers/staging/greybus/uart.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/staging/greybus/uart.c +18 -1
@@ -495,7 +495,24 @@ static void gb_tty_set_termios(struct tty_struct *tty, newline.data_bits =tty_get_char_size (termios->c_cflag); -/* FIXME: needs to clear unsupported bits in the termios */ +/* +* The Greybus UART driver only interprets a subset of termios +* c_cflag bits when configuring line settings: +* +* - CSIZE via tty_get_char_size() for data bits +* - CSTOPB for stop-bit format +* - PARENB, PARODD, CMSPAR for parity encoding +* - CRTSCTS for hardware flow control +* - CLOCAL for modem control handling +* - CBAUD via C_BAUD() for baud rate and B0 semantics +* +* Mask unsupported c_cflag bits. +*/ + termios->c_cflag &= (CSIZE |CSTOPB | +PARENB |PARODD |CMSPAR | +CLOCAL |CRTSCTS | +CBAUD ); + gb_tty->clocal = ((termios->c_cflag &CLOCAL ) !=0 );if (C_BAUD (tty) ==B0 ) {
Signature · 1 line
2.53.0
Greg KH
maintainerRe: [PATCH v2] staging: greybus: uart: clear unsupported c_cflag bits in set_termios
Quoted 8 lines · Debjeet Banerjee
gb_tty_set_termios()derives UART line configuration from a subset oftermios->c_cflagbits (CSIZE, CSTOPB, PARENB, PARODD, CMSPAR, CRTSCTS, CLOCAL and CBAUD). Other bits are not interpreted by the driver and are not represented in the Greybus UART protocol.Mask unsupported
c_cflagbits so that userspace-visible termios reflects the supported bits implemented by the driver.
Quoted 7 lines
This addresses the existing FIXME.
Signed-off-by Debjeet Banerjee <[email protected]>---
v2:
- Clear unsupportedc_cflagbits as suggested
- Update comment to mention the change
Has this been tested? If not, I'd prefer to leave this as-is until it can be.
thanks,
greg k-h
Re: [PATCH v2] staging: greybus: uart: clear unsupported c_cflag bits in set_termios
Quoted 2 lines · On Mon, 4 May 2026 16:15:32 +0200 Greg KH wrote:
Has this been tested? If not, I'd prefer to leave this as-is until it can be.
Hi Greg,
I don't have the hardware to test this. The change follows the same pattern used by other uart drivers in the kernel that clear unsupported c_cflag bits in set_termios, so the logic should be correct, but I understand your concern.
If you'd prefer to wait for someone with hardware to verify it, that's fine with me.
Regards,
Debjeet