Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d90bb1

Browse files
peterhurleygregkh
authored andcommitted
serial: core: Document and assert lock requirements for irq helpers
The serial core provides two helper functions, uart_handle_dcd_change() and uart_handle_cts_change(), for UART drivers to use at interrupt time. The serial core expects the UART driver to hold the uart port lock when calling these helpers to prevent state corruption. If lockdep enabled, trigger a warning if the uart port lock is not held when calling these helper functions. Signed-off-by: Peter Hurley <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9a37110 commit 4d90bb1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/tty/serial/serial_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,13 +2743,17 @@ EXPORT_SYMBOL(uart_match_port);
27432743
* uart_handle_dcd_change - handle a change of carrier detect state
27442744
* @uport: uart_port structure for the open port
27452745
* @status: new carrier detect status, nonzero if active
2746+
*
2747+
* Caller must hold uport->lock
27462748
*/
27472749
void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
27482750
{
27492751
struct tty_port *port = &uport->state->port;
27502752
struct tty_struct *tty = port->tty;
27512753
struct tty_ldisc *ld;
27522754

2755+
lockdep_assert_held_once(&uport->lock);
2756+
27532757
if (tty) {
27542758
ld = tty_ldisc_ref(tty);
27552759
if (ld) {
@@ -2774,12 +2778,16 @@ EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
27742778
* uart_handle_cts_change - handle a change of clear-to-send state
27752779
* @uport: uart_port structure for the open port
27762780
* @status: new clear to send status, nonzero if active
2781+
*
2782+
* Caller must hold uport->lock
27772783
*/
27782784
void uart_handle_cts_change(struct uart_port *uport, unsigned int status)
27792785
{
27802786
struct tty_port *port = &uport->state->port;
27812787
struct tty_struct *tty = port->tty;
27822788

2789+
lockdep_assert_held_once(&uport->lock);
2790+
27832791
uport->icount.cts++;
27842792

27852793
if (tty_port_cts_enabled(port)) {

0 commit comments

Comments
 (0)