Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp879184yba; Thu, 16 May 2019 10:18:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6jwNlUpvs8mBACHFhg6XxNJ+TMvPWRxQRklyn6GzDO0oHhsewq1vkEsHpafIrCy//cN2r X-Received: by 2002:a17:902:8c85:: with SMTP id t5mr51783356plo.23.1558027103217; Thu, 16 May 2019 10:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558027103; cv=none; d=google.com; s=arc-20160816; b=Gk8PUXo+o6a+VmJv0TS9Uy3TY1RQa6dWSwD9sqUeTIFPu5tItci1bmhf1HfnUZBZrq /F5Ftedmfcx3VWqK2c5q5kvfG0IRyNwNmRVv2SIVwNd7Wrikx1G3Xqf5EX69mbpOdkSX VQPxCPL2gpjhBiPa4fdFCkmxLgRwszgKv8fZqB6qso0SE4iHuitXRown7j8ua+8Fh9iF 6llP95xzfDh/oMy1JKI5eVvPd6WeTailhwoZQEcRcaN5e/lWaE5JleK7obzj9nwzGn7I 2KhHTb0wt9QVhRZAk/P1nzyoQhosJe+u+ldWguSyMtu8qiHzQ0dTcb2jfF+stluBXLpd 3kXA== 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=nC+lU5wFiqSbb880es2NIZVzXaC7ZVUAJusjLU3yQYw=; b=dU80ZA3QbUGHVf5yHehIWbQ668o5CJpyU9HJL8SJz8+roVZ09ctg/aN2FS6xhSmW8S 8xmRmX5PSpfSYk0Dr3IZtUUOXXNDmor16v6qSrPC49g8l8aFbYp2hJRMPdN9AroU9Y73 ntsp3PXnZYjdA+WrVJcCATwL7DUW3Ps2Es4pYm5jme2xIyrcgQ0g9bYo8yIu6HkuEvTJ ncKxZb5CZqmz2hHUREwl2Z8pLUHU0JUO6rXdFN4sOf8Hq4BB+z+1RlsyWSKQxW2plBQ6 t5FtnB1uM4aIi08Qnn3XVLtMQqD65kmNDNKmTqMqwHDxGoor1PLmCxpnOUFpCE7oW3ol G4Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=yg0PstNK; 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 u1si5257434plz.45.2019.05.16.10.18.07; Thu, 16 May 2019 10:18:23 -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=yg0PstNK; 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 S1727726AbfEPPan (ORCPT + 99 others); Thu, 16 May 2019 11:30:43 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:2546 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbfEPPam (ORCPT ); Thu, 16 May 2019 11:30:42 -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 x4GFQ5Id007015; Thu, 16 May 2019 17:30:31 +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=nC+lU5wFiqSbb880es2NIZVzXaC7ZVUAJusjLU3yQYw=; b=yg0PstNKDCsxCaZA3Pna5TboHkvbKYHSHzpwv1ZGigG5M0fX/A0girzBMea0fC6kxcD7 8w+XZ+CxBJPkDG2HqqO9E/bpzcIMR2XFqRrMPWqW6OHJqmvRmg5eiL7ruD+VcK+og36W dfGLg3v3zLKAHdGmTF75lOxSbZn4ZmTvdJMXmYjviBptPN/ZM2531YJixOVs7Q4eoT+6 pT4zQUakHozg62LJ1YicUq5nNZKLeTz5Ma0Z8YX6/0BKbzCbvxzbOb3+skOtq7f7qjHE cWdX+SjE7lDqWLkHhtEHwyqDXTMX1x5CpcRN/lvP0CcCax0qEJTFXTO4dhKWK9ZVuiye 0g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2sdkv07xm0-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 16 May 2019 17:30:31 +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 CDBEE34; Thu, 16 May 2019 15:30:30 +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 ADED6285D; Thu, 16 May 2019 15:30:30 +0000 (GMT) Received: from localhost (10.75.127.46) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 16 May 2019 17:30:30 +0200 From: Fabrice Gasnier To: , CC: , , , , , , , Subject: [PATCH v2] i2c: i2c-stm32f7: fix the get_irq error cases Date: Thu, 16 May 2019 17:29:54 +0200 Message-ID: <1558020594-1498-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.46] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-16_13:,, 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 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..d7d7dd7 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 ? irq_event : -ENODEV; } - 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 ? irq_error : -ENODEV; } i2c_dev->clk = devm_clk_get(&pdev->dev, NULL); -- 2.7.4