]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.9/cpufreq-ti-cpufreq-only-register-platform_device-whe.patch
drop queue-4.14/mips-make-sure-dt-memory-regions-are-valid.patch
[thirdparty/kernel/stable-queue.git] / releases / 4.19.9 / cpufreq-ti-cpufreq-only-register-platform_device-whe.patch
CommitLineData
ab0021f1
SL
1From 8bd74b34049c6007e42781406dbb6fcfb1b83da1 Mon Sep 17 00:00:00 2001
2From: Dave Gerlach <d-gerlach@ti.com>
3Date: Tue, 13 Nov 2018 13:30:40 -0600
4Subject: cpufreq: ti-cpufreq: Only register platform_device when supported
5
6[ Upstream commit d98ccfc3948ab63152494bb6b9c17e15295c0310 ]
7
8Currently the ti-cpufreq driver blindly registers a 'ti-cpufreq' to force
9the driver to probe on any platforms where the driver is built in.
10However, this should only happen on platforms that actually can make use
11of the driver. There is already functionality in place to match the
12SoC compatible so let's factor this out into a separate call and
13make sure we find a match before creating the ti-cpufreq platform device.
14
15Reviewed-by: Johan Hovold <johan@kernel.org>
16Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
17Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
18Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
19Signed-off-by: Sasha Levin <sashal@kernel.org>
20---
21 drivers/cpufreq/ti-cpufreq.c | 26 +++++++++++++++++++++-----
22 1 file changed, 21 insertions(+), 5 deletions(-)
23
24diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
25index 3f0e2a14895a..22b53bf26817 100644
26--- a/drivers/cpufreq/ti-cpufreq.c
27+++ b/drivers/cpufreq/ti-cpufreq.c
28@@ -201,19 +201,28 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
29 {},
30 };
31
32+static const struct of_device_id *ti_cpufreq_match_node(void)
33+{
34+ struct device_node *np;
35+ const struct of_device_id *match;
36+
37+ np = of_find_node_by_path("/");
38+ match = of_match_node(ti_cpufreq_of_match, np);
39+ of_node_put(np);
40+
41+ return match;
42+}
43+
44 static int ti_cpufreq_probe(struct platform_device *pdev)
45 {
46 u32 version[VERSION_COUNT];
47- struct device_node *np;
48 const struct of_device_id *match;
49 struct opp_table *ti_opp_table;
50 struct ti_cpufreq_data *opp_data;
51 const char * const reg_names[] = {"vdd", "vbb"};
52 int ret;
53
54- np = of_find_node_by_path("/");
55- match = of_match_node(ti_cpufreq_of_match, np);
56- of_node_put(np);
57+ match = dev_get_platdata(&pdev->dev);
58 if (!match)
59 return -ENODEV;
60
61@@ -290,7 +299,14 @@ fail_put_node:
62
63 static int ti_cpufreq_init(void)
64 {
65- platform_device_register_simple("ti-cpufreq", -1, NULL, 0);
66+ const struct of_device_id *match;
67+
68+ /* Check to ensure we are on a compatible platform */
69+ match = ti_cpufreq_match_node();
70+ if (match)
71+ platform_device_register_data(NULL, "ti-cpufreq", -1, match,
72+ sizeof(*match));
73+
74 return 0;
75 }
76 module_init(ti_cpufreq_init);
77--
782.19.1
79