Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161951AbbKEHWe (ORCPT ); Thu, 5 Nov 2015 02:22:34 -0500 Received: from mail-by2on0085.outbound.protection.outlook.com ([207.46.100.85]:5783 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032411AbbKEHVi (ORCPT ); Thu, 5 Nov 2015 02:21:38 -0500 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=bestguesspass action=none header.from=xilinx.com; From: Soren Brinkmann To: Greg Kroah-Hartman , Jiri Slaby CC: Michal Simek , , , , "Soren Brinkmann" Subject: [PATCH v2 10/10] tty: xuartps: Cleanup: Reformat if-else Date: Wed, 4 Nov 2015 23:21:19 -0800 Message-ID: <1446708079-1105-11-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 2.6.2.3.ga463a5b In-Reply-To: <1446708079-1105-1-git-send-email-soren.brinkmann@xilinx.com> References: <1446708079-1105-1-git-send-email-soren.brinkmann@xilinx.com> X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21920.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD025;1:TI8gyxxmd8ZzLWDCUCCxzJa4Aj74LSNdX/L8CVFDdbBXEj8AjY+4fEQ++LEytEWetzS5KVgZHEveSR3gp7MQHERTcevwj5ohyd3q2SxdtSuJ+hK/EKy3OSMr4KeuwGQRPsUcJYypxzQijaXKfD2/4R4iTEwh/1C9y1ESTSV5fNjOGaX+5ZT55yvbS6K9JS1EFpy33rluUD/2MVCPS8e8AHUxJxvI9fk538mEF59dMpCHLyOKFW0uXBZxzVnpjfslCENFM0iUySiuTID6B0Wfm+6b3vNxouYQ7zCAt3fUKfEr1enXfuH08lbWk1/jED5yzkJwg4qqqXpIWBGOSTZWKCrKdVfmpBf0d12jPzfxDrbAB0INNwQhVMU5sjklgeLm X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(87936001)(229853001)(5001770100001)(5001960100002)(19580405001)(48376002)(50986999)(33646002)(189998001)(86362001)(16796002)(50466002)(76506005)(57986006)(47776003)(76176999)(5003940100001)(92566002)(77096005)(36756003)(19580395003)(81156007)(107886002)(5007970100001)(63266004)(5008740100001)(2950100001)(6806005)(106466001)(36386004)(4001430100002)(50226001)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN1AFFO11HUB010;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11HUB010;2:mgJrFt+eZBqbxvQVDBJ2eRQioGdvxiT/JQgKEL4rb6OxRqgQ25NJOk3bVBQTA7CS0Gj/ZAlG/8bIIeEj0B125mFfKcoAjMSjPBNzn++2k1iUEX6GD6rdetxH01QyzKO8LxFP1HqSjSsybZYRTXFcBpdslH8clL2SGtzJi51e2PE=;3:HifFzLwpMDzv9PFaEeC7YZ6FxtJjr4LZ7TlE9sMPwhO/S5BWCi9Y51QG1LbLODZNxB0Nk6yajjg/udTPuHFzNJC0qz61yysvixgkLOIRZRbmDc2da9rg5WnVXhPHDt0EluWAKT5MhN3VWkrJViPpJ8c8ddCmFFJIwEVKlBvUcEmztoRxfcYrCJQwAzx9G3eD/PCCkfuNDS/i60er1vN0tgIQCQpQgD4GpGxYUEBh8jBHnq3O5jp6J1C5NqAhuVifUYrke1HIheR74hH6q90rDQ==;25:duCGItQ4VuHf7i8bodsSV61DZKoulUkl73oRQxFYcUUbuwk9SdkzUXQgxNhbBQsNmV4sAzyaNbdm893TEL8PsyKTANvZ5mnXm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ICoQh+wix4khD0p/Nu8pdOwHMAOGb7ziVyzKgIkRNthjm6v3vxxvWzrGEGHumpIHzklbWMf4zh5ca+Sd08yHB6XM60yUxtnGKjKdHAGs4Mf+zUwA X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(10201501046)(3002001);SRVR:BN1AFFO11HUB010;BCL:0;PCL:0;RULEID:;SRVR:BN1AFFO11HUB010; X-Forefront-PRVS: 0751474A44 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN1AFFO11HUB010;23:S+Chj7yuJ6n/JNttHwxmVvGzeGjPB7ff/w8qXUz?= =?us-ascii?Q?aQDyaGF5lJVIyOUm/zY5OROxi6IQai4XCXcNaXxIffIP/E2ObHskfv+ZwOJI?= =?us-ascii?Q?Wk4pzNGoDdPxCmeE2VHe3FP7z2NpseDGwIsAtU/Kap8D18XBsWL/jOotMI6w?= =?us-ascii?Q?YF4RHUHj9Sa34Su0j6J7SBhS5KWbXg/qXskVfO/8VqgGmn+ob9e2Qj6Mtbri?= =?us-ascii?Q?QCQNV+/OCGkWCvkFbfHlo4rwP9811GX3RZ5X5foMCxzk3Yck74xKYOcC2pgx?= =?us-ascii?Q?XiUNRGYtmVwKSS1EZEKkiZjbcrN7VsMGPJaTF2Dp6SOsqRVLwaMKHXP6CBq2?= =?us-ascii?Q?Kkd9+p1cvoPTT+JJHRsWSGlkDO3CLwdCneGstgiB4ROR7l6i5tDHcnEhQXFe?= =?us-ascii?Q?CofskoqRuq+XbsSg2Ln0vsWGZQ82xYzyiD9/xrBAgrsL7hBI+s0qgBV/Xcbr?= =?us-ascii?Q?IrDyEmFTK+CYhOP2TnmRISdpH52aeUTzeQbaDx3zsPxr6wcJQ2S24ES4aM6o?= =?us-ascii?Q?KgyDxzOxaAG2xUGEceBbCxMX8tV8WDb/+D/rVmPOuGGvDSWhaqOEMImcaVuP?= =?us-ascii?Q?KVs3Ogzexiv7b9NuXx5iobYGJTS3qIqVlL9/zj/7twMxcfmH456AzXDBrogF?= =?us-ascii?Q?whVpadGGMu5U1Q3uGf53W5cFL59RwaCwdaqWgtNbZNo0VoJvNr/zmJQxVubU?= =?us-ascii?Q?0e6SGZ+8ic+xaSKhtYboWeHcUc+0Jo7zo57i8gHFmbc9m53BkSJpEHj4Gk/N?= =?us-ascii?Q?PxXrXY+6yGgx+G+uJMazUPla+jleVAClkzqmRxS8dS97Gxv7VLnuf8gQcKxF?= =?us-ascii?Q?uIJarVPsEEcFaoonTq8WHWM2g8pSuPDlhIZFpG6IsaMt87gs4fjMSU5I6eET?= =?us-ascii?Q?f6h3Z88gwd/Gz3w5xGVByUfvNUkrBvGJPh78YHumK2d3G8wxUUhJGFh30ogq?= =?us-ascii?Q?4z7DBAR4BTbsBXVz1G3/wHzcTOscVmhK7ao+Uo7C5iIuGXLKFiyAW1/ffseh?= =?us-ascii?Q?10RQ2gkEB/nV6zgQQ1zk/TVcZkNJpLH6HxMNwqML61Vul8MRjuldn/AZtKQe?= =?us-ascii?Q?z1ZGuDIQ=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11HUB010;5:YA0itWCpJEtojF8jCdBDoJcsZMUzxmzALlsJrVqus+SUN6j2hox4tfiBmonw48ZW4klQEgBwQMOSasn7lUk3VIExMk98JGxnBSNTtyz3pWXtwz/4jiP93yXz49gHivuw8dmYzx+/lyMvLfmuTLpKiw==;24:GepGboiZEg+yaVyM0Amk0dgpIm4M5sZHKkWvdLqCUmZwO0t13VjhWE0FYB9Th0YYJ5g/YCt3FUJobfLufeIv/jZFfVQKoNzK5qyx/EujSQo= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2015 07:21:35.7610 (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.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1AFFO11HUB010 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5035 Lines: 172 Convert an if-else into the more common early return on error, reducing the indent level of the happy path. Signed-off-by: Soren Brinkmann --- v2: - added this patch --- drivers/tty/serial/xilinx_uartps.c | 124 ++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 413229661f5d..aed8a31f3399 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -203,58 +203,55 @@ static void cdns_uart_handle_rx(struct uart_port *port, unsigned int isrstatus) isrstatus &= port->read_status_mask; isrstatus &= ~port->ignore_status_mask; - if ((isrstatus & CDNS_UART_IXR_TOUT) || - (isrstatus & CDNS_UART_IXR_RXTRIG)) { - /* Receive Timeout Interrupt */ - while (!(readl(port->membase + CDNS_UART_SR_OFFSET) & - CDNS_UART_SR_RXEMPTY)) { - u32 data; - char status = TTY_NORMAL; - - data = readl(port->membase + CDNS_UART_FIFO_OFFSET); - - /* Non-NULL byte after BREAK is garbage (99%) */ - if (data && (port->read_status_mask & - CDNS_UART_IXR_BRK)) { - port->read_status_mask &= ~CDNS_UART_IXR_BRK; - port->icount.brk++; - if (uart_handle_break(port)) - continue; - } + if (!(isrstatus & (CDNS_UART_IXR_TOUT | CDNS_UART_IXR_RXTRIG))) + return; + + while (!(readl(port->membase + CDNS_UART_SR_OFFSET) & + CDNS_UART_SR_RXEMPTY)) { + u32 data; + char status = TTY_NORMAL; + + data = readl(port->membase + CDNS_UART_FIFO_OFFSET); + + /* Non-NULL byte after BREAK is garbage (99%) */ + if (data && (port->read_status_mask & CDNS_UART_IXR_BRK)) { + port->read_status_mask &= ~CDNS_UART_IXR_BRK; + port->icount.brk++; + if (uart_handle_break(port)) + continue; + } #ifdef SUPPORT_SYSRQ - /* - * uart_handle_sysrq_char() doesn't work if - * spinlocked, for some reason - */ - if (port->sysrq) { - spin_unlock(&port->lock); - if (uart_handle_sysrq_char(port, - (unsigned char)data)) { - spin_lock(&port->lock); - continue; - } + /* + * uart_handle_sysrq_char() doesn't work if + * spinlocked, for some reason + */ + if (port->sysrq) { + spin_unlock(&port->lock); + if (uart_handle_sysrq_char(port, data)) { spin_lock(&port->lock); + continue; } + spin_lock(&port->lock); + } #endif - port->icount.rx++; - - if (isrstatus & CDNS_UART_IXR_PARITY) { - port->icount.parity++; - status = TTY_PARITY; - } else if (isrstatus & CDNS_UART_IXR_FRAMING) { - port->icount.frame++; - status = TTY_FRAME; - } else if (isrstatus & CDNS_UART_IXR_OVERRUN) { - port->icount.overrun++; - } + port->icount.rx++; - uart_insert_char(port, isrstatus, CDNS_UART_IXR_OVERRUN, - data, status); + if (isrstatus & CDNS_UART_IXR_PARITY) { + port->icount.parity++; + status = TTY_PARITY; + } else if (isrstatus & CDNS_UART_IXR_FRAMING) { + port->icount.frame++; + status = TTY_FRAME; + } else if (isrstatus & CDNS_UART_IXR_OVERRUN) { + port->icount.overrun++; } - tty_flip_buffer_push(&port->state->port); + + uart_insert_char(port, isrstatus, CDNS_UART_IXR_OVERRUN, + data, status); } + tty_flip_buffer_push(&port->state->port); } /** @@ -1431,27 +1428,30 @@ static int cdns_uart_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Cannot get uart_port structure\n"); rc = -ENODEV; goto err_out_notif_unreg; - } else { - /* Register the port. - * This function also registers this device with the tty layer - * and triggers invocation of the config_port() entry point. - */ - port->mapbase = res->start; - port->irq = irq; - port->dev = &pdev->dev; - port->uartclk = clk_get_rate(cdns_uart_data->uartclk); - port->private_data = cdns_uart_data; - cdns_uart_data->port = port; - platform_set_drvdata(pdev, port); - rc = uart_add_one_port(&cdns_uart_uart_driver, port); - if (rc) { - dev_err(&pdev->dev, - "uart_add_one_port() failed; err=%i\n", rc); - goto err_out_notif_unreg; - } - return 0; } + /* + * Register the port. + * This function also registers this device with the tty layer + * and triggers invocation of the config_port() entry point. + */ + port->mapbase = res->start; + port->irq = irq; + port->dev = &pdev->dev; + port->uartclk = clk_get_rate(cdns_uart_data->uartclk); + port->private_data = cdns_uart_data; + cdns_uart_data->port = port; + platform_set_drvdata(pdev, port); + + rc = uart_add_one_port(&cdns_uart_uart_driver, port); + if (rc) { + dev_err(&pdev->dev, + "uart_add_one_port() failed; err=%i\n", rc); + goto err_out_notif_unreg; + } + + return 0; + err_out_notif_unreg: #ifdef CONFIG_COMMON_CLK clk_notifier_unregister(cdns_uart_data->uartclk, -- 2.6.2.3.ga463a5b -- 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/