Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761681AbbKVDBJ (ORCPT ); Sat, 21 Nov 2015 22:01:09 -0500 Received: from mail-sn1nam02on0063.outbound.protection.outlook.com ([104.47.36.63]:61625 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752719AbbKVC61 (ORCPT ); Sat, 21 Nov 2015 21:58:27 -0500 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; hurleysoftware.com; dkim=none (message not signed) header.d=none;hurleysoftware.com; dmarc=bestguesspass action=none header.from=xilinx.com; From: Soren Brinkmann To: Greg Kroah-Hartman , Jiri Slaby CC: Michal Simek , , , , "Peter Hurley" , Soren Brinkmann Subject: [PATCH LINUX v3 05/10] tty: xuartps: Improve startup function Date: Sat, 21 Nov 2015 18:59:27 -0800 Message-ID: <1448161172-19717-6-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 2.6.3.3.g9bb996a In-Reply-To: <1448161172-19717-1-git-send-email-soren.brinkmann@xilinx.com> References: <1448161172-19717-1-git-send-email-soren.brinkmann@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21954.006 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.100;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(48376002)(2950100001)(50466002)(33646002)(87936001)(189998001)(76506005)(57986006)(63266004)(36756003)(36386004)(5001960100002)(11100500001)(107886002)(47776003)(50226001)(77096005)(19580395003)(19580405001)(5007970100001)(4001430100002)(50986999)(86362001)(5008740100001)(81156007)(5003940100001)(229853001)(106466001)(76176999)(92566002)(5001770100001)(586003)(6806005)(107986001)(217873001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2NAM02HT064;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501001);SRVR:BL2NAM02HT064; X-Microsoft-Antispam-PRVS: <5a01ed93beab4242ae3d7ddecbe283e1@BL2NAM02HT064.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(3002001)(10201501046);SRVR:BL2NAM02HT064;BCL:0;PCL:0;RULEID:;SRVR:BL2NAM02HT064; X-Forefront-PRVS: 076804FE30 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2015 02:58:23.8890 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT064 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2492 Lines: 70 The startup function is supposed to initialize the UART for receiving. Hence, don't enable the TX part. Also, protect HW accesses with the port lock. Signed-off-by: Soren Brinkmann --- drivers/tty/serial/xilinx_uartps.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index ef114d7a0623..6ffd3bbe3e18 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -758,6 +758,7 @@ static void cdns_uart_set_termios(struct uart_port *port, */ static int cdns_uart_startup(struct uart_port *port) { + unsigned long flags; unsigned int retval = 0, status = 0; retval = request_irq(port->irq, cdns_uart_isr, 0, CDNS_UART_NAME, @@ -765,6 +766,8 @@ static int cdns_uart_startup(struct uart_port *port) if (retval) return retval; + spin_lock_irqsave(&port->lock, flags); + /* Disable the TX and RX */ writel(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS, port->membase + CDNS_UART_CR_OFFSET); @@ -775,15 +778,14 @@ static int cdns_uart_startup(struct uart_port *port) writel(CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST, port->membase + CDNS_UART_CR_OFFSET); - status = readl(port->membase + CDNS_UART_CR_OFFSET); - - /* Clear the RX disable and TX disable bits and then set the TX enable - * bit and RX enable bit to enable the transmitter and receiver. + /* + * Clear the RX disable bit and then set the RX enable bit to enable + * the receiver. */ - writel((status & ~(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS)) - | (CDNS_UART_CR_TX_EN | CDNS_UART_CR_RX_EN | - CDNS_UART_CR_STOPBRK), - port->membase + CDNS_UART_CR_OFFSET); + status = readl(port->membase + CDNS_UART_CR_OFFSET); + status &= CDNS_UART_CR_RX_DIS; + status |= CDNS_UART_CR_RX_EN; + writel(status, port->membase + CDNS_UART_CR_OFFSET); /* Set the Mode Register with normal mode,8 data bits,1 stop bit, * no parity. @@ -814,6 +816,8 @@ static int cdns_uart_startup(struct uart_port *port) CDNS_UART_IXR_RXTRIG | CDNS_UART_IXR_TOUT, port->membase + CDNS_UART_IER_OFFSET); + spin_unlock_irqrestore(&port->lock, flags); + return retval; } -- 2.6.3.3.g9bb996a -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/