From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Bill Huang <bilhuang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org,
viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cpufreq-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3 2/2] cpufreq: tegra: Re-model Tegra cpufreq driver
Date: Thu, 05 Dec 2013 16:04:33 -0700 [thread overview]
Message-ID: <52A10681.4050906@wwwdotorg.org> (raw)
In-Reply-To: <1386229462-3474-3-git-send-email-bilhuang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
On 12/05/2013 12:44 AM, Bill Huang wrote:
> Re-model Tegra cpufreq driver to support all Tegra series of SoCs.
>
> * Make tegra-cpufreq.c a generic Tegra cpufreq driver.
> * Move Tegra20 specific codes into tegra20-cpufreq.c.
> * Bind Tegra cpufreq dirver with a fake device so defer probe would work
> when we're going to get regulator in the driver to support voltage
> scaling (DVFS).
> diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
> @@ -91,14 +40,10 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
...
> + if (soc_config->vote_emc_on_cpu_rate)
> + soc_config->vote_emc_on_cpu_rate(rate);
> +
> + ret = soc_config->cpu_clk_set_rate(rate * 1000);
> if (ret)
> pr_err("cpu-tegra: Failed to set cpu frequency to %lu kHz\n",
> rate);
Is there any/much shared code left in this file after this patch? It
seems like all this file does now is make each cpufreq callback function
call soc_config->the_same_function_name(). If so, wouldn't it be better
to simply implement completely separate tegar20-cpufreq and
tegra30-cpufreq drivers, and register them each directly with the
cpufreq core, to avoid this file doing all the indirection?
> -int __init tegra_cpufreq_init(void)
> +static struct {
> + char *compat;
> + int (*init)(struct tegra_cpufreq_data *,
> + const struct tegra_cpufreq_config **);
> +} tegra_init_funcs[] = {
> + { "nvidia,tegra20", tegra20_cpufreq_init },
> +};
> +
> +static int tegra_cpufreq_probe(struct platform_device *pdev)
...
> + for (i = 0; i < ARRAY_SIZE(tegra_init_funcs); i++) {
> + if (of_machine_is_compatible(tegra_init_funcs[i].compat)) {
> + ret = tegra_init_funcs[i].init(tegra_data, &soc_config);
> + if (!ret)
> + break;
> + else
> + goto out;
> + }
> }
> + if (i == ARRAY_SIZE(tegra_init_funcs))
> + goto out;
I think there are better ways of doing this than open-coding it. Perhaps
of_match_device() or the platform-driver equivalent could be made to work?
> +int __init tegra_cpufreq_init(void)
> +{
> + struct platform_device_info devinfo = { .name = "tegra-cpufreq", };
> +
> + platform_device_register_full(&devinfo);
> +
> + return 0;
> }
> EXPORT_SYMBOL(tegra_cpufreq_init);
Perhaps instead of hard-coding the name "tegra-cpufreq" here, you could
dynamically construct the device name based on the DT's root compatible
value, register "${root_compatible}-cpufreq", e.g.
"nvidia,tegra20-cpufreq" or "nvidia,tegra30-cpufreq". That would allow
the kernel's standard device/driver matching mechanism to pick the
correct driver to instantiate. Perhaps you could even dynamically
register an OF device so that you can use of_match_device() in probe, if
there's some advantage of having a single driver that supports N chips.
WARNING: multiple messages have this Message-ID (diff)
From: Stephen Warren <swarren@wwwdotorg.org>
To: Bill Huang <bilhuang@nvidia.com>,
rjw@rjwysocki.net, viresh.kumar@linaro.org,
thierry.reding@gmail.com
Cc: linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v3 2/2] cpufreq: tegra: Re-model Tegra cpufreq driver
Date: Thu, 05 Dec 2013 16:04:33 -0700 [thread overview]
Message-ID: <52A10681.4050906@wwwdotorg.org> (raw)
In-Reply-To: <1386229462-3474-3-git-send-email-bilhuang@nvidia.com>
On 12/05/2013 12:44 AM, Bill Huang wrote:
> Re-model Tegra cpufreq driver to support all Tegra series of SoCs.
>
> * Make tegra-cpufreq.c a generic Tegra cpufreq driver.
> * Move Tegra20 specific codes into tegra20-cpufreq.c.
> * Bind Tegra cpufreq dirver with a fake device so defer probe would work
> when we're going to get regulator in the driver to support voltage
> scaling (DVFS).
> diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
> @@ -91,14 +40,10 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
...
> + if (soc_config->vote_emc_on_cpu_rate)
> + soc_config->vote_emc_on_cpu_rate(rate);
> +
> + ret = soc_config->cpu_clk_set_rate(rate * 1000);
> if (ret)
> pr_err("cpu-tegra: Failed to set cpu frequency to %lu kHz\n",
> rate);
Is there any/much shared code left in this file after this patch? It
seems like all this file does now is make each cpufreq callback function
call soc_config->the_same_function_name(). If so, wouldn't it be better
to simply implement completely separate tegar20-cpufreq and
tegra30-cpufreq drivers, and register them each directly with the
cpufreq core, to avoid this file doing all the indirection?
> -int __init tegra_cpufreq_init(void)
> +static struct {
> + char *compat;
> + int (*init)(struct tegra_cpufreq_data *,
> + const struct tegra_cpufreq_config **);
> +} tegra_init_funcs[] = {
> + { "nvidia,tegra20", tegra20_cpufreq_init },
> +};
> +
> +static int tegra_cpufreq_probe(struct platform_device *pdev)
...
> + for (i = 0; i < ARRAY_SIZE(tegra_init_funcs); i++) {
> + if (of_machine_is_compatible(tegra_init_funcs[i].compat)) {
> + ret = tegra_init_funcs[i].init(tegra_data, &soc_config);
> + if (!ret)
> + break;
> + else
> + goto out;
> + }
> }
> + if (i == ARRAY_SIZE(tegra_init_funcs))
> + goto out;
I think there are better ways of doing this than open-coding it. Perhaps
of_match_device() or the platform-driver equivalent could be made to work?
> +int __init tegra_cpufreq_init(void)
> +{
> + struct platform_device_info devinfo = { .name = "tegra-cpufreq", };
> +
> + platform_device_register_full(&devinfo);
> +
> + return 0;
> }
> EXPORT_SYMBOL(tegra_cpufreq_init);
Perhaps instead of hard-coding the name "tegra-cpufreq" here, you could
dynamically construct the device name based on the DT's root compatible
value, register "${root_compatible}-cpufreq", e.g.
"nvidia,tegra20-cpufreq" or "nvidia,tegra30-cpufreq". That would allow
the kernel's standard device/driver matching mechanism to pick the
correct driver to instantiate. Perhaps you could even dynamically
register an OF device so that you can use of_match_device() in probe, if
there's some advantage of having a single driver that supports N chips.
next prev parent reply other threads:[~2013-12-05 23:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 7:44 [PATCH v3 0/2] Remodel Tegra cpufreq drivers to support Tegra series SoC Bill Huang
2013-12-05 7:44 ` Bill Huang
2013-12-05 7:44 ` [PATCH v3 1/2] cpufreq: tegra: Call tegra_cpufreq_init() specifically in machine code Bill Huang
2013-12-05 7:44 ` Bill Huang
2013-12-05 22:54 ` Stephen Warren
2013-12-09 8:41 ` bilhuang
2013-12-17 6:31 ` Viresh Kumar
2013-12-17 10:48 ` bilhuang
2013-12-05 7:44 ` [PATCH v3 2/2] cpufreq: tegra: Re-model Tegra cpufreq driver Bill Huang
2013-12-05 7:44 ` Bill Huang
[not found] ` <1386229462-3474-3-git-send-email-bilhuang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-12-05 23:04 ` Stephen Warren [this message]
2013-12-05 23:04 ` Stephen Warren
2013-12-09 8:44 ` bilhuang
2013-12-09 17:32 ` Stephen Warren
2013-12-11 11:18 ` bilhuang
2013-12-11 18:39 ` Stephen Warren
2013-12-17 6:54 ` Viresh Kumar
2013-12-17 10:52 ` bilhuang
2013-12-18 11:11 ` Viresh Kumar
2013-12-18 11:33 ` bilhuang
[not found] ` <52B187F5.7020105-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-12-18 14:39 ` Viresh Kumar
2013-12-18 14:39 ` Viresh Kumar
2013-12-19 5:26 ` bilhuang
[not found] ` <52B28397.5010808-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-12-19 5:29 ` Viresh Kumar
2013-12-19 5:29 ` Viresh Kumar
2013-12-19 5:57 ` bilhuang
[not found] ` <1386229462-3474-1-git-send-email-bilhuang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-12-17 6:26 ` [PATCH v3 0/2] Remodel Tegra cpufreq drivers to support Tegra series SoC Viresh Kumar
2013-12-17 6:26 ` Viresh Kumar
[not found] ` <CAKohponJAU20MQ92y4VaOXbsOOmxz6K=349KCq91c5=P=zQOQQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-17 10:47 ` bilhuang
2013-12-17 10:47 ` bilhuang
2013-12-17 10:51 ` Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52A10681.4050906@wwwdotorg.org \
--to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
--cc=bilhuang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=cpufreq-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org \
--cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.