counter: rz-mtu3-cnt: Abort probe if clock enable fails
Subsystems (3)
PATCH 1/1 counter: rz-mtu3-cnt: Abort probe if clock enable fails
When the RZ/G2L MTU3 module clock has no active enable reference, clk_prepare_enable() can reach the CPG gate callback and return -ETIMEDOUT if the gate fails to report enabled.
rz_mtu3_cnt_probe() ignores the error, marks the device runtime-active, and registers the Counter. Later Counter operations can access registers while the clock may still be off. Probe error handling or runtime suspend can also release a clock reference the probe never acquired.
Return the error through dev_err_probe() before setting up runtime PM or registering the Counter. clk_prepare_enable() rolls back the prepare reference on enable failure, so only errors after a successful enable need the existing clock cleanup.
Verification included source review,
an arm64 RZ/G2L driver object build, git diff --check, and checkpatch. Runtime and hardware reproduction were not performed.
--- drivers/counter/rz-mtu3-cnt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/counter/rz-mtu3-cnt.c +4 -1
@@ -861,7 +861,10 @@ static int rz_mtu3_cnt_probe(struct platform_device *pdev)mutex_init (&priv->lock);platform_set_drvdata (pdev, priv->clk); -clk_prepare_enable (priv->clk); + ret =clk_prepare_enable (priv->clk); +if (ret) +return dev_err_probe (dev, ret,"Clock enable failed\n" ); +pm_runtime_set_active (&pdev->dev);pm_runtime_enable (&pdev->dev); ret =devm_add_action_or_reset (&pdev->dev, rz_mtu3_cnt_pm_disable, dev);
Signature · 1 line
2.34.1