Skip to contentSkip to conversation

pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()

PATCH In review Yang Yingliang 3 participants 6 messages Sep 25, 2022 – Oct 17, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()

Using devm_add_action_or_reset() to make workqueue device-managed, so it can be destroy whenever the driver is unbound.

Fixes c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")

---
v3:
Using devm_add_action_or_reset().

v2:
move alloc_ordered_workqueue() after ocelot_pinctrl_register().

---
 drivers/pinctrl/pinctrl-ocelot.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/pinctrl/pinctrl-ocelot.c +10 -10
index 62ce3957abe4..266fbc957273 100644
@@ -2038,6 +2038,11 @@ static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev,
 	return devm_regmap_init_mmio(&pdev->dev, base, &regmap_config);
 }
 
+static void ocelot_destroy_workqueue(void *data)
+{
+	destroy_workqueue(data);
+}
+
 static int ocelot_pinctrl_probe(struct platform_device *pdev)
 {
 	const struct ocelot_match_data *data;
@@ -2069,6 +2074,11 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
 	if (!info->wq)
 		return -ENOMEM;
 
+	ret = devm_add_action_or_reset(dev, ocelot_destroy_workqueue,
+				       info->wq);
+	if (ret)
+		return ret;
+
 	info->pincfg_data = &data->pincfg_data;
 
 	reset = devm_reset_control_get_optional_shared(dev, "switch");
@@ -2110,15 +2120,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int ocelot_pinctrl_remove(struct platform_device *pdev)
-{
-	struct ocelot_pinctrl *info = platform_get_drvdata(pdev);
-
-	destroy_workqueue(info->wq);
-
-	return 0;
-}
-
 static struct platform_driver ocelot_pinctrl_driver = {
 	.driver = {
 		.name = "pinctrl-ocelot",
@@ -2126,7 +2127,6 @@ static struct platform_driver ocelot_pinctrl_driver = {
 		.suppress_bind_attrs = true,
 	},
 	.probe = ocelot_pinctrl_probe,
-	.remove = ocelot_pinctrl_remove,
 };
 module_platform_driver(ocelot_pinctrl_driver);
 
Signature · 1 line
2.25.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 3 lines · Yang Yingliang

Using devm_add_action_or_reset() to make workqueue device-managed, so it can be destroy whenever the driver is unbound.

Quoted 68 lines
Fixes c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")

---
v3:
Using devm_add_action_or_reset().

v2:
move alloc_ordered_workqueue() after ocelot_pinctrl_register().

---
 drivers/pinctrl/pinctrl-ocelot.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/pinctrl/pinctrl-ocelot.c +10 -11
index 62ce3957abe4..266fbc957273 100644
@@ -2038,6 +2038,11 @@ static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev,
        return devm_regmap_init_mmio(&pdev->dev, base, &regmap_config);
 }
 
+static void ocelot_destroy_workqueue(void *data)
+{
+       destroy_workqueue(data);
+}
+
 static int ocelot_pinctrl_probe(struct platform_device *pdev)
 {
        const struct ocelot_match_data *data;
@@ -2069,6 +2074,11 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
        if (!info->wq)
                return -ENOMEM;
 
+       ret = devm_add_action_or_reset(dev, ocelot_destroy_workqueue,
+                                      info->wq);
+       if (ret)
+               return ret;
+
        info->pincfg_data = &data->pincfg_data;
 
        reset = devm_reset_control_get_optional_shared(dev, "switch");
@@ -2110,15 +2120,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int ocelot_pinctrl_remove(struct platform_device *pdev)
-{
-       struct ocelot_pinctrl *info = platform_get_drvdata(pdev);
-
-       destroy_workqueue(info->wq);
-
-       return 0;
-}
-
 static struct platform_driver ocelot_pinctrl_driver = {
        .driver = {
                .name = "pinctrl-ocelot",
@@ -2126,7 +2127,6 @@ static struct platform_driver ocelot_pinctrl_driver = {
                .suppress_bind_attrs = true,
        },
        .probe = ocelot_pinctrl_probe,
-       .remove = ocelot_pinctrl_remove,
 };
 module_platform_driver(ocelot_pinctrl_driver);
 
--

2.25.1

Signature · 1 line
/Horatiu
#2 lore raw
In reply to Yang Yingliang
Quoted 8 lines · Yang Yingliang

Using devm_add_action_or_reset() to make workqueue device-managed, so it can be destroy whenever the driver is unbound.

Fixes c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")

---
v3:
Using devm_add_action_or_reset().

Patch applied, after deleting the hunks removing .remove because that was already gone upstream.

Yours,
Linus Walleij

#3 lore raw
Quoted 5 lines · Linus Walleij
Quoted 3 lines · Yang Yingliang

Using devm_add_action_or_reset() to make workqueue device-managed, so it can be destroy whenever the driver is unbound.

Quoted 8 lines
Quoted 5 lines
Fixes c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")

---
v3:
Using devm_add_action_or_reset().

Patch applied, after deleting the hunks removing .remove because that was already gone upstream.

Ah, the patch introducing that is in the MFD tree is it not?

Either ask Lee to apply it or wait until -rc1 it's no big deal anyway. Remind me in two weeks.

Yours,
Linus Walleij

#4 lore raw

Hi,

Quoted 11 lines · Linus Walleij
Quoted 10 lines · Linus Walleij
Quoted 8 lines · Yang Yingliang

Using devm_add_action_or_reset() to make workqueue device-managed, so it can be destroy whenever the driver is unbound.

Fixes c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")

---
v3:
Using devm_add_action_or_reset().

Quoted 6 lines
Quoted 2 lines

Patch applied, after deleting the hunks removing .remove because that was already gone upstream.

Ah, the patch introducing that is in the MFD tree is it not?

Either ask Lee to apply it or wait until -rc1 it's no big deal anyway. Remind me in two weeks.

It's OK.

Thanks,
Yang

Quoted 4 lines

Yours,
Linus Walleij
.

#5 lore raw
Quoted 16 lines · Yang Yingliang
Quoted 15 lines · Linus Walleij
Quoted 5 lines · Linus Walleij
Quoted 3 lines · Yang Yingliang

Using devm_add_action_or_reset() to make workqueue device-managed, so it can be destroy whenever the driver is unbound.

Quoted 7 lines
Quoted 5 lines
Fixes c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")

---
v3:
Using devm_add_action_or_reset().

Patch applied, after deleting the hunks removing .remove because that was already gone upstream.

Ah, the patch introducing that is in the MFD tree is it not?

Quoted 7 lines
Quoted 2 lines

Either ask Lee to apply it or wait until -rc1 it's no big deal anyway. Remind me in two weeks.

It's OK.

Thanks,
Yang

I rebased my development on v6.1-rc1 now and applied this patch!

Yours,
Linus Walleij