[PATCH] i3c: master: cdns: Simplify handling clocks in probe()
Krzysztof Kozlowski
krzysztof.kozlowski at linaro.org
Mon Jul 14 07:40:53 PDT 2025
On 14/07/2025 16:15, Frank Li wrote:
> On Sun, Jul 13, 2025 at 05:24:12PM +0200, Krzysztof Kozlowski wrote:
>> The two clocks, driver is getting, are not being disabled/re-enabled
>> during runtime of the device. Eliminate one variable in state struct,
>> all error paths and a lot of code from probe() and remove() by using
>> devm_clk_get_enabled().
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski at linaro.org>
>> ---
>> drivers/i3c/master/i3c-master-cdns.c | 51 +++++++---------------------
>> 1 file changed, 12 insertions(+), 39 deletions(-)
>>
>> diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c
>> index 449e85d7ba87..cc504b58013a 100644
>> --- a/drivers/i3c/master/i3c-master-cdns.c
>> +++ b/drivers/i3c/master/i3c-master-cdns.c
>> @@ -412,7 +412,6 @@ struct cdns_i3c_master {
>> } xferqueue;
>> void __iomem *regs;
>> struct clk *sysclk;
>> - struct clk *pclk;
>> struct cdns_i3c_master_caps caps;
>> unsigned long i3c_scl_lim;
>> const struct cdns_i3c_data *devdata;
>> @@ -1566,6 +1565,7 @@ MODULE_DEVICE_TABLE(of, cdns_i3c_master_of_ids);
>> static int cdns_i3c_master_probe(struct platform_device *pdev)
>> {
>> struct cdns_i3c_master *master;
>> + struct clk *pclk;
>> int ret, irq;
>> u32 val;
>>
>> @@ -1581,11 +1581,11 @@ static int cdns_i3c_master_probe(struct platform_device *pdev)
>> if (IS_ERR(master->regs))
>> return PTR_ERR(master->regs);
>>
>> - master->pclk = devm_clk_get(&pdev->dev, "pclk");
>> - if (IS_ERR(master->pclk))
>> - return PTR_ERR(master->pclk);
>> + pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
>> + if (IS_ERR(pclk))
>> + return PTR_ERR(pclk);
>>
>> - master->sysclk = devm_clk_get(&pdev->dev, "sysclk");
>> + master->sysclk = devm_clk_get_enabled(&pdev->dev, "sysclk");
>
> Can you use devm_clk_bulk_get_all_enabled() to simpilfy futher?
Instead of asking redundant question check yourself. On a first glance
it cannot, because it won't be simpler - you still need individual
clock. But if you find it possible which is not visible on first glance,
make a proposal instead of just random drive by comments.
Best regards,
Krzysztof
More information about the linux-i3c
mailing list