[PATCH] mmc: sdhci-of-arasan: Unregister all clock providers

Adrian Hunter adrian.hunter at intel.com
Wed Nov 4 10:23:42 PST 2026


On 03/11/2026 12:05, Wentao Liang wrote:
> When #clock-cells is non-zero, sdhci_arasan_register_sdclk() registers
> two clock providers for the same device node: one for the card clock and
> one for the sample clock.  of_clk_add_provider() takes a reference to
> the device node for each registration, but the unregister helper only
> calls of_clk_del_provider() once.  The second device node reference is
> therefore leaked and the sample clock provider remains registered after
> the driver has been unbound.
> 
> Drop one provider for every clock that was registered.
> 
> Fixes: 07a14d1df454 ("mmc: sdhci-of-arasan: Add sampling clock for a phy to use")
> Cc: stable at vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex

"Assisted-by" tag is not used anymore

> Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>

Looks OK to me but maybe someone who uses this code could
review or test it, since Krzysztof has cast some doubt on the
contributor.

> ---
>  drivers/mmc/host/sdhci-of-arasan.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
> index 0ee22923ad56..dccd2980fdd6 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -1648,11 +1648,20 @@ sdhci_arasan_register_sampleclk(struct sdhci_arasan_data *sdhci_arasan,
>  static void sdhci_arasan_unregister_sdclk(struct device *dev)
>  {
>  	struct device_node *np = dev->of_node;
> +	u32 num_clks = 0;
>  
> -	if (!of_property_present(np, "#clock-cells"))
> +	if (of_property_read_u32(np, "#clock-cells", &num_clks) < 0)
>  		return;
>  
> -	of_clk_del_provider(dev->of_node);
> +	of_clk_del_provider(np);
> +
> +	/*
> +	 * sdhci_arasan_register_sdclk() registers a second provider for the
> +	 * sample clock when #clock-cells is non-zero, and each provider holds
> +	 * its own reference to the device node.
> +	 */
> +	if (num_clks)
> +		of_clk_del_provider(np);
>  }
>  
>  /**




More information about the linux-arm-kernel mailing list