serial: core: Colocate crucial structure linkage
authorPeter Hurley <peter@hurleysoftware.com>
Thu, 16 Oct 2014 20:54:25 +0000 (16:54 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Nov 2014 02:53:55 +0000 (18:53 -0800)
The key function of uart_add_one_port() is to cross-reference the
UART driver's port structure with the serial core's state table;
keep the assignments together and document this crucial association.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_core.c

index af1d46697e3fa22bc527c759c52e29274d0c0ae0..e0082b73c198c55fac20246e2e564f37e9930d07 100644 (file)
@@ -2590,11 +2590,12 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
                goto out;
        }
 
+       /* Link the port to the driver state table and vice versa */
        state->uart_port = uport;
-       state->pm_state = UART_PM_STATE_UNDEFINED;
+       uport->state = state;
 
+       state->pm_state = UART_PM_STATE_UNDEFINED;
        uport->cons = drv->cons;
-       uport->state = state;
 
        /*
         * If this port is a console, then the spinlock is already