Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

reset: rzg2l-usbphy-ctrl: Move reset controller registration

As soon as the reset controller is registered, it could be used by a
reset consumer. That means hardware setup to be done first and then the
registration of the reset controller. So move the registration of reset
controller at the end of probe().

While at it, fix the issue that the reset is not re-asserted in case
devm_reset_controller_register() fails and also use goto statements to
simplify the error path in probe().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240610164845.89666-1-biju.das.jz@bp.renesas.com
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Biju Das and committed by
Philipp Zabel
b081f13c 1613e604

+19 -13
+19 -13
drivers/reset/reset-rzg2l-usbphy-ctrl.c
··· 125 125 if (error) 126 126 return error; 127 127 128 - priv->rcdev.ops = &rzg2l_usbphy_ctrl_reset_ops; 129 - priv->rcdev.of_reset_n_cells = 1; 130 - priv->rcdev.nr_resets = NUM_PORTS; 131 - priv->rcdev.of_node = dev->of_node; 132 - priv->rcdev.dev = dev; 133 - 134 - error = devm_reset_controller_register(dev, &priv->rcdev); 135 - if (error) 136 - return error; 137 - 138 128 spin_lock_init(&priv->lock); 139 129 dev_set_drvdata(dev, priv); 140 130 141 131 pm_runtime_enable(&pdev->dev); 142 132 error = pm_runtime_resume_and_get(&pdev->dev); 143 133 if (error < 0) { 144 - pm_runtime_disable(&pdev->dev); 145 - reset_control_assert(priv->rstc); 146 - return dev_err_probe(&pdev->dev, error, "pm_runtime_resume_and_get failed"); 134 + dev_err_probe(&pdev->dev, error, "pm_runtime_resume_and_get failed"); 135 + goto err_pm_disable_reset_deassert; 147 136 } 148 137 149 138 /* put pll and phy into reset state */ ··· 142 153 writel(val, priv->base + RESET); 143 154 spin_unlock_irqrestore(&priv->lock, flags); 144 155 156 + priv->rcdev.ops = &rzg2l_usbphy_ctrl_reset_ops; 157 + priv->rcdev.of_reset_n_cells = 1; 158 + priv->rcdev.nr_resets = NUM_PORTS; 159 + priv->rcdev.of_node = dev->of_node; 160 + priv->rcdev.dev = dev; 161 + 162 + error = devm_reset_controller_register(dev, &priv->rcdev); 163 + if (error) 164 + goto err_pm_runtime_put; 165 + 145 166 return 0; 167 + 168 + err_pm_runtime_put: 169 + pm_runtime_put(&pdev->dev); 170 + err_pm_disable_reset_deassert: 171 + pm_runtime_disable(&pdev->dev); 172 + reset_control_assert(priv->rstc); 173 + return error; 146 174 } 147 175 148 176 static int rzg2l_usbphy_ctrl_remove(struct platform_device *pdev)