forked from Minki/linux
regulator: qcom_spmi-regulator: Clean-up by using managed work init
Few drivers implement remove call-back only for ensuring a delayed work gets cancelled prior driver removal. Clean-up these by switching to use devm_delayed_work_autocancel() instead. Additionally, this helps avoiding mixing devm and manual resource management and cleans up a (theoretical?) bug where devm managed over-current IRQ might schedule a new work item after wq was cleaned at remove(). This change is compile-tested only. All testing is appreciated. Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Link: https://lore.kernel.org/r/3bd35bb43257f4bf5b99f75d207ed5e1e08d1d38.1616506559.git.matti.vaittinen@fi.rohmeurope.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6d0c5de2fd
commit
b668801515
@ -5,6 +5,7 @@
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/devm-helpers.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/interrupt.h>
|
||||
@ -1842,7 +1843,10 @@ static int spmi_regulator_of_parse(struct device_node *node,
|
||||
return ret;
|
||||
}
|
||||
|
||||
INIT_DELAYED_WORK(&vreg->ocp_work, spmi_regulator_vs_ocp_work);
|
||||
ret = devm_delayed_work_autocancel(dev, &vreg->ocp_work,
|
||||
spmi_regulator_vs_ocp_work);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2157,10 +2161,8 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
|
||||
vreg->regmap = regmap;
|
||||
if (reg->ocp) {
|
||||
vreg->ocp_irq = platform_get_irq_byname(pdev, reg->ocp);
|
||||
if (vreg->ocp_irq < 0) {
|
||||
ret = vreg->ocp_irq;
|
||||
goto err;
|
||||
}
|
||||
if (vreg->ocp_irq < 0)
|
||||
return vreg->ocp_irq;
|
||||
}
|
||||
vreg->desc.id = -1;
|
||||
vreg->desc.owner = THIS_MODULE;
|
||||
@ -2203,8 +2205,7 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
|
||||
rdev = devm_regulator_register(dev, &vreg->desc, &config);
|
||||
if (IS_ERR(rdev)) {
|
||||
dev_err(dev, "failed to register %s\n", name);
|
||||
ret = PTR_ERR(rdev);
|
||||
goto err;
|
||||
return PTR_ERR(rdev);
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&vreg->node);
|
||||
@ -2212,24 +2213,6 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
list_for_each_entry(vreg, vreg_list, node)
|
||||
if (vreg->ocp_irq)
|
||||
cancel_delayed_work_sync(&vreg->ocp_work);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int qcom_spmi_regulator_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct spmi_regulator *vreg;
|
||||
struct list_head *vreg_list = platform_get_drvdata(pdev);
|
||||
|
||||
list_for_each_entry(vreg, vreg_list, node)
|
||||
if (vreg->ocp_irq)
|
||||
cancel_delayed_work_sync(&vreg->ocp_work);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver qcom_spmi_regulator_driver = {
|
||||
@ -2238,7 +2221,6 @@ static struct platform_driver qcom_spmi_regulator_driver = {
|
||||
.of_match_table = qcom_spmi_regulator_match,
|
||||
},
|
||||
.probe = qcom_spmi_regulator_probe,
|
||||
.remove = qcom_spmi_regulator_remove,
|
||||
};
|
||||
module_platform_driver(qcom_spmi_regulator_driver);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user