ipmi:bt-bmc: Fix error handling and status check
[ Upstream commit 49826937e7
]
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 in the function bt_bmc_probe(),
when get irq failed, it will print error message. So use
platform_get_irq_optional() to simplify code. Finally in the
function bt_bmc_remove() should make the right status check
if get irq failed.
Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Message-Id: <20200505102906.17196-1-tangbin@cmss.chinamobile.com>
[Also set bt_bmc->irq to a negative value if devm_request_irq() fails.]
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
09197d39ca
commit
004cb15b1e
|
@ -399,15 +399,15 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
bt_bmc->irq = platform_get_irq(pdev, 0);
|
bt_bmc->irq = platform_get_irq_optional(pdev, 0);
|
||||||
if (!bt_bmc->irq)
|
if (bt_bmc->irq < 0)
|
||||||
return -ENODEV;
|
return bt_bmc->irq;
|
||||||
|
|
||||||
rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED,
|
rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED,
|
||||||
DEVICE_NAME, bt_bmc);
|
DEVICE_NAME, bt_bmc);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq);
|
dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq);
|
||||||
bt_bmc->irq = 0;
|
bt_bmc->irq = rc;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ static int bt_bmc_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
bt_bmc_config_irq(bt_bmc, pdev);
|
bt_bmc_config_irq(bt_bmc, pdev);
|
||||||
|
|
||||||
if (bt_bmc->irq) {
|
if (bt_bmc->irq >= 0) {
|
||||||
dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
|
dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
|
||||||
} else {
|
} else {
|
||||||
dev_info(dev, "No IRQ; using timer\n");
|
dev_info(dev, "No IRQ; using timer\n");
|
||||||
|
@ -505,7 +505,7 @@ static int bt_bmc_remove(struct platform_device *pdev)
|
||||||
struct bt_bmc *bt_bmc = dev_get_drvdata(&pdev->dev);
|
struct bt_bmc *bt_bmc = dev_get_drvdata(&pdev->dev);
|
||||||
|
|
||||||
misc_deregister(&bt_bmc->miscdev);
|
misc_deregister(&bt_bmc->miscdev);
|
||||||
if (!bt_bmc->irq)
|
if (bt_bmc->irq < 0)
|
||||||
del_timer_sync(&bt_bmc->poll_timer);
|
del_timer_sync(&bt_bmc->poll_timer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue