[PATCH] nvmem: imx-ocotp: Propagate clock setup errors from probe
Peng Fan (OSS)
peng.fan at oss.nxp.com
Sun Nov 29 18:41:46 PST 2026
On Sun, 29 Nov 2026 19:25:33 +0000 Jiawen Liu <liu1298662399 at gmail.com> wrote:
> imx_ocotp_probe() ignores the return value of clk_prepare_enable().
> On i.MX6SL, preparing the OCOTP clock can propagate a PLL2 lock timeout
> if PLL2 is selected and the shared clock chain is unprepared. The clock
> provider can still publish the OCOTP gate if registration of the critical
> MMDC IPG gate fails to prepare that chain.
>
> Probe then accesses the OCOTP registers without acquiring the clock,
> attempts an unmatched clk_disable_unprepare(), and can report success
> if NVMEM registration succeeds.
>
> Return the original clock error before clearing the OCOTP status or
> registering NVMEM. On success, release the clock after clearing the
> status, before registering NVMEM.
>
> Verified the probe and devres paths
> by source inspection, ran git diff --check and checkpatch.pl, and built
> imx-ocotp.o with Clang 19 using the ARM imx_v6_v7_defconfig.
> Runtime and hardware reproduction were not performed.
>
> Fixes: c33c585f1b3a ("nvmem: imx-ocotp: reset error status on probe")
> Signed-off-by: Jiawen Liu <liu1298662399 at gmail.com>
> ---
> drivers/nvmem/imx-ocotp.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
> index 55e07fd919a21..ecc085bb39e31 100644
> --- a/drivers/nvmem/imx-ocotp.c
> +++ b/drivers/nvmem/imx-ocotp.c
> @@ -598,6 +598,7 @@ static int imx_ocotp_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct ocotp_priv *priv;
> struct nvmem_device *nvmem;
> + int ret;
>
> priv = devm_kzalloc_obj(dev, *priv);
> if (!priv)
> @@ -622,7 +623,10 @@ static int imx_ocotp_probe(struct platform_device *pdev)
>
> priv->config = &imx_ocotp_nvmem_config;
>
> - clk_prepare_enable(priv->clk);
> + ret = clk_prepare_enable(priv->clk);
> + if (ret)
> + return ret;
> +
> imx_ocotp_clr_err_if_set(priv);
> clk_disable_unprepare(priv->clk);
Reviewed-by: Peng Fan <peng.fan at nxp.com>
More information about the linux-arm-kernel
mailing list