rng: msm_rng: Acquire optional clock even when initialization is skipped
PATCH 1/1 rng: msm_rng: Acquire optional clock even when initialization is skipped
For devices marked with skip_init ("qcom,prng-ee" and "qcom,trng"), msm_rng_probe() currently returns early before retrieving the clock. As a result, priv->clk remains uninitialized, causing subsequent calls to msm_rng_read() to skip enabling the clock which may cause failure if the device boots with the clock disabled.
Move clk_get_by_index() before the skip_init check so that any clock specified in device tree is properly recorded. Additionally, treat -ENOENT as non-fatal so the clock remains optional for devices (such as some "qcom,trng" nodes) that do not define one.
--- drivers/rng/msm_rng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rng/msm_rng.c +4 -4
@@ -114,13 +114,13 @@ static int msm_rng_probe(struct udevice *dev)if (priv->base ==FDT_ADDR_T_NONE )return -EINVAL ; -if (priv->skip_init) -return 0 ; - ret =clk_get_by_index (dev,0 , &priv->clk); -if (ret) +if (ret && ret != -ENOENT )return ret; +if (priv->skip_init) +return 0 ; + ret =clk_enable (&priv->clk);if (ret <0 )return ret;
---
base-commit: 0e2a0ceeefa0ae10118b8364da62f1fb86f286c0
change-id: 20260914-qcom-rng-fix-a7dabc760daf
Best regards,
Signature · 1 line
Reza Kurniawan <[email protected]>
Hi Reza,
Quoted 6 lines · Reza Kurniawan
For devices marked with
skip_init("qcom,prng-ee" and "qcom,trng"),msm_rng_probe()currently returns early before retrieving the clock. As a result,priv->clkremains uninitialized, causing subsequent calls tomsm_rng_read()to skip enabling the clock which may cause failure if the device boots with the clock disabled.
Quoted 6 lines
Move
clk_get_by_index()before theskip_initcheck so that any clock specified in device tree is properly recorded. Additionally, treat-ENOENTas non-fatal so the clock remains optional for devices (such as some "qcom,trng" nodes) that do not define one.Signed-off-by Reza Kurniawan <[email protected]>
Quoted 34 lines
--- drivers/rng/msm_rng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/rng/msm_rng.c +4
-5@@ -114,13 +114,13 @@ static int msm_rng_probe(struct udevice *dev)if (priv->base ==FDT_ADDR_T_NONE )return -EINVAL ; -if (priv->skip_init) -return 0 ; - ret =clk_get_by_index (dev,0 , &priv->clk); -if (ret) +if (ret && ret != -ENOENT )return ret; +if (priv->skip_init) +return 0 ; + ret =clk_enable (&priv->clk);if (ret <0 )return ret; ---base-commit:
0e2a0ceeefa0ae10118b8364da62f1fb86f286c0
change-id: 20260914-qcom-rng-fix-a7dabc760dafBest regards,
--
Reza Kurniawan <[email protected]>
Quoted 11 lines · Reza Kurniawan
For devices marked with
skip_init("qcom,prng-ee" and "qcom,trng"),msm_rng_probe()currently returns early before retrieving the clock. As a result,priv->clkremains uninitialized, causing subsequent calls tomsm_rng_read()to skip enabling the clock which may cause failure if the device boots with the clock disabled.Move
clk_get_by_index()before theskip_initcheck so that any clock specified in device tree is properly recorded. Additionally, treat-ENOENTas non-fatal so the clock remains optional for devices (such as some "qcom,trng" nodes) that do not define one.
Quoted 4 lines
Signed-off-by Reza Kurniawan <[email protected]>--- drivers/rng/msm_rng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
-Sumit
Quoted 33 lines
drivers/rng/msm_rng.c +4
-5@@ -114,13 +114,13 @@ static int msm_rng_probe(struct udevice *dev)if (priv->base ==FDT_ADDR_T_NONE )return -EINVAL ; -if (priv->skip_init) -return 0 ; - ret =clk_get_by_index (dev,0 , &priv->clk); -if (ret) +if (ret && ret != -ENOENT )return ret; +if (priv->skip_init) +return 0 ; + ret =clk_enable (&priv->clk);if (ret <0 )return ret; ---base-commit:
0e2a0ceeefa0ae10118b8364da62f1fb86f286c0
change-id: 20260914-qcom-rng-fix-a7dabc760dafBest regards,
Signature · 1 line
Reza Kurniawan <[email protected]>