[PATCH] rtc: zynqmp: Return optional clock lookup errors

Michal Simek michal.simek at amd.com
Fri Jun 26 05:42:47 PDT 2026



On 6/24/26 07:55, Pengpeng Hou wrote:
> devm_clk_get_optional() returns NULL when the optional clock is absent,
> but returns an ERR_PTR when the clock provider lookup fails.  Probe
> currently keeps the ERR_PTR and then passes it to clk_get_rate().
> 
> Return the lookup error instead.  A truly absent optional clock still
> reaches the existing calibration fallback through clk_get_rate(NULL).
> 
> Signed-off-by: Pengpeng Hou <pengpeng at iscas.ac.cn>
> ---
>   drivers/rtc/rtc-zynqmp.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
> index 2ae54804b87a..5bcb7536e973 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -334,10 +334,9 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
>   
>   	/* Getting the rtc info */
>   	xrtcdev->rtc_clk = devm_clk_get_optional(&pdev->dev, "rtc");
> -	if (IS_ERR(xrtcdev->rtc_clk)) {
> -		if (PTR_ERR(xrtcdev->rtc_clk) != -EPROBE_DEFER)
> -			dev_warn(&pdev->dev, "Device clock not found.\n");
> -	}
> +	if (IS_ERR(xrtcdev->rtc_clk))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(xrtcdev->rtc_clk),
> +				     "Failed to get rtc clock\n");
>   	xrtcdev->freq = clk_get_rate(xrtcdev->rtc_clk);
>   	if (!xrtcdev->freq) {
>   		ret = of_property_read_u32(pdev->dev.of_node, "calibration",


Fixes: 07dcc6f9c762 ("rtc: zynqmp: Add calibration set and get support")
cc: stable at kernel.org

Reviewed-by: Michal Simek <michal.simek at amd.com>

Thanks,
Michal



More information about the linux-arm-kernel mailing list