linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] cpufreq: ti-cpufreq: Only register platform_device when supported
@ 2018-11-13 17:39 Dave Gerlach
  2018-11-13 17:58 ` Johan Hovold
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Gerlach @ 2018-11-13 17:39 UTC (permalink / raw)
  To: Viresh Kumar, Rafael J . Wysocki
  Cc: linux-arm-kernel, linux-omap, linux-pm, linux-kernel, Keerthy J,
	Tero Kristo, Tony Lindgren, Nishanth Menon, Dave Gerlach,
	Stephen Boyd, Johan Hovold

Currently the ti-cpufreq driver blindly registers a 'ti-cpufreq' to force
the driver to probe on any platforms where the driver is built in.
However, this should only happen on platforms that actually can make use
of the driver. There is already functionality in place to match the
SoC compatible so let's factor this out into a separate call and
make sure we find a match before creating the ti-cpufreq platform device.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
v2->v3: Use platform_device_register_resndata to pass match data to probe to
	to avoid matching again in probe.

	v2: https://patchwork.kernel.org/patch/10574535/

 drivers/cpufreq/ti-cpufreq.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index 3f0e2a14895a..2f97a4b38bad 100644
--- a/drivers/cpufreq/ti-cpufreq.c
+++ b/drivers/cpufreq/ti-cpufreq.c
@@ -201,19 +201,28 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
 	{},
 };
 
+static const struct of_device_id *ti_cpufreq_match_node(void)
+{
+	struct device_node *np;
+	const struct of_device_id *match;
+
+	np = of_find_node_by_path("/");
+	match = of_match_node(ti_cpufreq_of_match, np);
+	of_node_put(np);
+
+	return match;
+}
+
 static int ti_cpufreq_probe(struct platform_device *pdev)
 {
 	u32 version[VERSION_COUNT];
-	struct device_node *np;
 	const struct of_device_id *match;
 	struct opp_table *ti_opp_table;
 	struct ti_cpufreq_data *opp_data;
 	const char * const reg_names[] = {"vdd", "vbb"};
 	int ret;
 
-	np = of_find_node_by_path("/");
-	match = of_match_node(ti_cpufreq_of_match, np);
-	of_node_put(np);
+	match = dev_get_platdata(&pdev->dev);
 	if (!match)
 		return -ENODEV;
 
@@ -290,7 +299,15 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
 
 static int ti_cpufreq_init(void)
 {
-	platform_device_register_simple("ti-cpufreq", -1, NULL, 0);
+	const struct of_device_id *match;
+
+	/* Check to ensure we are on a compatible platform */
+	match = ti_cpufreq_match_node();
+	if (match)
+		platform_device_register_resndata(NULL, "ti-cpufreq", -1, NULL,
+						  0, match,
+						  sizeof(*match));
+
 	return 0;
 }
 module_init(ti_cpufreq_init);
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] cpufreq: ti-cpufreq: Only register platform_device when supported
  2018-11-13 17:39 [PATCH v3] cpufreq: ti-cpufreq: Only register platform_device when supported Dave Gerlach
@ 2018-11-13 17:58 ` Johan Hovold
  2018-11-13 19:14   ` Dave Gerlach
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hovold @ 2018-11-13 17:58 UTC (permalink / raw)
  To: Dave Gerlach
  Cc: Viresh Kumar, Rafael J . Wysocki, linux-arm-kernel, linux-omap,
	linux-pm, linux-kernel, Keerthy J, Tero Kristo, Tony Lindgren,
	Nishanth Menon, Stephen Boyd, Johan Hovold

On Tue, Nov 13, 2018 at 11:39:12AM -0600, Dave Gerlach wrote:
> Currently the ti-cpufreq driver blindly registers a 'ti-cpufreq' to force
> the driver to probe on any platforms where the driver is built in.
> However, this should only happen on platforms that actually can make use
> of the driver. There is already functionality in place to match the
> SoC compatible so let's factor this out into a separate call and
> make sure we find a match before creating the ti-cpufreq platform device.
> 
> Reviewed-by: Johan Hovold <johan@kernel.org>
> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> ---
> v2->v3: Use platform_device_register_resndata to pass match data to probe to
> 	to avoid matching again in probe.
> 
> 	v2: https://patchwork.kernel.org/patch/10574535/
> 

>  static int ti_cpufreq_init(void)
>  {
> -	platform_device_register_simple("ti-cpufreq", -1, NULL, 0);
> +	const struct of_device_id *match;
> +
> +	/* Check to ensure we are on a compatible platform */
> +	match = ti_cpufreq_match_node();
> +	if (match)
> +		platform_device_register_resndata(NULL, "ti-cpufreq", -1, NULL,
> +						  0, match,
> +						  sizeof(*match));

platform_device_register_data()?

>  	return 0;
>  }
>  module_init(ti_cpufreq_init);

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] cpufreq: ti-cpufreq: Only register platform_device when supported
  2018-11-13 17:58 ` Johan Hovold
@ 2018-11-13 19:14   ` Dave Gerlach
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Gerlach @ 2018-11-13 19:14 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Viresh Kumar, Rafael J . Wysocki, linux-arm-kernel, linux-omap,
	linux-pm, linux-kernel, Keerthy J, Tero Kristo, Tony Lindgren,
	Nishanth Menon, Stephen Boyd

On 11/13/2018 11:58 AM, Johan Hovold wrote:
> On Tue, Nov 13, 2018 at 11:39:12AM -0600, Dave Gerlach wrote:
>> Currently the ti-cpufreq driver blindly registers a 'ti-cpufreq' to force
>> the driver to probe on any platforms where the driver is built in.
>> However, this should only happen on platforms that actually can make use
>> of the driver. There is already functionality in place to match the
>> SoC compatible so let's factor this out into a separate call and
>> make sure we find a match before creating the ti-cpufreq platform device.
>>
>> Reviewed-by: Johan Hovold <johan@kernel.org>
>> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
>> ---
>> v2->v3: Use platform_device_register_resndata to pass match data to probe to
>> 	to avoid matching again in probe.
>>
>> 	v2: https://patchwork.kernel.org/patch/10574535/
>>
> 
>>  static int ti_cpufreq_init(void)
>>  {
>> -	platform_device_register_simple("ti-cpufreq", -1, NULL, 0);
>> +	const struct of_device_id *match;
>> +
>> +	/* Check to ensure we are on a compatible platform */
>> +	match = ti_cpufreq_match_node();
>> +	if (match)
>> +		platform_device_register_resndata(NULL, "ti-cpufreq", -1, NULL,
>> +						  0, match,
>> +						  sizeof(*match));
> 
> platform_device_register_data()?

Whoops yeah that's a bit more concise, v4 incoming.

Regards,
Dave

> 
>>  	return 0;
>>  }
>>  module_init(ti_cpufreq_init);
> 
> Johan
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-13 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 17:39 [PATCH v3] cpufreq: ti-cpufreq: Only register platform_device when supported Dave Gerlach
2018-11-13 17:58 ` Johan Hovold
2018-11-13 19:14   ` Dave Gerlach

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).