提交 0799feaf 编写于 作者: D Dave Gerlach 提交者: Greg Kroah-Hartman

cpufreq: ti-cpufreq: Only register platform_device when supported

[ Upstream commit d98ccfc3948ab63152494bb6b9c17e15295c0310 ]

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: NJohan Hovold <johan@kernel.org>
Signed-off-by: NDave Gerlach <d-gerlach@ti.com>
Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 1a488242
...@@ -201,19 +201,28 @@ static const struct of_device_id ti_cpufreq_of_match[] = { ...@@ -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) static int ti_cpufreq_probe(struct platform_device *pdev)
{ {
u32 version[VERSION_COUNT]; u32 version[VERSION_COUNT];
struct device_node *np;
const struct of_device_id *match; const struct of_device_id *match;
struct opp_table *ti_opp_table; struct opp_table *ti_opp_table;
struct ti_cpufreq_data *opp_data; struct ti_cpufreq_data *opp_data;
const char * const reg_names[] = {"vdd", "vbb"}; const char * const reg_names[] = {"vdd", "vbb"};
int ret; int ret;
np = of_find_node_by_path("/"); match = dev_get_platdata(&pdev->dev);
match = of_match_node(ti_cpufreq_of_match, np);
of_node_put(np);
if (!match) if (!match)
return -ENODEV; return -ENODEV;
...@@ -290,7 +299,14 @@ static int ti_cpufreq_probe(struct platform_device *pdev) ...@@ -290,7 +299,14 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
static int ti_cpufreq_init(void) 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_data(NULL, "ti-cpufreq", -1, match,
sizeof(*match));
return 0; return 0;
} }
module_init(ti_cpufreq_init); module_init(ti_cpufreq_init);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册