Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp608610ybz; Wed, 15 Apr 2020 15:04:23 -0700 (PDT) X-Google-Smtp-Source: APiQypKjIS4JrwQWJU7LsSkYMCR/W53Fn+E/+aCOaSbGaQeHEvpGXaUHZREI16Ac8Brjb0VTncsa X-Received: by 2002:a05:6402:17f0:: with SMTP id t16mr26511190edy.157.1586988262950; Wed, 15 Apr 2020 15:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586988262; cv=none; d=google.com; s=arc-20160816; b=nRnZIjte3ZMRx5lM6yG6y0AIClFEg/7ottdkTG6tIWYKdfOoprOMVhnxzZ+qHJPXHV TSOXf5Wcauh5LMI1XvCkOzqrRZcC8g/bgqGE5pOrbLTEEEVPialOgw06zDGPA1K+8Zqy OoAzSP/WJ0W9sUgx1TUIBUHrDWpKTmO1xeIL9lYMsKv6CWdaYHXco2kyTOWj01Kd7iQq 6Bj24bCuGQ6H/MN5fEgeDRInT9UfPYaqGKRPf2ut+MfgiYf7wQQ10uc9u9o18F9kILI2 RWWaF6MmbYR6JZ2+hocIe5AClM+sfyIQvQbg7T3ibfrETnh49L+xtjGslKy+tmRR3ngY MKdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=kGDjHhHdpD8rWLMWyXEo4Q8qyHMVTG6iM5374zOMB+I=; b=F3cSi7ZSm0czr5YmU8OFfi1QeO6pWpIlof+1iTpu8zpc2HR4XPesredV5wgQr5JkyH aE97RWdC4JlJXFGUGyfi1ZbpYZX4+dydLPDasVt4c7/d2WHNXTrKzFAfnQ20cmlXmapa mlcjHq9xgWbqbtJZZQXICiZKQgmksmqfsDrvcVlXQALglFBilLYelf7iRelSv1y5x4+S Tp6qJqhwQoISIPgq5pXxCyMtWKPMdWTWSd/hrU5936Yltmktses78qwkaPjKppGkYGLa t7hUPR5WqYNR7086DQ+32lJiUrIdWb0rTJk4XKxeGq72BLZS7NtoNG3UqCi3fP8SoL7n Z1hQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo2si7613456edb.438.2020.04.15.15.03.59; Wed, 15 Apr 2020 15:04:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392874AbgDOCMd (ORCPT + 99 others); Tue, 14 Apr 2020 22:12:33 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:11703 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392857AbgDOCM2 (ORCPT ); Tue, 14 Apr 2020 22:12:28 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.17]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee75e966d7c257-5d4cd; Wed, 15 Apr 2020 10:12:12 +0800 (CST) X-RM-TRANSID: 2ee75e966d7c257-5d4cd X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from [172.20.21.224] (unknown[112.25.154.146]) by rmsmtp-syy-appsvr09-12009 (RichMail) with SMTP id 2ee95e966d7bbb6-4fa4c; Wed, 15 Apr 2020 10:12:12 +0800 (CST) X-RM-TRANSID: 2ee95e966d7bbb6-4fa4c Subject: Re: [PATCH 3/3] ipmi:bt-bmc: Fix error handling and status check To: minyard@acm.org Cc: arnd@arndb.de, gregkh@linuxfoundation.org, openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20200414141423.4968-1-tangbin@cmss.chinamobile.com> <20200414201832.GJ3587@minyard.net> From: Tang Bin Message-ID: Date: Wed, 15 Apr 2020 10:14:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200414201832.GJ3587@minyard.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Corey: On 2020/4/15 4:18, Corey Minyard wrote: > On Tue, Apr 14, 2020 at 10:14:24PM +0800, Tang Bin wrote: >> If the function platform_get_irq() failed, the negative >> value returned will not be detected here. So fix error >> handling in bt_bmc_config_irq(). And if devm_request_irq() >> failed, 'bt_bmc->irq' is assigned to zero maybe redundant, >> it may be more suitable for using the correct negative values >> to make the status check in the function bt_bmc_remove(). > Comments inline.. > >> Signed-off-by: Tang Bin >> Signed-off-by: Shengju Zhang >> --- >> drivers/char/ipmi/bt-bmc.c | 12 +++++------- >> 1 file changed, 5 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c >> index 1d4bf5c65..1740c6dc8 100644 >> --- a/drivers/char/ipmi/bt-bmc.c >> +++ b/drivers/char/ipmi/bt-bmc.c >> @@ -399,16 +399,14 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc, >> struct device *dev = &pdev->dev; >> int rc; >> >> - bt_bmc->irq = platform_get_irq(pdev, 0); >> - if (!bt_bmc->irq) >> - return -ENODEV; >> + bt_bmc->irq = platform_get_irq_optional(pdev, 0); >> + if (bt_bmc->irq < 0) >> + return bt_bmc->irq; >> For us, this part of modification have reached a consensus. >> rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED, >> DEVICE_NAME, bt_bmc); >> - if (rc < 0) { >> - bt_bmc->irq = 0; >> + if (rc < 0) >> return rc; > I don't think this part is correct. You will want to set bt_bmc->irq to > rc here to match what is done elsewhere so it's the error if negative. Nonono, I don't want to set bt_bmc->irq to rc, I think they are irrelevant. The logic of the previous code will continue to execute even if platform_get_irq() failed,which will be brought devm_request_irq() failed too. "bt_bmc->irq = 0" here is just for bt_bmc_remove() to execute del_timer_sync(). Otherwise the function del_timer_sync() will not execute if not set "bt_bmc->irq" to zero, because it's negative actually. > > Also, I believe this function should no longer return an error. It > should just set the irq to the error if one happens. The driver needs > to continue to operate even if it can't get its interrupt. > > The rest of the changes are correct, I believe. > > >> - } >> >> /* >> * Configure IRQs on the bmc clearing the H2B and HBUSY bits; >> @@ -499,7 +497,7 @@ static int bt_bmc_remove(struct platform_device *pdev) >> struct bt_bmc *bt_bmc = dev_get_drvdata(&pdev->dev); >> >> misc_deregister(&bt_bmc->miscdev); >> - if (!bt_bmc->irq) >> + if (bt_bmc->irq < 0) >> del_timer_sync(&bt_bmc->poll_timer); >> return 0; >> } But now, the logic is: if the platform_get_irq_optional() failed, it returns immediately, the irq at this point is negative,the bt_bmc_probe() continue to operate. But in the function bt_bmc_remove(), we need status check in order to execute del_timer_sync(), so change "!bt_bmc->irq" to "bt_bmc->irq < 0". So, when the judgment of "bt_bmc->irq" in the function bt_bmc_remove() goes back to  the original negative value, the "bt_bmc->irq = 0" in the line 410 become redundant. That's why I remove it. I am very glad to communicate and discuss with you these days. Thanks, Tang Bin >> >> >>