[SRU][F:linux-bluefield][PATCH v2 1/3]: UBUNTU: SAUCE: pwr-mlxbf.c: Improve driver dependencies
Asmaa Mnebhi
asmaa at nvidia.com
Fri Jul 29 13:06:59 UTC 2022
Buglink: https://bugs.launchpad.net/bugs/1980750
Instead of using SOFTDEP, return -EPROBE_DEFER if the
gpio-mlxbf driver is not loaded yet.
Flush work when driver is removed.
Signed-off-by: Asmaa Mnebhi <asmaa at nvidia.com>
---
drivers/power/reset/pwr-mlxbf.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/power/reset/pwr-mlxbf.c b/drivers/power/reset/pwr-mlxbf.c
index 09c275d57ffb..c9a6c480d5f0 100644
--- a/drivers/power/reset/pwr-mlxbf.c
+++ b/drivers/power/reset/pwr-mlxbf.c
@@ -62,21 +62,33 @@ pwr_mlxbf_probe(struct platform_device *pdev)
hid = acpi_device_hid(adev);
priv->hid = hid;
- irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(&pdev->dev), 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "Error getting %s irq.\n", priv->hid);
- return -ENODEV;
+ irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0);
+ if (irq == -EPROBE_DEFER) {
+ return -EPROBE_DEFER;
+ } else if (irq < 0) {
+ dev_err(dev, "Error getting %s irq.\n", priv->hid);
+ return -ENXIO;
}
INIT_WORK(&priv->send_work, pwr_mlxbf_send_work);
- err = devm_request_irq(&pdev->dev, irq, pwr_mlxbf_irq, 0, hid, priv);
+ err = devm_request_irq(dev, irq, pwr_mlxbf_irq, 0, hid, priv);
if (err)
- dev_err(&pdev->dev, "Failed request of %s irq\n", priv->hid);
+ dev_err(dev, "Failed request of %s irq\n", priv->hid);
return err;
}
+static int
+pwr_mlxbf_remove(struct platform_device *pdev)
+{
+ struct pwr_mlxbf *priv = platform_get_drvdata(pdev);
+
+ flush_work(&priv->send_work);
+
+ return 0;
+}
+
static const struct acpi_device_id __maybe_unused pwr_mlxbf_acpi_match[] = {
{ "MLNXBF24", 0 },
{ "MLNXBF29", 0 },
@@ -90,11 +102,11 @@ static struct platform_driver pwr_mlxbf_driver = {
.acpi_match_table = pwr_mlxbf_acpi_match,
},
.probe = pwr_mlxbf_probe,
+ .remove = pwr_mlxbf_remove,
};
module_platform_driver(pwr_mlxbf_driver);
-MODULE_SOFTDEP("pre: gpio_mlxbf2");
MODULE_DESCRIPTION("Mellanox BlueField power driver");
MODULE_AUTHOR("Asmaa Mnebhi <asmaa at nvidia.com>");
MODULE_LICENSE("Dual BSD/GPL");
--
2.30.1
More information about the kernel-team
mailing list