lkml.org 
[lkml]   [2018]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1 10/11] cpufreq: tegra20: Wrap cpufreq into platform driver
On 17-05-18, 21:00, Dmitry Osipenko wrote:
> -static int __init tegra_cpufreq_init(void)
> +static int tegra20_cpufreq_probe(struct platform_device *pdev)
> {
> + struct tegra20_cpufreq_data *data;
> int err;
>
> - if (!of_machine_is_compatible("nvidia,tegra20"))
> - return -ENODEV;

So this stuff wasn't really required as you are getting rid of that in
the same series. Should we really add it then ? Maybe ..

> + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
>
> - cpu_clk = clk_get_sys(NULL, "cclk");
> - if (IS_ERR(cpu_clk))
> - return PTR_ERR(cpu_clk);
> + data->cpu_clk = clk_get_sys(NULL, "cclk");
> + if (IS_ERR(data->cpu_clk))
> + return PTR_ERR(data->cpu_clk);
>
> - pll_x_clk = clk_get_sys(NULL, "pll_x");
> - if (IS_ERR(pll_x_clk)) {
> - err = PTR_ERR(pll_x_clk);
> + data->pll_x_clk = clk_get_sys(NULL, "pll_x");
> + if (IS_ERR(data->pll_x_clk)) {
> + err = PTR_ERR(data->pll_x_clk);
> goto put_cpu;
> }
>
> - pll_p_clk = clk_get_sys(NULL, "pll_p");
> - if (IS_ERR(pll_p_clk)) {
> - err = PTR_ERR(pll_p_clk);
> + data->pll_p_clk = clk_get_sys(NULL, "pll_p");
> + if (IS_ERR(data->pll_p_clk)) {
> + err = PTR_ERR(data->pll_p_clk);
> goto put_pll_x;
> }
>
> + data->dev = &pdev->dev;
> +
> + tegra_cpufreq_driver.driver_data = data;
> +
> err = cpufreq_register_driver(&tegra_cpufreq_driver);
> if (err)
> goto put_pll_p;
>
> + platform_set_drvdata(pdev, data);
> +
> return 0;
>
> put_pll_p:
> - clk_put(pll_p_clk);
> + clk_put(data->pll_p_clk);
> put_pll_x:
> - clk_put(pll_x_clk);
> + clk_put(data->pll_x_clk);
> put_cpu:
> - clk_put(cpu_clk);
> + clk_put(data->cpu_clk);
>
> return err;
> }
>
> -static void __exit tegra_cpufreq_exit(void)
> +static int tegra20_cpufreq_remove(struct platform_device *pdev)
> {
> + struct tegra20_cpufreq_data *data = platform_get_drvdata(pdev);
> +
> cpufreq_unregister_driver(&tegra_cpufreq_driver);
> - clk_put(pll_p_clk);
> - clk_put(pll_x_clk);
> - clk_put(cpu_clk);
> +
> + clk_put(data->pll_p_clk);
> + clk_put(data->pll_x_clk);
> + clk_put(data->cpu_clk);
> +
> + return 0;
> }
>
> +static struct platform_driver tegra20_cpufreq_driver = {
> + .probe = tegra20_cpufreq_probe,
> + .remove = tegra20_cpufreq_remove,
> + .driver = {
> + .name = "tegra20-cpufreq",
> + },
> +};
> +module_platform_driver(tegra20_cpufreq_driver);
> +
> MODULE_AUTHOR("Colin Cross <ccross@android.com>");
> +MODULE_ALIAS("platform:tegra20-cpufreq");
> MODULE_DESCRIPTION("NVIDIA Tegra20 cpufreq driver");
> MODULE_LICENSE("GPL");
> -module_init(tegra_cpufreq_init);
> -module_exit(tegra_cpufreq_exit);

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

--
viresh

\
 
 \ /
  Last update: 2018-05-18 04:08    [W:0.247 / U:5.432 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site