Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5898580ybi; Wed, 12 Jun 2019 10:19:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTnVyjKOPlIzd4+6D3vZONXf5gt8+gttuw+RNuzsCsOowcQDYdLsOF9zZ6tZli/ubkyiiT X-Received: by 2002:a17:90a:ca11:: with SMTP id x17mr241603pjt.107.1560359954992; Wed, 12 Jun 2019 10:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560359954; cv=none; d=google.com; s=arc-20160816; b=y8WxhCxj8gfdsqJdVgU3o5DOBmS5jRoRBdeZKDSq4tYAH8VLdojtNuTIH65kURrD5V u9dsohrrXCNHME9f49bHmTp38Ozgi3GREz1P3RWAX3GCfyQxdLuluy+ot2Pyei+e1cWS fTTQOPrBnh0JZ4n81lcej3j9X16urpmB9uaNScrxSsCdOJPLeLClcCALSw3LchxTPp51 SqVXFLcX7n7CCtYKW8wFpvBHIOoiK58K1VB3blAeiUkeDyJrd9HySUCvKUsbZncEZtZm VyCAy8sq0hk8E5DJiJrjeXP2cAHjM2r0AmQ5TLZ3jKqKcRtMgP3KWnhCRtqbXkPPfazC VOMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=uzCtDAjBrL+1vZ61l6aZvXQ4DLiHhDO5NcE7f5ZHrV4=; b=ykdXtNd8LCSlOk7Fp55fXAWAsZy/psPQh/quT3PfAx7lZhl0zaimvPP5Pz+S1SQwp9 C9WHfJ+aKoCuLc9R63zt99ZqUPa0UXGYiET1zb8/yX1AdKMa4bdegyKghzDUd+MBynXC gTIS0nyF2zVPk8Fv9iMmbgU13zOMGddrRfjEQBEFwwHpkEjvcpibs8fZQZ4H/kIZwCGL TefdhaX354EKjKFnFVpH8pn2IJQbcsOU3LxRreRFxf8qim5/x1T6yjF3p/iE6sNy7K9q 6Km033sUnDqQGhP4cayeY1BXnvXAXbwL1X/VtDpRM881nTwNGvEm/5+wC37CRjA09gYb hl5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=mjxkuclj; 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 c15si376803pjo.3.2019.06.12.10.18.59; Wed, 12 Jun 2019 10:19:14 -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=mjxkuclj; 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 S2438929AbfFLMaM (ORCPT + 99 others); Wed, 12 Jun 2019 08:30:12 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:36281 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407613AbfFLMaL (ORCPT ); Wed, 12 Jun 2019 08:30:11 -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 x5CCLeHk031270; Wed, 12 Jun 2019 14:30:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : from : to : cc : references : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=uzCtDAjBrL+1vZ61l6aZvXQ4DLiHhDO5NcE7f5ZHrV4=; b=mjxkucljzxAUHj2FgtiNV1hqjOQZJlu5AT7lQvpD9DL415dfBHy3T26A9vzP7rPEFQwp i85TbeaRuAW4ihjecSNylDmocBdjY5MbLdAX3D0q2roChQg63/iwRIA0i1Q0BQvCsub8 j0dlY3HyL9IEmVAA46N8aLAQUFhmNerrtp4ME5wXtBUmsPn1NNUFWX1uEqxhhULJUXp5 DJo2ThnnvzFzyPRPTdu0wTLyujCU/juTlitsLqr0fDJP4mNenKVwmnaeI3vzsi06xl2V zjfRDFE4ZckshHoHz0uar2gVlgnVhnihDpEQSBS2bWM79PtchXVjkCcf8HrnKKU1479q rg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2t2k3c41wm-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 12 Jun 2019 14:30:00 +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 67EF538; Wed, 12 Jun 2019 12:29:59 +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 494E82963; Wed, 12 Jun 2019 12:29:59 +0000 (GMT) Received: from [10.48.0.167] (10.75.127.49) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 12 Jun 2019 14:29:58 +0200 Subject: Re: [PATCH v2] i2c: i2c-stm32f7: fix the get_irq error cases From: Fabrice Gasnier To: , CC: , , , , , , , References: <1558020594-1498-1-git-send-email-fabrice.gasnier@st.com> Message-ID: <6fe9c4cc-d7ed-aad8-b8f8-240a4888aaa8@st.com> Date: Wed, 12 Jun 2019 14:29:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <1558020594-1498-1-git-send-email-fabrice.gasnier@st.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG5NODE2.st.com (10.75.127.14) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-12_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/16/19 5:29 PM, Fabrice Gasnier wrote: > 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 Hi Wolfram, all, Gentle ping on this patch Best Regards, Fabrice > --- > 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); >