[PATCH v2 3/9] usb: chipidea: usb2: use devm_clk_get_optional_enabled()

Junzhong Pan panjunzhong at linux.spacemit.com
Tue Sep 8 03:01:52 PDT 2026


On 9/8/2026 5:55 PM, sashiko-bot at kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Double disable and unprepare of the clock during device removal.
> --
> 
> commit d2e0018bd6f14cd49dfa6012d83048e3abde69f6
> Author: Junzhong Pan <panjunzhong at linux.spacemit.com>
> 
> usb: chipidea: usb2: use devm_clk_get_optional_enabled()
> 
> Convert devm_clk_get_optional() and clk_prepare_enable() into a single
> call devm_clk_get_optional_enabled().
> 
>> diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
>> index 8ffa1e95d8e86..6fae2d4a053a1 100644
>> --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
>> +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> [ ... ]
>> @@ -99,10 +94,6 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
>>  	pm_runtime_enable(dev);
>>  
>>  	return 0;
>> -
>> -clk_err:
>> -	clk_disable_unprepare(priv->clk);
>> -	return ret;
>>  }
>>  
>>  static void ci_hdrc_usb2_remove(struct platform_device *pdev)
> 
> [Severity: High]
> Does this conversion also require removing the manual cleanup in
> ci_hdrc_usb2_remove()?
> 
> Since the clock is now managed by devm_clk_get_optional_enabled(), it will
> automatically handle disabling and unpreparing the clock when the device
> is removed. 
> 
> Leaving the manual clk_disable_unprepare(priv->clk) in ci_hdrc_usb2_remove():
> 
> static void ci_hdrc_usb2_remove(struct platform_device *pdev)
> {
> 	struct ci_hdrc_usb2_priv *priv = platform_get_drvdata(pdev);
> 
> 	pm_runtime_disable(&pdev->dev);
> 	ci_hdrc_remove_device(priv->ci_pdev);
> 	clk_disable_unprepare(priv->clk);
> }
> 
> appears to result in a double disable and unprepare of the clock during
> device removal, which could lead to unbalanced reference counts and trigger
> kernel warnings.

Ok, I will fix this in v3. Thanks.




More information about the linux-riscv mailing list