Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2231406ybi; Mon, 17 Jun 2019 00:55:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSSU5GDuaN4qHAR1KzA9RlA/6ihwxUroK+ij1jysb0qBrAfvjy7xF4bE2XC+e2zVYrkn1w X-Received: by 2002:a17:902:7004:: with SMTP id y4mr22128941plk.31.1560758105103; Mon, 17 Jun 2019 00:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560758105; cv=none; d=google.com; s=arc-20160816; b=widg6r+WvLB/EH4okJIKKw/eqcqsqB7aQIazS8LtTFCCaj/c5iSwvJMX0FkihJYFoi +kDnbdK+AEJv7GP0iNSQ3NN5o4Dyms5ipUQ4OWZvb1tZkEsR81QIw53pOc7fx34xfPyg dw4Y1sd8l431leer079FqEikCwxOgEgviFraNjbTL1QfqT6b9Dax/EoLNvdaxUgD4Kkn q71n9ltJJ2FqpmV/HB4JBz2TUxHeVhw3uIv9aLBwfnwLSGc7H4rP8MqQGFMx5sQ9PJPL TtRn7hnEF+RahWtHlTndPh0VUBiSJsIad9CVVxPWi6pA/Sf54VwSpBbXuuhlcBUj3XAi pgnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=CTrvQhARsK2rq2uBwxe43MaGoFurKJQoc0Xtvz7t0+w=; b=chOB+bj36N4+8lRi8ImIsvaNicqyK7SIbqfsdAst9I/DwDO5xJRLfx0uASVBKc8Qqi m5KvYXl/5TZUShWzY7TUd6/GHO0C9jqd+MXRnO9G53rHh+HsF7SErXn/K3AYu/3VTgz1 xUv0tirKO7tSXmvZprBMUSfhjYxl/t+lkYkBcKNYaCANMJ3ZXVvstxWHssBlhUu+QL4C d/XsiBzwr3Lyuc4lCQNUp/cTO5Ak50Zc60Bd+UONW33wj69LBO7lcPE4kqR03IIhjM+M 4TqnTxc8hb395dMctyONxn3zDVK8IZdUNPg+5OKkDoYVnGYjhGzWvaad2tRHSljDHcAG XL8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=F+3o3nWz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 66si10243001pgg.199.2019.06.17.00.54.49; Mon, 17 Jun 2019 00:55:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=F+3o3nWz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbfFQHxT (ORCPT + 99 others); Mon, 17 Jun 2019 03:53:19 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:46963 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725837AbfFQHxS (ORCPT ); Mon, 17 Jun 2019 03:53:18 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5H7qB6H012707; Mon, 17 Jun 2019 09:53:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=CTrvQhARsK2rq2uBwxe43MaGoFurKJQoc0Xtvz7t0+w=; b=F+3o3nWzlV27xMfCYtyHi/OANHrg1Tk3r9hUGfm+ebNmuIr21dxUkuVttOzWP3Yn+mJB vm7doDEu6zsFP6Hjg+wCgJEwDg+vtwJl2z3eLSJBydDrhp2uuM5UYQ/hW+hfv68CV9AI dtWb1qSj4cmDL6f1tdzjC7h47jHnWDpn3MEcvdWiJAUk/zcMw8SnvNrKb5WR9QL7YuGV iKVI3txkM9N91g3WlV3MqgjmETqFXpjwLgzugPbcQY+OSQa8DQHfunbW1ySrSkZ66Fd6 92GntuY5SJX9Dtr8WubS7jpZGazAE2qp5Ksyn/CHvrNVKoF6d9smR3KFY0UAvuJNPXjl qQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2t4peu1399-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 17 Jun 2019 09:53:07 +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 B712234; Mon, 17 Jun 2019 07:53:06 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 959181651; Mon, 17 Jun 2019 07:53:06 +0000 (GMT) Received: from localhost (10.75.127.49) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 17 Jun 2019 09:53:06 +0200 From: Fabrice Gasnier To: , CC: , , , , , , , , Subject: [PATCH v3] i2c: i2c-stm32f7: fix the get_irq error cases Date: Mon, 17 Jun 2019 09:53:01 +0200 Message-ID: <1560757981-10532-1-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG8NODE1.st.com (10.75.127.22) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-17_05:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During probe, return the "get_irq" error value instead of -EINVAL which allows the driver to be deferred probed if needed. Fix also the case where of_irq_get() returns a negative value. Note : On failure of_irq_get() returns 0 or a negative value while platform_get_irq() returns a negative value. Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver") Reviewed-by: Pierre-Yves MORDRET Signed-off-by: Fabien Dessenne Signed-off-by: Fabrice Gasnier --- Changes in v3: - return -ENOENT instead of -ENODEV and shorten the ternary operator as suggested by Wolfram. Changes in v2: - Also check for irq == 0 that means "does not exist" as pointed out by Marc --- drivers/i2c/busses/i2c-stm32f7.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c index 4284fc9..432b701 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -1812,15 +1811,14 @@ static struct i2c_algorithm stm32f7_i2c_algo = { static int stm32f7_i2c_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; struct stm32f7_i2c_dev *i2c_dev; const struct stm32f7_i2c_setup *setup; struct resource *res; - u32 irq_error, irq_event, clk_rate, rise_time, fall_time; + u32 clk_rate, rise_time, fall_time; struct i2c_adapter *adap; struct reset_control *rst; dma_addr_t phy_addr; - int ret; + int irq_error, irq_event, ret; i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL); if (!i2c_dev) @@ -1832,16 +1830,20 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) return PTR_ERR(i2c_dev->base); phy_addr = (dma_addr_t)res->start; - irq_event = irq_of_parse_and_map(np, 0); - if (!irq_event) { - dev_err(&pdev->dev, "IRQ event missing or invalid\n"); - return -EINVAL; + irq_event = platform_get_irq(pdev, 0); + if (irq_event <= 0) { + if (irq_event != -EPROBE_DEFER) + dev_err(&pdev->dev, "Failed to get IRQ event: %d\n", + irq_event); + return irq_event ? : -ENOENT; } - irq_error = irq_of_parse_and_map(np, 1); - if (!irq_error) { - dev_err(&pdev->dev, "IRQ error missing or invalid\n"); - return -EINVAL; + irq_error = platform_get_irq(pdev, 1); + if (irq_error <= 0) { + if (irq_error != -EPROBE_DEFER) + dev_err(&pdev->dev, "Failed to get IRQ error: %d\n", + irq_error); + return irq_error ? : -ENOENT; } i2c_dev->clk = devm_clk_get(&pdev->dev, NULL); -- 2.7.4