From patchwork Thu Mar 31 08:23:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 8708331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CF4F8C0553 for ; Thu, 31 Mar 2016 08:28:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3887A20125 for ; Thu, 31 Mar 2016 08:28:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67C7120117 for ; Thu, 31 Mar 2016 08:28:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1alXwK-0008En-Tc; Thu, 31 Mar 2016 08:26:52 +0000 Received: from mx2.suse.de ([195.135.220.15]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alXtn-0004Zf-17 for linux-arm-kernel@lists.infradead.org; Thu, 31 Mar 2016 08:24:26 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0F3DBAB5D; Thu, 31 Mar 2016 08:23:52 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Subject: [PATCH 1/2] TTY: serial, handle platform_get_irq retval properly Date: Thu, 31 Mar 2016 10:23:33 +0200 Message-Id: <1459412614-4549-1-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160331_012415_983858_F95A687E X-CRM114-Status: GOOD ( 13.90 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Courbot , Russell King , linux-serial@vger.kernel.org, Stephen Warren , linux-kernel@vger.kernel.org, Michal Simek , Laxman Dewangan , Thierry Reding , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Jiri Slaby , linux-tegra@vger.kernel.org, Peter Korsgaard , Jiri Slaby , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP platform_get_irq: * can fail => handle negative value * can return 0 as irq number, change '<= 0' checks accordingly * returns int => when converted to uint (e.g. uart_port->irq), '< 0' would not work on that, do '< 0' on the int instead * '!retval' does not mean bad irq, 'retval < 0' does Signed-off-by: Jiri Slaby Cc: Russell King Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: "Uwe Kleine-König" Cc: Laxman Dewangan Cc: Stephen Warren Cc: Thierry Reding Cc: Alexandre Courbot Cc: Peter Korsgaard Cc: Michal Simek Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-tegra@vger.kernel.org --- drivers/tty/serial/amba-pl011.c | 8 +++++++- drivers/tty/serial/efm32-uart.c | 4 ++-- drivers/tty/serial/fsl_lpuart.c | 8 +++++++- drivers/tty/serial/pmac_zilog.c | 2 +- drivers/tty/serial/serial-tegra.c | 7 ++++++- drivers/tty/serial/uartlite.c | 2 +- drivers/tty/serial/xilinx_uartps.c | 2 +- 7 files changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 7c198e0a3178..59f31073e746 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2552,11 +2552,17 @@ static int sbsa_uart_probe(struct platform_device *pdev) if (!uap) return -ENOMEM; + ret = platform_get_irq(pdev, 0); + if (ret < 0) { + dev_err(&pdev->dev, "cannot obtain irq\n"); + return ret; + } + uap->port.irq = ret; + uap->reg_offset = vendor_sbsa.reg_offset; uap->vendor = &vendor_sbsa; uap->fifosize = 32; uap->port.iotype = vendor_sbsa.access_32b ? UPIO_MEM32 : UPIO_MEM; - uap->port.irq = platform_get_irq(pdev, 0); uap->port.ops = &sbsa_uart_pops; uap->fixed_baud = baudrate; diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c index 195acc868763..efadba355a20 100644 --- a/drivers/tty/serial/efm32-uart.c +++ b/drivers/tty/serial/efm32-uart.c @@ -724,7 +724,7 @@ static int efm32_uart_probe(struct platform_device *pdev) } ret = platform_get_irq(pdev, 0); - if (ret <= 0) { + if (ret < 0) { dev_dbg(&pdev->dev, "failed to get rx irq\n"); goto err_get_rxirq; } @@ -732,7 +732,7 @@ static int efm32_uart_probe(struct platform_device *pdev) efm_port->port.irq = ret; ret = platform_get_irq(pdev, 1); - if (ret <= 0) + if (ret < 0) ret = efm_port->port.irq + 1; efm_port->txirq = ret; diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 3d790033744e..7f95f782a485 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1830,7 +1830,13 @@ static int lpuart_probe(struct platform_device *pdev) sport->port.dev = &pdev->dev; sport->port.type = PORT_LPUART; sport->port.iotype = UPIO_MEM; - sport->port.irq = platform_get_irq(pdev, 0); + ret = platform_get_irq(pdev, 0); + if (ret < 0) { + dev_err(&pdev->dev, "cannot obtain irq\n"); + return ret; + } + sport->port.irq = ret; + if (sport->lpuart32) sport->port.ops = &lpuart32_pops; else diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index e156e39d620c..0f086a2559ff 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c @@ -1720,7 +1720,7 @@ static int __init pmz_init_port(struct uart_pmac_port *uap) r_ports = platform_get_resource(uap->pdev, IORESOURCE_MEM, 0); irq = platform_get_irq(uap->pdev, 0); - if (!r_ports || !irq) + if (!r_ports || irq < 0) return -ENODEV; uap->port.mapbase = r_ports->start; diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c index 5dde7ed3950a..11e64624dcdc 100644 --- a/drivers/tty/serial/serial-tegra.c +++ b/drivers/tty/serial/serial-tegra.c @@ -1312,7 +1312,12 @@ static int tegra_uart_probe(struct platform_device *pdev) } u->iotype = UPIO_MEM32; - u->irq = platform_get_irq(pdev, 0); + ret = platform_get_irq(pdev, 0); + if (ret < 0) { + dev_err(&pdev->dev, "Couldn't get IRQ\n"); + return ret; + } + u->irq = ret; u->regshift = 2; ret = uart_add_one_port(&tegra_uart_driver, u); if (ret < 0) { diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index c9fdfc8bf47f..0e4e398c66c0 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -693,7 +693,7 @@ static int ulite_probe(struct platform_device *pdev) return -ENODEV; irq = platform_get_irq(pdev, 0); - if (irq <= 0) + if (irq < 0) return -ENXIO; return ulite_assign(&pdev->dev, id, res->start, irq); diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index cd46e64c4255..34a705b15a4f 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1368,7 +1368,7 @@ static int cdns_uart_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); - if (irq <= 0) { + if (irq < 0) { rc = -ENXIO; goto err_out_clk_disable; }