Re: [PATCH v4 2/2] cpufreq: tegra124: Allow building as a module

Jon Hunter
2025-05-20T10:03:46Z

On 19/05/2025 11:26, Viresh Kumar wrote:
> On 14-05-25, 11:31, Jon Hunter wrote:
>>> +static void tegra124_cpufreq_remove(struct platform_device *pdev)
>>> +{
>>> + struct tegra124_cpufreq_priv *priv = dev_get_drvdata(&pdev->dev);
>>> +
>>> + if (!IS_ERR(priv->cpufreq_dt_pdev)) {
>>> + platform_device_unregister(priv->cpufreq_dt_pdev);
>>> + priv->cpufreq_dt_pdev = ERR_PTR(-ENODEV);
>>> + }
>>> +
>>> + clk_put(priv->pllp_clk);
>>> + clk_put(priv->pllx_clk);
>>> + clk_put(priv->dfll_clk);
>>> + clk_put(priv->cpu_clk);
>>
>>
>> If we use devm_clk_get() in probe, then we should be able to avoid this.
>
> Not sure if we can do that. The clks belong to the CPU device, while
> the devm_* functions are using &pdev->dev. The CPU device never goes
> away and so the resources won't get freed if we use devm for the CPU
> device.

I don't follow. If they are allocated in the probe using the pdev->dev
device by using devm_clk_get() they should get freed when the platform
device is removed.

Jon

--
nvpublic