linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Peter Geis <pgwipeout@gmail.com>
Subject: Re: [PATCH v1 10/11] cpufreq: tegra20: Wrap cpufreq into platform driver
Date: Fri, 18 May 2018 12:19:16 +0300	[thread overview]
Message-ID: <4ed2535c-651a-2bb1-c9bc-0550bca3d292@gmail.com> (raw)
In-Reply-To: <20180518090755.GJ14500@ulmo>

On 18.05.2018 12:07, Thierry Reding wrote:
> On Thu, May 17, 2018 at 09:00:55PM +0300, Dmitry Osipenko wrote:
>> Currently tegra20-cpufreq kernel module isn't getting autoloaded because
>> there is no device associated with the module, this is one of two patches
>> that resolves the module autoloading. This patch adds a module alias that
>> will associate the tegra20-cpufreq kernel module with the platform device,
>> other patch will instantiate the actual platform device. And now it makes
>> sense to wrap cpufreq driver into a platform driver for consistency.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/cpufreq/tegra20-cpufreq.c | 116 +++++++++++++++++++-----------
>>  1 file changed, 73 insertions(+), 43 deletions(-)
>>
>> diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
>> index c0a7b5a78aa6..f9d02a28df9e 100644
>> --- a/drivers/cpufreq/tegra20-cpufreq.c
>> +++ b/drivers/cpufreq/tegra20-cpufreq.c
>> @@ -19,7 +19,7 @@
>>  #include <linux/clk.h>
>>  #include <linux/cpufreq.h>
>>  #include <linux/module.h>
>> -#include <linux/of.h>
>> +#include <linux/platform_device.h>
>>  
>>  static struct cpufreq_frequency_table freq_table[] = {
>>  	{ .frequency = 216000 },
>> @@ -33,15 +33,19 @@ static struct cpufreq_frequency_table freq_table[] = {
>>  	{ .frequency = CPUFREQ_TABLE_END },
>>  };
>>  
>> -static struct clk *cpu_clk;
>> -static struct clk *pll_x_clk;
>> -static struct clk *pll_p_clk;
>> -static bool pll_x_prepared;
>> +struct tegra20_cpufreq_data {
> 
> Nit: I'm not a big fan of _data suffixes because they are completely
> redundant. Any data structure by definition hosts data, so I'd just drop
> that.

Okay, I'll drop it in v2.

> [...]
>> @@ -152,55 +161,76 @@ static struct cpufreq_driver tegra_cpufreq_driver = {
>>  	.suspend		= cpufreq_generic_suspend,
>>  };
>>  
>> -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;
>> +	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;
> 
> Couldn't this be embedded into struct tegra20_cpufreq_data? Moving
> everything but this into a per-device data structure seems half-baked.

That's a good suggestions, thank you.

  reply	other threads:[~2018-05-18  9:19 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17 18:00 [PATCH v1 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
2018-05-17 18:00 ` [PATCH v1 01/11] cpufreq: tegra20: Change module description Dmitry Osipenko
2018-05-18  1:53   ` Viresh Kumar
2018-05-18  8:34   ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 02/11] cpufreq: tegra20: Clean up whitespaces in the code Dmitry Osipenko
2018-05-18  1:54   ` Viresh Kumar
2018-05-18  8:34   ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 03/11] cpufreq: tegra20: Remove EMC clock usage Dmitry Osipenko
2018-05-18  1:54   ` Viresh Kumar
2018-05-18  8:36   ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 04/11] cpufreq: tegra20: Release clocks properly Dmitry Osipenko
2018-05-18  1:55   ` Viresh Kumar
2018-05-18  8:37   ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 05/11] cpufreq: tegra20: Clean up included headers Dmitry Osipenko
2018-05-18  1:58   ` Viresh Kumar
2018-05-18  8:05     ` Dmitry Osipenko
2018-05-18  8:57       ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 06/11] cpufreq: tegra20: Remove unneeded check in tegra_cpu_init Dmitry Osipenko
2018-05-18  1:59   ` Viresh Kumar
2018-05-18  8:57   ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 07/11] cpufreq: tegra20: Check if this is Tegra20 machine Dmitry Osipenko
2018-05-18  1:59   ` Viresh Kumar
2018-05-18  8:58   ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 08/11] cpufreq: tegra20: Remove unneeded variable initialization Dmitry Osipenko
2018-05-18  2:00   ` Viresh Kumar
2018-05-18  8:58   ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 09/11] cpufreq: tegra20: Allow cpufreq driver to be built as loadable module Dmitry Osipenko
2018-05-18  2:00   ` Viresh Kumar
2018-05-18  9:00   ` Thierry Reding
2018-05-17 18:00 ` [PATCH v1 10/11] cpufreq: tegra20: Wrap cpufreq into platform driver Dmitry Osipenko
2018-05-18  2:07   ` Viresh Kumar
2018-05-18  8:09     ` Dmitry Osipenko
2018-05-18  9:04       ` Viresh Kumar
2018-05-18  9:07   ` Thierry Reding
2018-05-18  9:19     ` Dmitry Osipenko [this message]
2018-05-17 18:00 ` [PATCH v1 11/11] ARM: tegra: Create platform device for tegra20-cpufreq driver Dmitry Osipenko
2018-05-18  2:07   ` Viresh Kumar
2018-05-18  9:13   ` Thierry Reding
2018-05-18  9:30     ` Dmitry Osipenko
2018-05-18  7:30 ` [PATCH v1 00/11] Clean up Tegra20 cpufreq driver Rafael J. Wysocki
2018-05-18  8:18   ` Dmitry Osipenko

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=4ed2535c-651a-2bb1-c9bc-0550bca3d292@gmail.com \
    --to=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=pgwipeout@gmail.com \
    --cc=rjw@rjwysocki.net \
    --cc=thierry.reding@gmail.com \
    --cc=viresh.kumar@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).