* [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()
@ 2022-09-17 2:46 Yang Yingliang
2022-09-17 2:46 ` [PATCH -next v2 2/2] pinctrl: ocelot: Use devm_platform_get_and_ioremap_resource() Yang Yingliang
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Yang Yingliang @ 2022-09-17 2:46 UTC (permalink / raw)
To: linux-gpio, linux-kernel; +Cc: linus.walleij, p.zabel, horatiu.vultur
Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
in error path.
Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
v2:
move alloc_ordered_workqueue() after ocelot_pinctrl_register().
---
drivers/pinctrl/pinctrl-ocelot.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
index d9c0184c077f..c672bc2a4df5 100644
--- a/drivers/pinctrl/pinctrl-ocelot.c
+++ b/drivers/pinctrl/pinctrl-ocelot.c
@@ -2065,10 +2065,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
if (!info->desc)
return -ENOMEM;
- info->wq = alloc_ordered_workqueue("ocelot_ordered", 0);
- if (!info->wq)
- return -ENOMEM;
-
info->pincfg_data = &data->pincfg_data;
reset = devm_reset_control_get_optional_shared(dev, "switch");
@@ -2107,9 +2103,15 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
if (ret)
return ret;
+ info->wq = alloc_ordered_workqueue("ocelot_ordered", 0);
+ if (!info->wq)
+ return -ENOMEM;
+
ret = ocelot_gpiochip_register(pdev, info);
- if (ret)
+ if (ret) {
+ destroy_workqueue(info->wq);
return ret;
+ }
dev_info(dev, "driver registered\n");
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH -next v2 2/2] pinctrl: ocelot: Use devm_platform_get_and_ioremap_resource()
2022-09-17 2:46 [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe() Yang Yingliang
@ 2022-09-17 2:46 ` Yang Yingliang
2022-09-17 8:55 ` andy.shevchenko
2022-09-17 8:54 ` [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe() andy.shevchenko
2022-10-04 7:09 ` Linus Walleij
2 siblings, 1 reply; 7+ messages in thread
From: Yang Yingliang @ 2022-09-17 2:46 UTC (permalink / raw)
To: linux-gpio, linux-kernel; +Cc: linus.walleij, p.zabel, horatiu.vultur
Switch to use devm_platform_get_and_ioremap_resource() to simplify code.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/pinctrl/pinctrl-ocelot.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
index c672bc2a4df5..d2c144611d4b 100644
--- a/drivers/pinctrl/pinctrl-ocelot.c
+++ b/drivers/pinctrl/pinctrl-ocelot.c
@@ -2073,8 +2073,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
"Failed to get reset\n");
reset_control_reset(reset);
- base = devm_ioremap_resource(dev,
- platform_get_resource(pdev, IORESOURCE_MEM, 0));
+ base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(base))
return PTR_ERR(base);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()
2022-09-17 2:46 [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe() Yang Yingliang
2022-09-17 2:46 ` [PATCH -next v2 2/2] pinctrl: ocelot: Use devm_platform_get_and_ioremap_resource() Yang Yingliang
@ 2022-09-17 8:54 ` andy.shevchenko
2022-09-17 11:19 ` Yang Yingliang
2022-10-04 7:09 ` Linus Walleij
2 siblings, 1 reply; 7+ messages in thread
From: andy.shevchenko @ 2022-09-17 8:54 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-gpio, linux-kernel, linus.walleij, p.zabel, horatiu.vultur
Sat, Sep 17, 2022 at 10:46:33AM +0800, Yang Yingliang kirjoitti:
> Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
> in error path.
>
> Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> v2:
> move alloc_ordered_workqueue() after ocelot_pinctrl_register().
Why? What will happen if user space start using pins before workqueue is allocated?
If you really want to have it correct, you need either drop all devm_ calls
after allocating workqueue, or wrap destroying into devm.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2 2/2] pinctrl: ocelot: Use devm_platform_get_and_ioremap_resource()
2022-09-17 2:46 ` [PATCH -next v2 2/2] pinctrl: ocelot: Use devm_platform_get_and_ioremap_resource() Yang Yingliang
@ 2022-09-17 8:55 ` andy.shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: andy.shevchenko @ 2022-09-17 8:55 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-gpio, linux-kernel, linus.walleij, p.zabel, horatiu.vultur
Sat, Sep 17, 2022 at 10:46:34AM +0800, Yang Yingliang kirjoitti:
> Switch to use devm_platform_get_and_ioremap_resource() to simplify code.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/pinctrl/pinctrl-ocelot.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
> index c672bc2a4df5..d2c144611d4b 100644
> --- a/drivers/pinctrl/pinctrl-ocelot.c
> +++ b/drivers/pinctrl/pinctrl-ocelot.c
> @@ -2073,8 +2073,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
> "Failed to get reset\n");
> reset_control_reset(reset);
>
> - base = devm_ioremap_resource(dev,
> - platform_get_resource(pdev, IORESOURCE_MEM, 0));
> + base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
> if (IS_ERR(base))
> return PTR_ERR(base);
>
> --
> 2.25.1
>
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()
2022-09-17 8:54 ` [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe() andy.shevchenko
@ 2022-09-17 11:19 ` Yang Yingliang
0 siblings, 0 replies; 7+ messages in thread
From: Yang Yingliang @ 2022-09-17 11:19 UTC (permalink / raw)
To: andy.shevchenko
Cc: linux-gpio, linux-kernel, linus.walleij, p.zabel, horatiu.vultur
Hi,
On 2022/9/17 16:54, andy.shevchenko@gmail.com wrote:
> Sat, Sep 17, 2022 at 10:46:33AM +0800, Yang Yingliang kirjoitti:
>> Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
>> in error path.
>>
>> Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>> v2:
>> move alloc_ordered_workqueue() after ocelot_pinctrl_register().
> Why? What will happen if user space start using pins before workqueue is allocated?
This is a suggestion from Horatiu Vultur.
And I think the workqueue is used in ocelot_irq_unmask_level(), but
before ocelot_gpiochip_register() calling,
the irq is not prepared, the work won't be queued before
ocelot_gpiochip_register().
>
> If you really want to have it correct, you need either drop all devm_ calls
> after allocating workqueue, or wrap destroying into devm.
I am trying to add devm APIs for allocating workqueue.
Thanks,
Yang
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()
2022-09-17 2:46 [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe() Yang Yingliang
2022-09-17 2:46 ` [PATCH -next v2 2/2] pinctrl: ocelot: Use devm_platform_get_and_ioremap_resource() Yang Yingliang
2022-09-17 8:54 ` [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe() andy.shevchenko
@ 2022-10-04 7:09 ` Linus Walleij
2022-10-04 9:11 ` Horatiu Vultur
2 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2022-10-04 7:09 UTC (permalink / raw)
To: Yang Yingliang, Horatiu Vultur; +Cc: linux-gpio, linux-kernel, p.zabel
On Sat, Sep 17, 2022 at 4:39 AM Yang Yingliang <yangyingliang@huawei.com> wrote:
> Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
> in error path.
>
> Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> v2:
> move alloc_ordered_workqueue() after ocelot_pinctrl_register().
Horatiu does this v2 look like you want it? Reviewed-by?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()
2022-10-04 7:09 ` Linus Walleij
@ 2022-10-04 9:11 ` Horatiu Vultur
0 siblings, 0 replies; 7+ messages in thread
From: Horatiu Vultur @ 2022-10-04 9:11 UTC (permalink / raw)
To: Linus Walleij; +Cc: Yang Yingliang, linux-gpio, linux-kernel, p.zabel
The 10/04/2022 09:09, Linus Walleij wrote:
Hi Linus,
>
> On Sat, Sep 17, 2022 at 4:39 AM Yang Yingliang <yangyingliang@huawei.com> wrote:
>
> > Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
> > in error path.
> >
> > Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
> > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> > ---
> > v2:
> > move alloc_ordered_workqueue() after ocelot_pinctrl_register().
>
> Horatiu does this v2 look like you want it? Reviewed-by?
I have noticed that Yang has sent another version (v3)[1] where he makes
uses of devm_add_action_or_reset.
[1] https://lore.kernel.org/all/20220925021258.1492905-1-yangyingliang@huawei.com/T/
>
> Yours,
> Linus Walleij
--
/Horatiu
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-10-04 9:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-17 2:46 [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe() Yang Yingliang
2022-09-17 2:46 ` [PATCH -next v2 2/2] pinctrl: ocelot: Use devm_platform_get_and_ioremap_resource() Yang Yingliang
2022-09-17 8:55 ` andy.shevchenko
2022-09-17 8:54 ` [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe() andy.shevchenko
2022-09-17 11:19 ` Yang Yingliang
2022-10-04 7:09 ` Linus Walleij
2022-10-04 9:11 ` Horatiu Vultur
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.