From patchwork Tue May 21 15:45:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erwan Le Ray X-Patchwork-Id: 164739 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1769059ili; Tue, 21 May 2019 08:47:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFaUbyhKBFohvKLYJ3jRutNWRB11GBOwTY8cQsJEfFOhA7FzQv0ZmJ1LiEaq9EvKrtcwaK X-Received: by 2002:aa7:8dc3:: with SMTP id j3mr88778166pfr.141.1558453648054; Tue, 21 May 2019 08:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558453648; cv=none; d=google.com; s=arc-20160816; b=HrLK2H+ORQlEtH5tPhD76kN1bk+9MstYuHM3mdBQyghAezg9mu3+gCQzQrvdDHrelT 42csRtZGkevowyYd03bEk4mOgWe0/6PcrfNFstT0UsvGVy9V2Zv7owdPKxZcX4JS0hLR 5dgumiP2JiAEeknDlDYmLYYY3zhlrXgDl7+tws6Pv3ih8q68bdtRCUE2IqTFGe5/aLl8 pJNRMVFnFs1NvwnAdh+JhhCngXV6q+sOfWIS2X5n+tL4w74rhEE+72oEnC5njRJzvl+B kQiKR08qYYsy0IienqJ+MGnyQm9QEjjB0+xkGqd+jynIXuX1zd/SkEIqWjNvoF9iPaV/ e3MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=/FwJ1TQFru+32XoeDMyEaHFno8vBWsvjxdibmbx8Z44=; b=n1PcKb+TZGjFIxbm2CyujYoPAjyYKwibtyD4OwkG13hE3kkxsOsTbdP3kBgq3wPnW/ 2uVRT59wCHkT8XJTl1WVZyuu0aHxXov/8bQl6Zvc6YUJ7nuBgzrsl3I8OGgagqLxVhW7 rTK6YhjJ5kU2/lZR8DjiTAKz48va6hN/T2VVPUDqBNYT9rNO2Sfl1A6gObP8f2wVT+gi WKAWvPKckNFU4wu9Id+Qb7c1D6TS/4S29phlcqOV4Gyu3peG9u4SeLM7lJKnkCkTxfC3 npJTLS04go+XZbj/tg5h5zdsN5c3PmrzXQTvkacdac6qG6qe7Low+DbVL+YmaF01hh9E g+Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=gbBFvw9P; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si21356340plr.220.2019.05.21.08.47.27; Tue, 21 May 2019 08:47:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=gbBFvw9P; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729010AbfEUPr1 (ORCPT + 1 other); Tue, 21 May 2019 11:47:27 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:35802 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728212AbfEUPr1 (ORCPT ); Tue, 21 May 2019 11:47:27 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4LFkWKv028109; Tue, 21 May 2019 17:46:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=/FwJ1TQFru+32XoeDMyEaHFno8vBWsvjxdibmbx8Z44=; b=gbBFvw9PfoW4Jz1Z5DI5evS/YoZjHP52RrV3HaNP/qCmI+pE+lF5J1aHrDRpoiRo8ugv eueMNl8Oed88Ojs9BomX52FAr+86xmAVlTb9LN5sy2P9u4FK5YumzMcNjrr7SufkZR2e s2G6lVfq6UDuTD0jexrlTomUSgiG7BYulNcqB8pStV9yxmtnsQCovd8Z7d2gdfE/KgsU eakofKIn0tJPCHqWS23ZnEOHpj+aJmX0aJNXEkobP+WRF5gl+WuhgS06y2i44abJAAq9 sRnfNEMpyLqUOp/PiFW5kJlJB9el1v4bkkep7gvNuXihyWVl6NKXkdnokN0IN0vEncKF kA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2sj7h0tkyr-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 21 May 2019 17:46:46 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 522913A; Tue, 21 May 2019 15:46:45 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas24.st.com [10.75.90.94]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 35CBE2CED; Tue, 21 May 2019 15:46:45 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.46) by Safex1hubcas24.st.com (10.75.90.94) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 21 May 2019 17:46:45 +0200 Received: from localhost (10.201.23.31) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 21 May 2019 17:46:43 +0200 From: Erwan Le Ray To: Greg Kroah-Hartman , Jiri Slaby , Maxime Coquelin , "Alexandre Torgue" CC: , , , , "Erwan Le Ray" , Fabrice Gasnier , "Fabien Dessenne" Subject: [PATCH 7/7] serial: stm32: fix the get_irq error case Date: Tue, 21 May 2019 17:45:47 +0200 Message-ID: <1558453547-22866-8-git-send-email-erwan.leray@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1558453547-22866-1-git-send-email-erwan.leray@st.com> References: <1558453547-22866-1-git-send-email-erwan.leray@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.31] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-21_03:, , signatures=0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Checks the returned values of platform_get_irq() for both required "event" and optional "wakeup" IRQs during probe. This allows the driver probe to be deferred if needed. Removes redundant checks for 'cfg.has_wakeup'. Signed-off-by: Fabien Dessenne Signed-off-by: Erwan Le Ray -- 1.9.1 diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 1334e42..9c2b04e 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -852,12 +852,31 @@ static int stm32_init_port(struct stm32_port *stm32port, port->flags = UPF_BOOT_AUTOCONF; port->ops = &stm32_uart_ops; port->dev = &pdev->dev; - port->irq = platform_get_irq(pdev, 0); + + ret = platform_get_irq(pdev, 0); + if (ret <= 0) { + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "Can't get event IRQ: %d\n", ret); + return ret ? ret : -ENODEV; + } + port->irq = ret; + port->rs485_config = stm32_config_rs485; stm32_init_rs485(port, pdev); - stm32port->wakeirq = platform_get_irq(pdev, 1); + if (stm32port->info->cfg.has_wakeup) { + stm32port->wakeirq = platform_get_irq(pdev, 1); + if (stm32port->wakeirq <= 0 && stm32port->wakeirq != -ENXIO) { + if (stm32port->wakeirq != -EPROBE_DEFER) + dev_err(&pdev->dev, + "Can't get event wake IRQ: %d\n", + stm32port->wakeirq); + return stm32port->wakeirq ? stm32port->wakeirq : + -ENODEV; + } + } + stm32port->fifoen = stm32port->info->cfg.has_fifo; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1064,7 +1083,7 @@ static int stm32_serial_probe(struct platform_device *pdev) if (ret) return ret; - if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0) { + if (stm32port->wakeirq > 0) { ret = device_init_wakeup(&pdev->dev, true); if (ret) goto err_uninit; @@ -1094,11 +1113,11 @@ static int stm32_serial_probe(struct platform_device *pdev) return 0; err_wirq: - if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0) + if (stm32port->wakeirq > 0) dev_pm_clear_wake_irq(&pdev->dev); err_nowup: - if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0) + if (stm32port->wakeirq > 0) device_init_wakeup(&pdev->dev, false); err_uninit: @@ -1112,7 +1131,6 @@ static int stm32_serial_remove(struct platform_device *pdev) struct uart_port *port = platform_get_drvdata(pdev); struct stm32_port *stm32_port = to_stm32_port(port); struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - struct stm32_usart_config *cfg = &stm32_port->info->cfg; stm32_clr_bits(port, ofs->cr3, USART_CR3_DMAR); @@ -1134,7 +1152,7 @@ static int stm32_serial_remove(struct platform_device *pdev) TX_BUF_L, stm32_port->tx_buf, stm32_port->tx_dma_buf); - if (cfg->has_wakeup && stm32_port->wakeirq >= 0) { + if (stm32_port->wakeirq > 0) { dev_pm_clear_wake_irq(&pdev->dev); device_init_wakeup(&pdev->dev, false); } @@ -1252,7 +1270,7 @@ static void stm32_serial_enable_wakeup(struct uart_port *port, bool enable) struct stm32_usart_config *cfg = &stm32_port->info->cfg; u32 val; - if (!cfg->has_wakeup || stm32_port->wakeirq < 0) + if (stm32_port->wakeirq <= 0) return; if (enable) {