From: Lad Prabhakar <[email protected]>
In the event of failure during devm_reset_controller_register(), ensure
that the reset line is asserted back.
Fixes: bee08559701fb ("reset: renesas: Add RZ/G2L usbphy control driver")
Signed-off-by: Lad Prabhakar <[email protected]>
---
drivers/reset/reset-rzg2l-usbphy-ctrl.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
index a8dde4606360..43eb01105596 100644
--- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
+++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
@@ -132,8 +132,10 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
priv->rcdev.dev = dev;
error = devm_reset_controller_register(dev, &priv->rcdev);
- if (error)
+ if (error) {
+ reset_control_assert(priv->rstc);
return error;
+ }
spin_lock_init(&priv->lock);
dev_set_drvdata(dev, priv);
--
2.34.1
Hi Prabhakar,
On Thu, Mar 21, 2024 at 12:43 PM Prabhakar <[email protected]> wrote:
> From: Lad Prabhakar <[email protected]>
>
> In the event of failure during devm_reset_controller_register(), ensure
> that the reset line is asserted back.
>
> Fixes: bee08559701fb ("reset: renesas: Add RZ/G2L usbphy control driver")
> Signed-off-by: Lad Prabhakar <[email protected]>
Thanks for your patch!
> --- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> +++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> @@ -132,8 +132,10 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
> priv->rcdev.dev = dev;
>
> error = devm_reset_controller_register(dev, &priv->rcdev);
> - if (error)
> + if (error) {
> + reset_control_assert(priv->rstc);
> return error;
> + }
>
> spin_lock_init(&priv->lock);
> dev_set_drvdata(dev, priv);
Reviewed-by: Geert Uytterhoeven <[email protected]>
Alternatively, you could register a cleanup handler with
devm_add_action_or_reset(), like many drivers already do.
Or better, turn devm_aspeed_peci_reset_control_deassert() into a
generic helper, and convert all drivers[1] to use that.
That would just leave us with undoing pm_runtime_enable(), which can
be automated using devm_pm_runtime_enable() instead.
[1] git grep -w devm.*reset_control_assert
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68korg
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert,
Thank you for the review.
On Wed, Apr 17, 2024 at 3:38 PM Geert Uytterhoeven <[email protected]> wrote:
>
> Hi Prabhakar,
>
> On Thu, Mar 21, 2024 at 12:43 PM Prabhakar <[email protected]> wrote:
> > From: Lad Prabhakar <[email protected]>
> >
> > In the event of failure during devm_reset_controller_register(), ensure
> > that the reset line is asserted back.
> >
> > Fixes: bee08559701fb ("reset: renesas: Add RZ/G2L usbphy control driver")
> > Signed-off-by: Lad Prabhakar <[email protected]>
>
> Thanks for your patch!
>
> > --- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> > +++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> > @@ -132,8 +132,10 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
> > priv->rcdev.dev = dev;
> >
> > error = devm_reset_controller_register(dev, &priv->rcdev);
> > - if (error)
> > + if (error) {
> > + reset_control_assert(priv->rstc);
> > return error;
> > + }
> >
> > spin_lock_init(&priv->lock);
> > dev_set_drvdata(dev, priv);
>
> Reviewed-by: Geert Uytterhoeven <[email protected]>
>
> Alternatively, you could register a cleanup handler with
> devm_add_action_or_reset(), like many drivers already do.
> Or better, turn devm_aspeed_peci_reset_control_deassert() into a
> generic helper, and convert all drivers[1] to use that.
>
Good point, I'll send an RFC patch for this.
> That would just leave us with undoing pm_runtime_enable(), which can
> be automated using devm_pm_runtime_enable() instead.
>
Agreed.
> [1] git grep -w devm.*reset_control_assert
>
Cheers,
Prabhakar