From patchwork Thu Dec 23 14:40:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 12698366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2D50C433EF for ; Thu, 23 Dec 2021 14:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fdbUw7gdKov2UXsrC5/S9J/zXua5b7JQEIqTJOHWMnk=; b=Fp2GSxdYicsOQV LKTSLZHMEbzkS3E1GkFxT/4QOBSKYJOlUjwUW1cb+U2CXrclQzTo2oO65bt8FQS+juD/jDdLRwnkl 4dcWx+oJGpCuiyw7AJLZrTuZ7Z8q0E1BM7RCnDE2SD7F66nAHu9QAqzpHDN1qYApCOmB6c5OlZu+F 7G+6IIokw36ZrFNyUD/Z8JvLDe+JXqUJRlBrKYZL2YY9axPXcGsS2ZkYANpgdmSjQNYzsIb2uk/Tc TAWMl2AGRV15fwIaOuIUSUKvT1t1XLx9Nh8vQXo4P5OUEGEVn2F88AkvlSFYzT7cIiGoxOANxlwfw dAZCj9OpCXqhtSoxHTVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0PH0-00CuI2-E7; Thu, 23 Dec 2021 14:40:50 +0000 Received: from smtp23.cstnet.cn ([159.226.251.23] helo=cstnet.cn) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0PGw-00CuHH-QR for linux-arm-kernel@lists.infradead.org; Thu, 23 Dec 2021 14:40:48 +0000 Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-03 (Coremail) with SMTP id rQCowACnrlpmisRhYLlqBA--.46420S2; Thu, 23 Dec 2021 22:40:38 +0800 (CST) From: Jiasheng Jiang To: robin.murphy@arm.com, andy.shevchenko@gmail.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, liviu.dudau@arm.com, sudeep.holla@arm.com, lorenzo.pieralisi@arm.com Cc: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH v4] serial: mps2-uart: Check for error irq Date: Thu, 23 Dec 2021 22:40:37 +0800 Message-Id: <20211223144037.1400435-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: rQCowACnrlpmisRhYLlqBA--.46420S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw1DAryDArW8CrW3Ww47XFb_yoW8AFW8pF 1ktFZ8ZrWkGaySgF9rZr1UZF43Cayvvay7Xr1a9342ka45JFnxC345CFnIvF1kZrWkJw4f Xr45tFW8uF10vFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvK14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkIecxEwVAFwVW5XwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAI cVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxh VjvjDU0xZFpf9x0JUS_M3UUUUU= X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211223_064047_258172_08BFBB31 X-CRM114-Status: GOOD ( 10.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For the possible failure of the platform_get_irq(), the returned irq could be error number and will finally cause the failure of the request_irq(). Consider that platform_get_irq() can now in certain cases return -EPROBE_DEFER, and the consequences of letting request_irq() effectively convert that into -EINVAL, even at probe time rather than later on. So it might be better to check just now. Fixes: 041f031def33 ("serial: mps2-uart: add MPS2 UART driver") Signed-off-by: Jiasheng Jiang --- Changelog: v3 -> v4 *Change 1. Using error variable to check. *Change 2. Add new commit message. *Change 3. Refine the commit message to be more reasonable. --- drivers/tty/serial/mps2-uart.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c index 587b42f754cb..24a52300d8d9 100644 --- a/drivers/tty/serial/mps2-uart.c +++ b/drivers/tty/serial/mps2-uart.c @@ -584,11 +584,29 @@ static int mps2_init_port(struct platform_device *pdev, if (mps_port->flags & UART_PORT_COMBINED_IRQ) { - mps_port->port.irq = platform_get_irq(pdev, 0); + ret = platform_get_irq(pdev, 0); + if (ret < 0) + return ret; + + mps_port->port.irq = ret; } else { - mps_port->rx_irq = platform_get_irq(pdev, 0); - mps_port->tx_irq = platform_get_irq(pdev, 1); - mps_port->port.irq = platform_get_irq(pdev, 2); + ret = platform_get_irq(pdev, 0); + if (ret < 0) + return ret; + + mps_port->rx_irq = ret; + + ret = platform_get_irq(pdev, 1); + if (ret < 0) + return ret; + + mps_port->tx_irq = ret; + + ret = platform_get_irq(pdev, 2); + if (ret < 0) + return ret; + + mps_port->port.irq = ret; } return ret;